50505504dd674af8e62c78404a0c2932d7e9f5e0
[citadel.git] / webcit / tiny_mce / plugins / example / editor_plugin_src.js
1 /**\r
2  * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $\r
3  *\r
4  * @author Moxiecode\r
5  * @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved.\r
6  */\r
7 \r
8 (function() {\r
9         // Load plugin specific language pack\r
10         tinymce.PluginManager.requireLangPack('example');\r
11 \r
12         tinymce.create('tinymce.plugins.ExamplePlugin', {\r
13                 /**\r
14                  * Initializes the plugin, this will be executed after the plugin has been created.\r
15                  * This call is done before the editor instance has finished it's initialization so use the onInit event\r
16                  * of the editor instance to intercept that event.\r
17                  *\r
18                  * @param {tinymce.Editor} ed Editor instance that the plugin is initialized in.\r
19                  * @param {string} url Absolute URL to where the plugin is located.\r
20                  */\r
21                 init : function(ed, url) {\r
22                         // Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('mceExample');\r
23                         ed.addCommand('mceExample', function() {\r
24                                 ed.windowManager.open({\r
25                                         file : url + '/dialog.htm',\r
26                                         width : 320 + parseInt(ed.getLang('example.delta_width', 0)),\r
27                                         height : 120 + parseInt(ed.getLang('example.delta_height', 0)),\r
28                                         inline : 1\r
29                                 }, {\r
30                                         plugin_url : url, // Plugin absolute URL\r
31                                         some_custom_arg : 'custom arg' // Custom argument\r
32                                 });\r
33                         });\r
34 \r
35                         // Register example button\r
36                         ed.addButton('example', {\r
37                                 title : 'example.desc',\r
38                                 cmd : 'mceExample',\r
39                                 image : url + '/img/example.gif'\r
40                         });\r
41 \r
42                         // Add a node change handler, selects the button in the UI when a image is selected\r
43                         ed.onNodeChange.add(function(ed, cm, n) {\r
44                                 cm.setActive('example', n.nodeName == 'IMG');\r
45                         });\r
46                 },\r
47 \r
48                 /**\r
49                  * Creates control instances based in the incomming name. This method is normally not\r
50                  * needed since the addButton method of the tinymce.Editor class is a more easy way of adding buttons\r
51                  * but you sometimes need to create more complex controls like listboxes, split buttons etc then this\r
52                  * method can be used to create those.\r
53                  *\r
54                  * @param {String} n Name of the control to create.\r
55                  * @param {tinymce.ControlManager} cm Control manager to use inorder to create new control.\r
56                  * @return {tinymce.ui.Control} New control instance or null if no control was created.\r
57                  */\r
58                 createControl : function(n, cm) {\r
59                         return null;\r
60                 },\r
61 \r
62                 /**\r
63                  * Returns information about the plugin as a name/value array.\r
64                  * The current keys are longname, author, authorurl, infourl and version.\r
65                  *\r
66                  * @return {Object} Name/value array containing information about the plugin.\r
67                  */\r
68                 getInfo : function() {\r
69                         return {\r
70                                 longname : 'Example plugin',\r
71                                 author : 'Some author',\r
72                                 authorurl : 'http://tinymce.moxiecode.com',\r
73                                 infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/example',\r
74                                 version : "1.0"\r
75                         };\r
76                 }\r
77         });\r
78 \r
79         // Register plugin\r
80         tinymce.PluginManager.add('example', tinymce.plugins.ExamplePlugin);\r
81 })();