Hopefully by now everyone is on board Edmund's new method of saving forms rather than nodes (5.2).
Now that this is so close to working i thought i would go down the path of adding support for TinyMCE - here's where i am at so far.
When AS is saving nodes it correctly saves the content from any Tiny enabled fields on the form.. yeaaay!!!
but it doesn't "recover" them when i return to saved node and VIEW.
From what i gather the fields are actually being updated but these are the hidden textarea fields that are behind the tiny iframe that would get enabled if tiny was disabled. We need to have jquery.field.js update both fields (the visible Tiny iframe one as well as the hidden one).
The place where this needs to be done is around line 242 or this code:
case "text":
this.value = v.join(defaults.delimiter);
break;
and, sadly i am not a jq expert but if someone could tell me how to access the innerHTML of body within "this" iframe with class=mceEditorIframe then i think we be about done.. :)
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | autosave-5.2b-0.3.zip | 18.67 KB | liquidcms |
| #8 | fixTinyReset.patch | 550 bytes | liquidcms |
| #6 | as-5.2b-0.2.zip | 19.07 KB | liquidcms |
| #3 | autosave.zip | 18.38 KB | liquidcms |
Comments
Comment #1
edmund.kwok commentedTry looking at updateContent() here http://wiki.moxiecode.com/index.php/TinyMCE:Functions
Comment #2
liquidcms commentededdie.. you da man!! works like a charm.. hopefully i'll wrap this up int he next hour and post a new ZIP
Comment #3
liquidcms commentedand here it is.. version 5.2 of autosave (single form per page only) with host of new features including support for TinyMCE.
- i likely should have some code to check if field is Tiny enabled.. but i left it off and non-tniy textareas still function ok.
- i should test with IE (all my testing is with FF)
sorry it's a zip and not patch..
i think outstanding issues to tie Edmund's branch and my "branch" together are:
- need generic solution for single or mutliforms per page
- need agreement on how to select which forms get autosaved; my solution only uses AS for node forms and therefore adds a node config setting to select if using autosave - possibly something like ajaxsubmit uses could be used - it adds cool admin UI that pops up on every form and asks if you want to add that one to the list of forms it knows about to enable for AS.
- anything else??
still toying with idea of adding AS period as user profile definable setting.
Comment #4
edmund.kwok commentedGreat! I'll look at the differences and commit the change soon, thanks!
Btw, regarding the interface for autosave configuration UI, did you try the one that I was toying around with? To see it in action, browse to any page with form(s) and append /configure-autosave to the url. For example, admin/content/taxonomy/add/vocabulary/configure-autosave
Comment #5
liquidcms commentedI was wondering what the configure_autosave was for.
So this ZIP includes version which fixes 2 bugs (almost).
- removes unsetting form_token so that form validates on sumbit
- adds nodeapi submit hook to remove AS table entry when node is submitted
bug #2 is only partially fixed with simple submit hook that i have added. There still exists issue of ajax firing off save near the same time user hits submit. Therefore submit hook will delete entry but action will already have been fired to save another copy - if it comes in after submit hook does the delete it will simply be recreated.
Likely need some sort of semaphore type lockout to prevent this properly - possibly a simple test if post[op]=submit is set when doing ajax submit would suffice? I'll test this out tomorrow.
Comment #6
liquidcms commentedhmm.. for some reason the ZIP didn't attach..
Comment #7
liquidcms commentedOne more issue which i have not tested in much depth - i don't think my integration with Tiny works for IE. I think it does the save ok, just not the VIEW (pulling saved content back into Tiny fields).
Comment #8
liquidcms commentedthere is/was also an issue with the Tiny fields not being reset when RESET is selected. This patches fixes that. Patch is on my ZIP'ed code in #6.
Still have outstanding IE issues - thats next.
Comment #9
liquidcms commentedan update on where i am at with this:
ADDED:
- i added this code to end of autosave.module to do the AS table clenup when a node is submitted:
but then realized their is an ajaxy issue that the submit could fire off around the time the ajax autosave routine fires andif it comes in after submit hook cleans the table - the entry will be replaced.
so i changed that function to this (somewhat cludgy but likely very reliable) way to ensure autosave routine doesn't add an entry if node has "just been saved:
Comment #10
liquidcms commentedOther issues/solutions i have finished or am working on include:
- in IE7 when i select VIEW only some fields are displayed correctly; others are blank
I originally thought this was a Tiny issue but appears to only be an IE7 issue. I have back reved a little ways and the issue is still there. I think jquery is fully functional with IE7 so that narrows the code down a bit. I'll back rev even further to see if i can narrow it down any more - hopefully shouldn't take to long to get this sorted out.
Pretty sure the issue is either in the formHash function or form.reset().
- there seems to be some issue with cursor jumping around inside a field
haven't looked at this much yet but will be next on my agenda.
- i use the checkout module (although revisions made to it) and i think it may be intefering with the autosave function - need to check that out as well.
and that's all i know of at the momeent.
Comment #11
liquidcms commentedfigured out cause of IE7 issue: the line in jqeury.field.js:
keys = n.split(/\[(\w*)\]/);
is not supoprted by IE7
i'll see if i can find a more generic way to do this.
Comment #12
liquidcms commentedsolution for IE7
it turns out IE7 doesn't do regex splits very well.. so using this code for the part that Edmund added to handle Drupal names with [] should be something like this (around line 303 of jquery.field.js):
i hate JS, i hate IE... so what could be worse.. JS in IE... grrr!!!
Comment #13
liquidcms commentedOk, here's my final update of this module. This fixes all the IE, Tiny, etc issues i have seen to date, including:
- Tiny fields loading properly
- cursor jumping to start of Tiny fields when autosave kicks in
- proper cleanup of autosave table on node submit.
- likely a couple other things.
enjoy.
Comment #14
bbenone commentedMaybe I am missing something here--- how do I turn on autosave for a form? I enabled the module and configed it to save every 10 seconds.
I went to /node/add/page
and waited... nothing...
So I looked through above and saw the discussion about appending /configure-autosave to the path. So I went to /node/add/page/configure-autosave
it says "autosave enabled" around the input fields. I would guess that means it should be working?
I can't get it to actually do anything though...
It should also be noted that (at least in firefox) I can not expand and then collapse a fieldset anywhere on my site w/ the module installed.
Comment #15
bbenone commentedBTW, I have this version of the module up and running here so that you can see the symptoms I'm describing above. I can't seem to get it to anything:
http://cakwak.com/autosavetest2/?q=node/add/page
login as
u: admin
p: admin
It's a bare Drupal 5.3 install with nothing extra on but this module and JQuery Update
Comment #16
liquidcms commentedoff the top of my head i would suggest you don't "really" have jquery update. Do you know that it is necessary to copy the version of jquery.js that comes with jqueyr_update into the /misc folder? Can you view the JS file that gets loaded in your browser and tell me what version it is?
Comment #17
bbenone commentedIts showing as JQuery 1.1.2
I did forget to copy over the JS file initially, but it's there now and it is still acting the same way.
It did fix the fieldsets so that they expand/collapse properly though :)
Comment #18
liquidcms commentedhave you configured?
did you set update period (not sure what default is)?
did you enable autosave for your node type?
Comment #19
bbenone commentedThat's exactly what I was asking how to do in my original post :) Based on the discussion in this thread I kept going to (for example) /node/add/page/configure-autosave to configure it.... I didn't think that there was another spot.
I found it though, inside the content type's configuration page. So now I'm up and running (sorta :) )
On a basic form like /node/add/page in firefox I am showing 1 JS error:
This prevents the form from ever re-saving after the first time.
In IE (6.0), it doesn't even save the first time. Just tells me "Unknown runtime error" in the JS console on page load.
If you'd like, you can login to my autosave test site as uid 1 to see the issue:
http://cakwak.com/autosavetest2/?q=node/add/page (admin/admin)
Thanks, dude-- this is looking pretty sweet. Among other things, I like the "Keep" link ya added :)
Comment #20
bbenone commentedjust realized I didn't get ya all the error information that FF was giving... in case it helps:
also, the following PHP errors show on the next page load:
Thanks...
Comment #21
Tamar Badichi-Levy commentedthe php warnings about line 521 in node.module are the result of calling node_load without a numeric parameter. This is sometimes done in autosave_save()
In order to solve that I have changed the above line:
$submitted = node_load($path_args[1]);to
and no more warnings...
Comment #22
Crell commented