summaryrefslogtreecommitdiff
path: root/public/javascripts/tiny_mce/plugins/save
diff options
context:
space:
mode:
Diffstat (limited to 'public/javascripts/tiny_mce/plugins/save')
-rwxr-xr-xpublic/javascripts/tiny_mce/plugins/save/editor_plugin.js1
-rwxr-xr-xpublic/javascripts/tiny_mce/plugins/save/editor_plugin_src.js98
2 files changed, 99 insertions, 0 deletions
diff --git a/public/javascripts/tiny_mce/plugins/save/editor_plugin.js b/public/javascripts/tiny_mce/plugins/save/editor_plugin.js
new file mode 100755
index 0000000..8a13e7d
--- /dev/null
+++ b/public/javascripts/tiny_mce/plugins/save/editor_plugin.js
@@ -0,0 +1 @@
(function(){tinymce.create('tinymce.plugins.Save',{init:function(ed,url){var t=this;t.editor=ed;ed.addCommand('mceSave',t._save,t);ed.addCommand('mceCancel',t._cancel,t);ed.addButton('save',{title:'save.save_desc',cmd:'mceSave'});ed.addButton('cancel',{title:'save.cancel_desc',cmd:'mceCancel'});ed.onNodeChange.add(t._nodeChange,t);ed.addShortcut('ctrl+s',ed.getLang('save.save_desc'),'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};},_nodeChange:function(ed,cm,n){var ed=this.editor;if(ed.getParam('save_enablewhendirty')){cm.setDisabled('save',!ed.isDirty());cm.setDisabled('cancel',!ed.isDirty());}},_save:function(){var ed=this.editor,formObj,os,i,elementId;formObj=tinymce.DOM.get(ed.id).form||tinymce.DOM.getParent(ed.id,'form');if(ed.getParam("save_enablewhendirty")&&!ed.isDirty())return;tinyMCE.triggerSave();if(os=ed.getParam("save_onsavecallback")){if(ed.execCallback('save_onsavecallback',ed)){ed.startContent=tinymce.trim(ed.getContent({format:'raw'}));ed.nodeChanged();}return;}if(formObj){ed.isNotDirty=true;if(formObj.onsubmit==null||formObj.onsubmit()!=false)formObj.submit();ed.nodeChanged();}else ed.windowManager.alert("Error: No form element found.");},_cancel:function(){var ed=this.editor,os,h=tinymce.trim(ed.startContent);if(os=ed.getParam("save_oncancelcallback")){ed.execCallback('save_oncancelcallback',ed);return;}ed.setContent(h);ed.undoManager.clear();ed.nodeChanged();}});tinymce.PluginManager.add('save',tinymce.plugins.Save);})(); \ No newline at end of file
diff --git a/public/javascripts/tiny_mce/plugins/save/editor_plugin_src.js b/public/javascripts/tiny_mce/plugins/save/editor_plugin_src.js
new file mode 100755
index 0000000..b38be4d
--- /dev/null
+++ b/public/javascripts/tiny_mce/plugins/save/editor_plugin_src.js
@@ -0,0 +1,98 @@
1/**
2 * $Id: editor_plugin_src.js 851 2008-05-26 15:38:49Z spocke $
3 *
4 * @author Moxiecode
5 * @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved.
6 */
7
8(function() {
9 tinymce.create('tinymce.plugins.Save', {
10 init : function(ed, url) {
11 var t = this;
12
13 t.editor = ed;
14
15 // Register commands
16 ed.addCommand('mceSave', t._save, t);
17 ed.addCommand('mceCancel', t._cancel, t);
18
19 // Register buttons
20 ed.addButton('save', {title : 'save.save_desc', cmd : 'mceSave'});
21 ed.addButton('cancel', {title : 'save.cancel_desc', cmd : 'mceCancel'});
22
23 ed.onNodeChange.add(t._nodeChange, t);
24 ed.addShortcut('ctrl+s', ed.getLang('save.save_desc'), 'mceSave');
25 },
26
27 getInfo : function() {
28 return {
29 longname : 'Save',
30 author : 'Moxiecode Systems AB',
31 authorurl : 'http://tinymce.moxiecode.com',
32 infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/save',
33 version : tinymce.majorVersion + "." + tinymce.minorVersion
34 };
35 },
36
37 // Private methods
38
39 _nodeChange : function(ed, cm, n) {
40 var ed = this.editor;
41
42 if (ed.getParam('save_enablewhendirty')) {
43 cm.setDisabled('save', !ed.isDirty());
44 cm.setDisabled('cancel', !ed.isDirty());
45 }
46 },
47
48 // Private methods
49
50 _save : function() {
51 var ed = this.editor, formObj, os, i, elementId;
52
53 formObj = tinymce.DOM.get(ed.id).form || tinymce.DOM.getParent(ed.id, 'form');
54
55 if (ed.getParam("save_enablewhendirty") && !ed.isDirty())
56 return;
57
58 tinyMCE.triggerSave();
59
60 // Use callback instead
61 if (os = ed.getParam("save_onsavecallback")) {
62 if (ed.execCallback('save_onsavecallback', ed)) {
63 ed.startContent = tinymce.trim(ed.getContent({format : 'raw'}));
64 ed.nodeChanged();
65 }
66
67 return;
68 }
69
70 if (formObj) {
71 ed.isNotDirty = true;
72
73 if (formObj.onsubmit == null || formObj.onsubmit() != false)
74 formObj.submit();
75
76 ed.nodeChanged();
77 } else
78 ed.windowManager.alert("Error: No form element found.");
79 },
80
81 _cancel : function() {
82 var ed = this.editor, os, h = tinymce.trim(ed.startContent);
83
84 // Use callback instead
85 if (os = ed.getParam("save_oncancelcallback")) {
86 ed.execCallback('save_oncancelcallback', ed);
87 return;
88 }
89
90 ed.setContent(h);
91 ed.undoManager.clear();
92 ed.nodeChanged();
93 }
94 });
95
96 // Register plugin
97 tinymce.PluginManager.add('save', tinymce.plugins.Save);
98})(); \ No newline at end of file