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