2 * $Id: editor_plugin_src.js 609 2008-02-18 16:19:27Z spocke $
\r
5 * @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved.
\r
9 tinymce.create('tinymce.plugins.Save', {
\r
10 init : function(ed, url) {
\r
15 // Register commands
\r
16 ed.addCommand('mceSave', t._save, t);
\r
17 ed.addCommand('mceCancel', t._cancel, t);
\r
20 ed.addButton('save', {title : 'save.save_desc', cmd : 'mceSave'});
\r
21 ed.addButton('cancel', {title : 'save.cancel_desc', cmd : 'mceCancel'});
\r
23 ed.onNodeChange.add(t._nodeChange, t);
\r
24 ed.addShortcut('ctrl+s', ed.getLang('save.save_desc'), 'mceSave');
\r
27 getInfo : function() {
\r
30 author : 'Moxiecode Systems AB',
\r
31 authorurl : 'http://tinymce.moxiecode.com',
\r
32 infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/save',
\r
33 version : tinymce.majorVersion + "." + tinymce.minorVersion
\r
39 _nodeChange : function(ed, cm, n) {
\r
40 var ed = this.editor;
\r
42 if (ed.getParam('save_enablewhendirty')) {
\r
43 cm.setDisabled('save', !ed.isDirty());
\r
44 cm.setDisabled('cancel', !ed.isDirty());
\r
50 _save : function() {
\r
51 var ed = this.editor, formObj, os, i, elementId;
\r
53 formObj = tinymce.DOM.get(ed.id).form || tinymce.DOM.getParent(ed.id, 'form');
\r
55 if (ed.getParam("save_enablewhendirty") && !ed.isDirty())
\r
58 tinyMCE.triggerSave();
\r
60 // Use callback instead
\r
61 if (os = ed.getParam("save_onsavecallback")) {
\r
62 if (ed.execCallback('save_onsavecallback', ed)) {
\r
63 ed.startContent = tinymce.trim(ed.getContent({format : 'raw'}));
\r
71 ed.isNotDirty = true;
\r
73 if (formObj.onsubmit == null || formObj.onsubmit() != false)
\r
78 ed.windowManager.alert("Error: No form element found.");
\r
83 _cancel : function() {
\r
84 var ed = this.editor, os, h = tinymce.trim(ed.startContent);
\r
86 // Use callback instead
\r
87 if (os = ed.getParam("save_oncancelcallback")) {
\r
88 ed.execCallback('save_oncancelcallback', ed);
\r
93 ed.undoManager.clear();
\r
99 tinymce.PluginManager.add('save', tinymce.plugins.Save);
\r