annotate WebContent/jscripts/tiny_mce/plugins/save/editor_plugin_src.js @ 6:5bb7cc86069c

restlet.jar
author dwinter
date Wed, 14 Mar 2012 16:21:45 +0100
parents 0be9d53a6967
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1 /**
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2 * editor_plugin_src.js
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3 *
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4 * Copyright 2009, Moxiecode Systems AB
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5 * Released under LGPL License.
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6 *
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
7 * License: http://tinymce.moxiecode.com/license
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
8 * Contributing: http://tinymce.moxiecode.com/contributing
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
9 */
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
10
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
11 (function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
12 tinymce.create('tinymce.plugins.Save', {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
13 init : function(ed, url) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
14 var t = this;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
15
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
16 t.editor = ed;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
17
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
18 // Register commands
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
19 ed.addCommand('mceSave', t._save, t);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
20 ed.addCommand('mceCancel', t._cancel, t);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
21
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
22 // Register buttons
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
23 ed.addButton('save', {title : 'save.save_desc', cmd : 'mceSave'});
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
24 ed.addButton('cancel', {title : 'save.cancel_desc', cmd : 'mceCancel'});
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
25
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
26 ed.onNodeChange.add(t._nodeChange, t);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
27 ed.addShortcut('ctrl+s', ed.getLang('save.save_desc'), 'mceSave');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
28 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
29
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
30 getInfo : function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
31 return {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
32 longname : 'Save',
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
33 author : 'Moxiecode Systems AB',
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
34 authorurl : 'http://tinymce.moxiecode.com',
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
35 infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/save',
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
36 version : tinymce.majorVersion + "." + tinymce.minorVersion
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
37 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
38 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
39
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
40 // Private methods
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
41
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
42 _nodeChange : function(ed, cm, n) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
43 var ed = this.editor;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
44
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
45 if (ed.getParam('save_enablewhendirty')) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
46 cm.setDisabled('save', !ed.isDirty());
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
47 cm.setDisabled('cancel', !ed.isDirty());
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
48 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
49 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
50
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
51 // Private methods
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
52
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
53 _save : function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
54 var ed = this.editor, formObj, os, i, elementId;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
55
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
56 formObj = tinymce.DOM.get(ed.id).form || tinymce.DOM.getParent(ed.id, 'form');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
57
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
58 if (ed.getParam("save_enablewhendirty") && !ed.isDirty())
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
59 return;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
60
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
61 tinyMCE.triggerSave();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
62
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
63 // Use callback instead
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
64 if (os = ed.getParam("save_onsavecallback")) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
65 if (ed.execCallback('save_onsavecallback', ed)) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
66 ed.startContent = tinymce.trim(ed.getContent({format : 'raw'}));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
67 ed.nodeChanged();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
68 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
69
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
70 return;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
71 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
72
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
73 if (formObj) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
74 ed.isNotDirty = true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
75
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
76 if (formObj.onsubmit == null || formObj.onsubmit() != false)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
77 formObj.submit();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
78
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
79 ed.nodeChanged();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
80 } else
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
81 ed.windowManager.alert("Error: No form element found.");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
82 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
83
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
84 _cancel : function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
85 var ed = this.editor, os, h = tinymce.trim(ed.startContent);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
86
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
87 // Use callback instead
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
88 if (os = ed.getParam("save_oncancelcallback")) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
89 ed.execCallback('save_oncancelcallback', ed);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
90 return;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
91 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
92
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
93 ed.setContent(h);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
94 ed.undoManager.clear();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
95 ed.nodeChanged();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
96 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
97 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
98
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
99 // Register plugin
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
100 tinymce.PluginManager.add('save', tinymce.plugins.Save);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
101 })();