]> git.sur5r.net Git - bacula/bacula/blob - gui/baculum/debian/missing-sources/framework/Web/Javascripts/source/tinymce-405/plugins/save/plugin.js
baculum: Add missing-sources directory in debian metadata structure
[bacula/bacula] / gui / baculum / debian / missing-sources / framework / Web / Javascripts / source / tinymce-405 / plugins / save / plugin.js
1 /**
2  * plugin.js
3  *
4  * Copyright, Moxiecode Systems AB
5  * Released under LGPL License.
6  *
7  * License: http://www.tinymce.com/license
8  * Contributing: http://www.tinymce.com/contributing
9  */
10
11 /*global tinymce:true */
12
13 tinymce.PluginManager.add('save', function(editor) {
14         function save() {
15                 var formObj, os;
16
17                 formObj = tinymce.DOM.getParent(editor.id, 'form');
18
19                 if (editor.getParam("save_enablewhendirty", true) && !editor.isDirty()) {
20                         return;
21                 }
22
23                 tinymce.triggerSave();
24
25                 // Use callback instead
26                 if ((os = editor.getParam("save_onsavecallback"))) {
27                         if (editor.execCallback('save_onsavecallback', editor)) {
28                                 editor.startContent = tinymce.trim(editor.getContent({format: 'raw'}));
29                                 editor.nodeChanged();
30                         }
31
32                         return;
33                 }
34
35                 if (formObj) {
36                         editor.isNotDirty = true;
37
38                         if (!formObj.onsubmit || formObj.onsubmit()) {
39                                 if (typeof(formObj.submit) == "function") {
40                                         formObj.submit();
41                                 } else {
42                                         editor.windowManager.alert("Error: Form submit field collision.");
43                                 }
44                         }
45
46                         editor.nodeChanged();
47                 } else {
48                         editor.windowManager.alert("Error: No form element found.");
49                 }
50         }
51
52         function cancel() {
53                 var os, h = tinymce.trim(editor.startContent);
54
55                 // Use callback instead
56                 if ((os = editor.getParam("save_oncancelcallback"))) {
57                         editor.execCallback('save_oncancelcallback', editor);
58                         return;
59                 }
60
61                 editor.setContent(h);
62                 editor.undoManager.clear();
63                 editor.nodeChanged();
64         }
65
66         function stateToggle() {
67                 var self = this;
68
69                 editor.on('nodeChange', function() {
70                         self.disabled(editor.getParam("save_enablewhendirty", true) && !editor.isDirty());
71                 });
72         }
73
74         editor.addCommand('mceSave', save);
75         editor.addCommand('mceCancel', cancel);
76
77         editor.addButton('save', {
78                 icon: 'save',
79                 text: 'Save',
80                 cmd: 'mceSave',
81                 disabled: true,
82                 onPostRender: stateToggle
83         });
84
85         editor.addButton('cancel', {
86                 text: 'Cancel',
87                 icon: false,
88                 cmd: 'mceCancel',
89                 disabled: true,
90                 onPostRender: stateToggle
91         });
92
93         editor.addShortcut('ctrl+s', '', 'mceSave');
94 });