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