comparison static/js/tiny_mce/plugins/save/editor_plugin_src.js @ 312:88b2b9cb8c1f

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