Changeset 3975


Ignore:
Timestamp:
05/24/09 14:45:54 (3 years ago)
Author:
MichaelTempest
Message:

Item1548: Add "onclick" to the various save and cancel buttons, that marks the editor as non-dirty, which inhibits the "data loss" warning.

Also disable "quiet save" and the "save and continue" buttons during TML <-> HTML conversions ("save" was already disabled in those times).

Location:
trunk/TinyMCEPlugin
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/TinyMCEPlugin/data/System/TinyMCEPlugin.txt

    r3973 r3975  
    128128 
    129129|  Author: | [[http://c-dot.co.uk][Crawford Currie]] | 
    130 |  Copyright: | &copy; 2007-2008 Crawford Currie http://c-dot.co.uk | 
     130|  Copyright: | &copy; 2007-2009 Crawford Currie http://c-dot.co.uk | 
    131131|  License: | [[http://www.gnu.org/licenses/gpl.html][GPL (Gnu General Public License)]] | 
    132132|             | This package also includes the complete sources for version 3.2.2 of the !TinyMCE editor which is covered by [[http://tinymce.moxiecode.com/license.php][its own license]]. | 
    133133|  Plugin Version: | %$VERSION% | 
    134134|  Change History: | <!-- versions below in reverse order -->&nbsp; | 
    135 |  24 May 2009 | Foswikitask:Item1205: add support for global NOWYSIWYG flag Foswikitask:Item1341: keep TML lettered & roman numeral lists (Michael Tempest) Foswikitask:Item1534: fix typewriter text (Michael Tempest) | 
     135|  24 May 2009 | Foswikitask:Item1205: add support for global NOWYSIWYG flag Foswikitask:Item1341: keep TML lettered & roman numeral lists (Michael Tempest) Foswikitask:Item1534: fix typewriter text (Michael Tempest) Foswikitask:Item1548: fix data-loss warning when saving from wiki-text (Michael Tempest) | 
    136136|  10 Apr 2009 | Foswikitask:Item1394: fixed colour handling Foswikitask:Item8108: added safari,inlinepopups,fullscreen plugins, fixed some minor bugs on IE | 
    137137|  3 Apr 2009 | Foswikitask:Item1383: Optimised the preferences Foswikitask:Item8094: fixed the pickaxe | 
  • trunk/TinyMCEPlugin/pub/System/TinyMCEPlugin/foswiki_tiny.js

    r3798 r3975  
    22return FoswikiTiny.foswikiVars[name];},expandVariables:function(url){for(var i in FoswikiTiny.foswikiVars){url=url.replace('%'+i+'%',FoswikiTiny.foswikiVars[i],'g');} 
    33return url;},enableSaveButton:function(enabled){var status=enabled?null:"disabled";var elm=document.getElementById("save");if(elm){elm.disabled=status;} 
     4elm=document.getElementById("quietsave");if(elm){elm.disabled=status;} 
     5elm=document.getElementById("checkpoint");if(elm){elm.disabled=status;} 
    46elm=document.getElementById("preview");if(elm){elm.style.display='none';elm.disabled=status;}},transform:function(editor,handler,text,onSuccess,onFail){var url=FoswikiTiny.getFoswikiVar("SCRIPTURL");var suffix=FoswikiTiny.getFoswikiVar("SCRIPTSUFFIX");if(suffix==null)suffix='';url+="/rest"+suffix+"/WysiwygPlugin/"+handler;var path=FoswikiTiny.getFoswikiVar("WEB")+'.' 
    57+FoswikiTiny.getFoswikiVar("TOPIC");tinymce.util.XHR.send({url:url,content_type:"application/x-www-form-urlencoded",type:"POST",data:"nocache="+encodeURIComponent((new Date()).getTime()) 
    68+"&topic="+encodeURIComponent(path) 
    7 +"&text="+encodeURIComponent(text),async:true,scope:editor,success:onSuccess,error:onFail})},initialisedFromServer:false,setUpContent:function(editor_id,body,doc){if(FoswikiTiny.initialisedFromServer)return;var editor=tinyMCE.getInstanceById(editor_id);FoswikiTiny.switchToWYSIWYG(editor);FoswikiTiny.initialisedFromServer=true;},onSubmitHandler:false,switchToRaw:function(editor){var text=editor.getContent();document.getElementById("foswikiTinyMcePluginWysiwygEditHelp").style.display='none';document.getElementById("foswikiTinyMcePluginRawEditHelp").style.display='block';for(var i=0;i<FoswikiTiny.html2tml.length;i++){var cb=FoswikiTiny.html2tml[i];text=cb.apply(editor,[editor,text]);} 
     9+"&text="+encodeURIComponent(text),async:true,scope:editor,success:onSuccess,error:onFail})},initialisedFromServer:false,setUpContent:function(editor_id,body,doc){if(FoswikiTiny.initialisedFromServer)return;var editor=tinyMCE.getInstanceById(editor_id);FoswikiTiny.switchToWYSIWYG(editor);FoswikiTiny.initialisedFromServer=true;},cleanBeforeSave:function(eid,buttonId){var el=document.getElementById(buttonId);if(el==null) 
     10return;el.onclick=function(){var editor=tinyMCE.getInstanceById(eid);editor.isNotDirty=true;return true;}},onSubmitHandler:false,switchToRaw:function(editor){var text=editor.getContent();document.getElementById("foswikiTinyMcePluginWysiwygEditHelp").style.display='none';document.getElementById("foswikiTinyMcePluginRawEditHelp").style.display='block';for(var i=0;i<FoswikiTiny.html2tml.length;i++){var cb=FoswikiTiny.html2tml[i];text=cb.apply(editor,[editor,text]);} 
    811FoswikiTiny.enableSaveButton(false);editor.getElement().value="Please wait... retrieving page from server.";FoswikiTiny.transform(editor,"html2tml",text,function(text,req,o){this.getElement().value=text;FoswikiTiny.enableSaveButton(true);},function(type,req,o){this.setContent("<div class='foswikiAlert'>" 
    912+"There was a problem retrieving " 
     
    1114+type+" "+req.status+"</div>");});var eid=editor.id;var id=eid+"_2WYSIWYG";var el=document.getElementById(id);if(el){el.style.display="block";}else{el=document.createElement('INPUT');el.id=id;el.type="button";el.value="WYSIWYG";el.className="foswikiButton";el.onclick=function(){document.getElementById("foswikiTinyMcePluginWysiwygEditHelp").style.display='block';document.getElementById("foswikiTinyMcePluginRawEditHelp").style.display='none';tinyMCE.execCommand("mceToggleEditor",null,eid);FoswikiTiny.switchToWYSIWYG(editor);return false;} 
    1215var pel=editor.getElement().parentNode;pel.insertBefore(el,editor.getElement());} 
    13 editor.getElement().onchange=function(){var editor=tinyMCE.getInstanceById(eid);editor.isNotDirty=false;return true;},this.onSubmitHandler=function(ed,e){editor.initialized=false;};editor.onSubmit.addToTop(this.onSubmitHandler);},switchToWYSIWYG:function(editor){editor.getElement().onchange=null;var text=editor.getElement().value;if(this.onSubmitHandler){editor.onSubmit.remove(this.onSubmitHandler);this.onSubmitHandler=null;} 
     16editor.getElement().onchange=function(){var editor=tinyMCE.getInstanceById(eid);editor.isNotDirty=false;return true;},this.onSubmitHandler=function(ed,e){editor.initialized=false;};editor.onSubmit.addToTop(this.onSubmitHandler);FoswikiTiny.cleanBeforeSave(eid,"save");FoswikiTiny.cleanBeforeSave(eid,"quietsave");FoswikiTiny.cleanBeforeSave(eid,"checkpoint");FoswikiTiny.cleanBeforeSave(eid,"preview");FoswikiTiny.cleanBeforeSave(eid,"cancel");},switchToWYSIWYG:function(editor){editor.getElement().onchange=null;var text=editor.getElement().value;if(this.onSubmitHandler){editor.onSubmit.remove(this.onSubmitHandler);this.onSubmitHandler=null;} 
    1417FoswikiTiny.enableSaveButton(false);editor.setContent("<span class='foswikiAlert'>" 
    1518+"Please wait... retrieving page from server." 
  • trunk/TinyMCEPlugin/pub/System/TinyMCEPlugin/foswiki_tiny_src.js

    r3799 r3975  
    4444        var status = enabled ? null : "disabled"; 
    4545        var elm = document.getElementById("save"); 
     46        if (elm) { 
     47            elm.disabled = status; 
     48        } 
     49        elm = document.getElementById("quietsave"); 
     50        if (elm) { 
     51            elm.disabled = status; 
     52        } 
     53        elm = document.getElementById("checkpoint"); 
    4654        if (elm) { 
    4755            elm.disabled = status; 
     
    8997        FoswikiTiny.switchToWYSIWYG(editor); 
    9098        FoswikiTiny.initialisedFromServer = true; 
     99    }, 
     100 
     101    cleanBeforeSave : function (eid, buttonId) { 
     102        var el = document.getElementById(buttonId); 
     103        if (el == null) 
     104            return; 
     105        // SMELL: what if there is already an onclick handler? 
     106        el.onclick = function () { 
     107            var editor = tinyMCE.getInstanceById(eid); 
     108            editor.isNotDirty = true; 
     109            return true; 
     110        } 
    91111    }, 
    92112 
     
    168188        // to break when we upgrade TMCE 
    169189        editor.onSubmit.addToTop(this.onSubmitHandler); 
     190        // Make the save buttons mark the text as not-dirty  
     191        // to avoid the popup that says "Are you sure? The changes you have made will be lost" 
     192        FoswikiTiny.cleanBeforeSave(eid, "save"); 
     193        FoswikiTiny.cleanBeforeSave(eid, "quietsave"); 
     194        FoswikiTiny.cleanBeforeSave(eid, "checkpoint"); 
     195        // preview shouldn't get the popup either, when preview is enabled one day 
     196        FoswikiTiny.cleanBeforeSave(eid, "preview");  
     197        // cancel shouldn't get the popup because the user just *said* they want to cancel 
     198        FoswikiTiny.cleanBeforeSave(eid, "cancel");  
    170199    }, 
    171200 
Note: See TracChangeset for help on using the changeset viewer.