diff -r c72b545f1304 -r 67bd3121a12e includes/clientside/tinymce/plugins/save/editor_plugin_src.js --- a/includes/clientside/tinymce/plugins/save/editor_plugin_src.js Wed Dec 26 00:37:26 2007 -0500 +++ b/includes/clientside/tinymce/plugins/save/editor_plugin_src.js Thu Dec 27 22:09:33 2007 -0500 @@ -1,115 +1,103 @@ /** - * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $ + * $Id: editor_plugin_src.js 372 2007-11-11 18:38:50Z spocke $ * * @author Moxiecode * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved. */ -/* Import plugin specific language pack */ -tinyMCE.importPluginLanguagePack('save'); +(function() { + tinymce.create('tinymce.plugins.Save', { + init : function(ed, url) { + var t = this; + + t.editor = ed; -var TinyMCE_SavePlugin = { - getInfo : function() { - return { - longname : 'Save', - author : 'Moxiecode Systems AB', - authorurl : 'http://tinymce.moxiecode.com', - infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/save', - version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion - }; - }, + // Register commands + ed.addCommand('mceSave', t._save, t); + ed.addCommand('mceCancel', t._cancel, t); + + // Register buttons + ed.addButton('save', {title : 'save.save_desc', cmd : 'mceSave'}); + ed.addButton('cancel', {title : 'save.cancel_desc', cmd : 'mceCancel'}); - initInstance : function(inst) { - inst.addShortcut('ctrl', 's', 'lang_save_desc', 'mceSave'); - }, + ed.onNodeChange.add(t._nodeChange, t); + ed.addShortcut('ctrl+s', ed.getLang('save.save_desc'), 'mceSave'); + }, - /** - * Returns the HTML contents of the save control. - */ - getControlHTML : function(cn) { - switch (cn) { - case "save": - return tinyMCE.getButtonHTML(cn, 'lang_save_desc', '{$pluginurl}/images/save.gif', 'mceSave'); - } + getInfo : function() { + return { + longname : 'Save', + author : 'Moxiecode Systems AB', + authorurl : 'http://tinymce.moxiecode.com', + infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/save', + version : tinymce.majorVersion + "." + tinymce.minorVersion + }; + }, - return ""; - }, + // Private methods - /** - * Executes the save command. - */ - execCommand : function(editor_id, element, command, user_interface, value) { - // Handle commands - switch (command) { - case "mceSave": - if (tinyMCE.getParam("fullscreen_is_enabled")) - return true; + _nodeChange : function(ed, cm, n) { + var ed = this.editor; - var inst = tinyMCE.selectedInstance; - var formObj = inst.formElement.form; + if (ed.getParam('save_enablewhendirty')) { + cm.setDisabled('save', !ed.isDirty()); + cm.setDisabled('cancel', !ed.isDirty()); + } + }, - if (tinyMCE.getParam("save_enablewhendirty") && !inst.isDirty()) - return true; + // Private methods + + _save : function() { + var ed = this.editor, formObj, os, i, elementId; - if (formObj) { - tinyMCE.triggerSave(); + if (ed.getParam("fullscreen_is_enabled")) + return true; + + formObj = tinymce.DOM.get(ed.id).form; + + if (ed.getParam("save_enablewhendirty") && !ed.isDirty()) + return true; - // Use callback instead - var os; - if ((os = tinyMCE.getParam("save_onsavecallback"))) { - if (eval(os + '(inst);')) { - inst.startContent = tinyMCE.trim(inst.getBody().innerHTML); - /*inst.undoLevels = new Array(); - inst.undoIndex = 0; - inst.typingUndoIndex = -1; - inst.undoRedo = true; - inst.undoLevels[inst.undoLevels.length] = inst.startContent;*/ - tinyMCE.triggerNodeChange(false, true); - } + if (formObj) { + tinyMCE.triggerSave(); - return true; + // Use callback instead + if (os = ed.getParam("save_onsavecallback")) { + if (ed.execCallback('save_onsavecallback', ed)) { + ed.startContent = tinymce.trim(ed.getContent({format : 'raw'})); + ed.nodeChanged(); } - // Disable all UI form elements that TinyMCE created - for (var i=0; i