]> code.citadel.org Git - citadel.git/blob - webcit/tiny_mce/plugins/_template/editor_plugin_src.js
* Upgraded TinyMCE to version 2.0RC3. This fixes a conflict with
[citadel.git] / webcit / tiny_mce / plugins / _template / editor_plugin_src.js
1 /* Import plugin specific language pack */
2 tinyMCE.importPluginLanguagePack('template', 'en,he,no'); // <- Add a comma separated list of all supported languages
3
4 /****
5  * Steps for creating a plugin from this template:
6  *
7  * 1. Change all "template" to the name of your plugin.
8  * 2. Remove all the callbacks in this file that you don't need.
9  * 3. Remove the popup.htm file if you don't need any popups.
10  * 4. Add your custom logic to the callbacks you needed.
11  * 5. Write documentation in a readme.txt file on how to use the plugin.
12  * 6. Upload it under the "Plugins" section at sourceforge.
13  *
14  ****/
15
16 /**
17  * Information about the plugin.
18  */
19 function TinyMCE_template_getInfo() {
20         return {
21                 longname : 'Template plugin',
22                 author : 'Your name',
23                 authorurl : 'http://www.yoursite.com',
24                 infourl : 'http://www.yoursite.com/docs/template.html',
25                 version : "1.0"
26         };
27 };
28
29 /**
30  * Gets executed when a editor instance is initialized
31  */
32 function TinyMCE_template_initInstance(inst) {
33         // You can take out plugin specific parameters
34         alert("Initialization parameter:" + tinyMCE.getParam("template_someparam", false));
35 }
36
37 /**
38  * Gets executed when a editor needs to generate a button.
39  */
40 function TinyMCE_template_getControlHTML(control_name) {
41         switch (control_name) {
42                 case "template":
43                         return '<a href="javascript:tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceTemplate\', true);" target="_self" onmousedown="return false;"><img id="{$editor_id}_template" src="{$pluginurl}/images/template.gif" title="{$lang_template_desc}" width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');" /></a>';
44         }
45
46         return "";
47 }
48
49 /**
50  * Gets executed when a command is called.
51  */
52 function TinyMCE_template_execCommand(editor_id, element, command, user_interface, value) {
53         // Handle commands
54         switch (command) {
55                 // Remember to have the "mce" prefix for commands so they don't intersect with built in ones in the browser.
56                 case "mceTemplate":
57                         // Show UI/Popup
58                         if (user_interface) {
59                                 // Open a popup window and send in some custom data in a window argument
60                                 var template = new Array();
61
62                                 template['file'] = '../../plugins/template/popup.htm'; // Relative to theme
63                                 template['width'] = 300;
64                                 template['height'] = 200;
65
66                                 tinyMCE.openWindow(template, {editor_id : editor_id, some_custom_arg : "somecustomdata"});
67
68                                 // Let TinyMCE know that something was modified
69                                 tinyMCE.triggerNodeChange(false);
70                         } else {
71                                 // Do a command this gets called from the template popup
72                                 alert("execCommand: mceTemplate gets called from popup.");
73                         }
74
75                         return true;
76         }
77
78         // Pass to next handler in chain
79         return false;
80 }
81
82 /**
83  * Gets executed when the selection/cursor position was changed.
84  */
85 function TinyMCE_template_handleNodeChange(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) {
86         // Deselect template button
87         tinyMCE.switchClassSticky(editor_id + '_template', 'mceButtonNormal');
88
89         // Select template button if parent node is a strong or b
90         if (node.parentNode.nodeName == "STRONG" || node.parentNode.nodeName == "B")
91                 tinyMCE.switchClassSticky(editor_id + '_template', 'mceButtonSelected');
92
93         return true;
94 }
95
96 /**
97  * Gets executed when contents is inserted / retrived.
98  */
99 function TinyMCE_template_cleanup(type, content) {
100         switch (type) {
101                 case "get_from_editor":
102                         alert("[FROM] Value HTML string: " + content);
103
104                         // Do custom cleanup code here
105
106                         break;
107
108                 case "insert_to_editor":
109                         alert("[TO] Value HTML string: " + content);
110
111                         // Do custom cleanup code here
112
113                         break;
114
115                 case "get_from_editor_dom":
116                         alert("[FROM] Value DOM Element " + content.innerHTML);
117
118                         // Do custom cleanup code here
119
120                         break;
121
122                 case "insert_to_editor_dom":
123                         alert("[TO] Value DOM Element: " + content.innerHTML);
124
125                         // Do custom cleanup code here
126
127                         break;
128         }
129
130         return content;
131 }