applied my changes - initial import
[boxroom-stian.git] / public / javascripts / tiny_mce / plugins / save / editor_plugin_src.js
blobe505cdf51d36142fa37a42bf826bf9efa0303ee2
1 /**
2 * $Id: editor_plugin_src.js 126 2006-10-22 16:19:55Z spocke $
4 * @author Moxiecode
5 * @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved.
6 */
8 /* Import plugin specific language pack */
9 tinyMCE.importPluginLanguagePack('save');
11 var TinyMCE_SavePlugin = {
12 getInfo : function() {
13 return {
14 longname : 'Save',
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');
26 /**
27 * Returns the HTML contents of the save control.
29 getControlHTML : function(cn) {
30 switch (cn) {
31 case "save":
32 return tinyMCE.getButtonHTML(cn, 'lang_save_desc', '{$pluginurl}/images/save.gif', 'mceSave');
35 return "";
38 /**
39 * Executes the save command.
41 execCommand : function(editor_id, element, command, user_interface, value) {
42 // Handle commands
43 switch (command) {
44 case "mceSave":
45 if (tinyMCE.getParam("fullscreen_is_enabled"))
46 return true;
48 var inst = tinyMCE.selectedInstance;
49 var formObj = inst.formElement.form;
51 if (tinyMCE.getParam("save_enablewhendirty") && !inst.isDirty())
52 return true;
54 if (formObj) {
55 tinyMCE.triggerSave();
57 // Use callback instead
58 var os;
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();
63 inst.undoIndex = 0;
64 inst.typingUndoIndex = -1;
65 inst.undoRedo = true;
66 inst.undoLevels[inst.undoLevels.length] = inst.startContent;*/
67 tinyMCE.triggerNodeChange(false, true);
70 return 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();
85 } else
86 alert("Error: No form element found.");
88 return true;
90 // Pass to next handler in chain
91 return false;
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');
97 return true;
100 if (tinyMCE.getParam("save_enablewhendirty")) {
101 var inst = tinyMCE.getInstanceById(editor_id);
103 if (inst.isDirty()) {
104 tinyMCE.switchClass(editor_id + '_save', 'mceButtonNormal');
105 return true;
108 tinyMCE.switchClass(editor_id + '_save', 'mceButtonDisabled');
111 return true;
115 tinyMCE.addPlugin("save", TinyMCE_SavePlugin);