d950113a483d14cac84b974887d90a06754bb2ad
[atutor.git] / docs / jscripts / tiny_mce / plugins / acheck / editor_plugin_src.js
1 /**\r
2  * $Id: editor_plugin_src.js 201 2008-04-17 15:56:56Z cindy $\r
3  *\r
4  * @author Cindy Li\r
5  * @copyright Copyright © 2008, ATutor, All rights reserved.\r
6  */\r
7 \r
8 (function() {\r
9         // Load plugin specific language pack\r
10         tinymce.PluginManager.requireLangPack('acheck');\r
11 \r
12         tinymce.create('tinymce.plugins.AcheckPlugin', {\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('mceACheck');\r
23                         ed.addCommand('mceACheck', function() {\r
24 \r
25                                         var theCode = '<html><body onLoad="document.accessform.submit();"> \n';\r
26                                         theCode += '<h1>Submitting Code for Accessibility Checking.....</h1>\n';\r
27                                         theCode += '<form action="http://achecker.ca/checker/index.php" name="accessform" method="post"> \n';\r
28                                         theCode += '<input type="hidden" name="gid[]" value="8" /> \n';\r
29                                         theCode += '<textarea name="validate_content">' + tinyMCE.activeEditor.getContent() + '</textarea>\n';\r
30                                         theCode += '<input type="submit" /></form> \n';  \r
31                                         theCode += '</body></html> \n';\r
32                                         accessWin = window.open('', 'accessWin',  '');\r
33                                         accessWin.document.writeln(theCode);\r
34                                         accessWin.document.close();\r
35                         });\r
36 \r
37                         // Register ACheck button\r
38                         ed.addButton('acheck', {\r
39                                 title : 'acheck.desc',\r
40                                 cmd : 'mceACheck',\r
41                                 image : url + '/img/acheck.gif'\r
42                         });\r
43 \r
44                         // Add a node change handler, selects the button in the UI when a image is selected\r
45                         ed.onNodeChange.add(function(ed, cm, n) {\r
46                                 cm.setActive('acheck', n.nodeName == 'acheck');\r
47                         });\r
48                 },\r
49 \r
50                 /**\r
51                  * Creates control instances based in the incomming name. This method is normally not\r
52                  * needed since the addButton method of the tinymce.Editor class is a more easy way of adding buttons\r
53                  * but you sometimes need to create more complex controls like listboxes, split buttons etc then this\r
54                  * method can be used to create those.\r
55                  *\r
56                  * @param {String} n Name of the control to create.\r
57                  * @param {tinymce.ControlManager} cm Control manager to use inorder to create new control.\r
58                  * @return {tinymce.ui.Control} New control instance or null if no control was created.\r
59                  */\r
60                 createControl : function(n, cm) {\r
61                         return null;\r
62                 },\r
63 \r
64                 /**\r
65                  * Returns information about the plugin as a name/value array.\r
66                  * The current keys are longname, author, authorurl, infourl and version.\r
67                  *\r
68                  * @return {Object} Name/value array containing information about the plugin.\r
69                  */\r
70                 getInfo : function() {\r
71                         return {\r
72                                 longname : 'ACheck Plugin',\r
73                                 author   : 'ATutor',\r
74                                 authorurl : 'http://www.atutor.ca',\r
75                                 infourl : 'http://www.atutor.ca',\r
76                                 version : "1.0"\r
77                         };\r
78                 }\r
79         });\r
80 \r
81         // Register plugin\r
82         tinymce.PluginManager.add('acheck', tinymce.plugins.AcheckPlugin);\r
83 })();\r