]> code.citadel.org Git - citadel.git/blob - webcit/tiny_mce/plugins/_template/editor_plugin.js
* Removed the Kevin Roth rich text editor and replaced it with TinyMCE.
[citadel.git] / webcit / tiny_mce / plugins / _template / editor_plugin.js
1 /* Import plugin specific language pack */
2 tinyMCE.importPluginLanguagePack('template', 'en'); // <- 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  * Gets executed when a editor instance is initialized
18  */
19 function TinyMCE_template_initInstance(inst) {
20         // You can take out plugin specific parameters
21         alert("Initialization parameter:" + tinyMCE.getParam("template_someparam", false));
22 }
23
24 /**
25  * Gets executed when a editor needs to generate a button.
26  */
27 function TinyMCE_template_getControlHTML(control_name) {
28         switch (control_name) {
29                 case "template":
30                         return '<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\');tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceTemplate\', true);" />';
31         }
32
33         return "";
34 }
35
36 /**
37  * Gets executed when a command is called.
38  */
39 function TinyMCE_template_execCommand(editor_id, element, command, user_interface, value) {
40         // Handle commands
41         switch (command) {
42                 // Remember to have the "mce" prefix for commands so they don't intersect with built in ones in the browser.
43                 case "mceTemplate":
44                         // Show UI/Popup
45                         if (user_interface) {
46                                 // Open a popup window and send in some custom data in a window argument
47                                 var template = new Array();
48
49                                 template['file'] = '../../plugins/template/popup.htm'; // Relative to theme
50                                 template['width'] = 300;
51                                 template['height'] = 200;
52
53                                 tinyMCE.openWindow(template, {editor_id : editor_id, some_custom_arg : "somecustomdata"});
54
55                                 // Let TinyMCE know that something was modified
56                                 tinyMCE.triggerNodeChange(false);
57                         } else {
58                                 // Do a command this gets called from the template popup
59                                 alert("execCommand: mceTemplate gets called from popup.");
60                         }
61
62                         return true;
63         }
64
65         // Pass to next handler in chain
66         return false;
67 }
68
69 /**
70  * Gets executed when the selection/cursor position was changed.
71  */
72 function TinyMCE_template_handleNodeChange(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) {
73         // Deselect template button
74         tinyMCE.switchClassSticky(editor_id + '_template', 'mceButtonNormal');
75
76         // Select template button if parent node is a strong or b
77         if (node.parentNode.nodeName == "STRONG" || node.parentNode.nodeName == "B")
78                 tinyMCE.switchClassSticky(editor_id + '_template', 'mceButtonSelected');
79
80         return true;
81 }
82
83 /**
84  * Gets executed when contents is inserted / retrived.
85  */
86 function TinyMCE_template_cleanup(type, content) {
87         switch (type) {
88                 case "get_from_editor":
89                         alert("[FROM] Value HTML string: " + content);
90
91                         // Do custom cleanup code here
92
93                         break;
94
95                 case "insert_to_editor":
96                         alert("[TO] Value HTML string: " + content);
97
98                         // Do custom cleanup code here
99
100                         break;
101
102                 case "get_from_editor_dom":
103                         alert("[FROM] Value DOM Element " + content.innerHTML);
104
105                         // Do custom cleanup code here
106
107                         break;
108
109                 case "insert_to_editor_dom":
110                         alert("[TO] Value DOM Element: " + content.innerHTML);
111
112                         // Do custom cleanup code here
113
114                         break;
115         }
116
117         return content;
118 }