ddb62dd381672290513f535274a49a168e67f3f6
[atutor.git] / docs / jscripts / ATutor_tiny_mce_plugins / swap_toolbar / editor_plugin_src.js
1 /**\r
2  * $Id: $\r
3  *\r
4  * @author Laurel A. Williams\r
5  * @copyright Copyright © 2008, ATutor, All rights reserved.\r
6  */\r
7 \r
8 /*global tinymce*/\r
9 \r
10 "use strict";\r
11 (function () {\r
12         \r
13         // Load plugin specific language pack\r
14         tinymce.PluginManager.requireLangPack('swap_toolbar');\r
15         \r
16         tinymce.create('tinymce.plugins.Swap_toolbarPlugin', {\r
17                 \r
18                 /**\r
19                  * Initializes the plugin, this will be executed after the plugin has been created.\r
20                  * This call is done before the editor instance has finished it's initialization so use the onInit event\r
21                  * of the editor instance to intercept that event.\r
22                  *\r
23                  * @param {tinymce.Editor} ed Editor instance that the plugin is initialized in.\r
24                  * @param {string} url Absolute URL to where the plugin is located.\r
25                  */\r
26                 init : function (ed, url) {                     \r
27                         \r
28                         ed.addCommand('mceSwapToComplex', function () {\r
29                                 tinyMCE.execCommand('mceRemoveControl', false, ed.id);\r
30                                 ATutor.tinymce.initComplex();\r
31                 tinyMCE.execCommand('mceAddControl', false, ed.id);\r
32                 jQuery("#complexeditor").val('1');\r
33                         });\r
34                         \r
35                         ed.addButton('swap_toolbar_complex', {\r
36                                 title : 'swap_toolbar_complex.desc',\r
37                                 cmd : 'mceSwapToComplex',\r
38                                 image : url + '/img/bullet_arrow_down.png'\r
39                         });\r
40                         \r
41                         ed.addCommand('mceSwapToSimple', function () {\r
42                                 tinyMCE.execCommand('mceRemoveControl', false, ed.id);\r
43                                 ATutor.tinymce.initSimple();\r
44                 tinyMCE.execCommand('mceAddControl', false, ed.id);\r
45                 jQuery("#complexeditor").val('0');\r
46                         });\r
47                         \r
48                         ed.addButton('swap_toolbar_simple', {\r
49                                 title : 'swap_toolbar_simple.desc',\r
50                                 cmd : 'mceSwapToSimple',\r
51                                 image : url + '/img/bullet_arrow_up.png'\r
52                         });\r
53                 },      \r
54                 \r
55                 \r
56                 /**\r
57                  * Returns information about the plugin as a name/value array. The\r
58                  * current keys are longname, author, authorurl, infourl and version.\r
59                  * \r
60                  * @return {Object} Name/value array containing information about the\r
61                  *         plugin.\r
62                  */\r
63                 getInfo : function () {\r
64                         return {\r
65                                 longname : 'Swap toolbar plugin',\r
66                                 author : 'ATutor',\r
67                                 authorurl : 'http://www.atutor.ca',\r
68                                 infourl : 'http://www.atutor.ca',\r
69                                 version : "0.9beta"\r
70                         };\r
71                 }\r
72         });\r
73 \r
74         // Register plugin\r
75         tinymce.PluginManager.add('swap_toolbar', tinymce.plugins.Swap_toolbarPlugin);\r
76 })();