2 * $Id: editor_plugin_src.js 126 2006-10-22 16:19:55Z spocke $
5 * @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved.
8 /* Import plugin specific language pack */
9 tinyMCE
.importPluginLanguagePack('save');
11 var TinyMCE_SavePlugin
= {
12 getInfo : function() {
15 author
: 'Moxiecode Systems AB',
16 authorurl
: 'http://tinymce.moxiecode.com',
17 infourl
: 'http://tinymce.moxiecode.com/tinymce/docs/plugin_save.html',
18 version
: tinyMCE
.majorVersion
+ "." + tinyMCE
.minorVersion
22 initInstance : function(inst
) {
23 inst
.addShortcut('ctrl', 's', 'lang_save_desc', 'mceSave');
27 * Returns the HTML contents of the save control.
29 getControlHTML : function(cn
) {
32 return tinyMCE
.getButtonHTML(cn
, 'lang_save_desc', '{$pluginurl}/images/save.gif', 'mceSave');
39 * Executes the save command.
41 execCommand : function(editor_id
, element
, command
, user_interface
, value
) {
45 if (tinyMCE
.getParam("fullscreen_is_enabled"))
48 var inst
= tinyMCE
.selectedInstance
;
49 var formObj
= inst
.formElement
.form
;
51 if (tinyMCE
.getParam("save_enablewhendirty") && !inst
.isDirty())
55 tinyMCE
.triggerSave();
57 // Use callback instead
59 if ((os
= tinyMCE
.getParam("save_onsavecallback"))) {
60 if (eval(os
+ '(inst);')) {
61 inst
.startContent
= tinyMCE
.trim(inst
.getBody().innerHTML
);
62 /*inst.undoLevels = new Array();
64 inst.typingUndoIndex = -1;
66 inst.undoLevels[inst.undoLevels.length] = inst.startContent;*/
67 tinyMCE
.triggerNodeChange(false, true);
73 // Disable all UI form elements that TinyMCE created
74 for (var i
=0; i
<formObj
.elements
.length
; i
++) {
75 var elementId
= formObj
.elements
[i
].name
? formObj
.elements
[i
].name
: formObj
.elements
[i
].id
;
77 if (elementId
.indexOf('mce_editor_') == 0)
78 formObj
.elements
[i
].disabled
= true;
81 tinyMCE
.isNotDirty
= true;
83 if (formObj
.onsubmit
== null || formObj
.onsubmit() != false)
84 inst
.formElement
.form
.submit();
86 alert("Error: No form element found.");
90 // Pass to next handler in chain
94 handleNodeChange : function(editor_id
, node
, undo_index
, undo_levels
, visual_aid
, any_selection
) {
95 if (tinyMCE
.getParam("fullscreen_is_enabled")) {
96 tinyMCE
.switchClass(editor_id
+ '_save', 'mceButtonDisabled');
100 if (tinyMCE
.getParam("save_enablewhendirty")) {
101 var inst
= tinyMCE
.getInstanceById(editor_id
);
103 if (inst
.isDirty()) {
104 tinyMCE
.switchClass(editor_id
+ '_save', 'mceButtonNormal');
108 tinyMCE
.switchClass(editor_id
+ '_save', 'mceButtonDisabled');
115 tinyMCE
.addPlugin("save", TinyMCE_SavePlugin
);