1 /* Import plugin specific language pack */
\r
3 tinyMCE.importPluginLanguagePack('acheck', 'en'); // <- Add a comma separated list of all supported languages
\r
5 var TinyMCE_ACheckPlugin = {
\r
6 getInfo : function() {
\r
10 authorurl : 'http://www.atutor.ca',
\r
11 infourl : 'http://www.atutor.ca',
\r
17 * Gets executed when a TinyMCE editor instance is initialized.
\r
19 * @param {TinyMCE_Control} Initialized TinyMCE editor control instance.
\r
21 initInstance : function(inst) {
\r
22 // You can take out plugin specific parameters
\r
23 //alert("Initialization parameter:" + tinyMCE.getParam("somename_someparam", false));
\r
25 // Register custom keyboard shortcut
\r
26 //inst.addShortcut('ctrl', 't', 'lang_somename_desc', 'mceSomeCommand');
\r
30 * Returns the HTML code for a specific control or empty string if this plugin doesn't have that control.
\r
31 * A control can be a button, select list or any other HTML item to present in the TinyMCE user interface.
\r
32 * The variable {$editor_id} will be replaced with the current editor instance id and {$pluginurl} will be replaced
\r
33 * with the URL of the plugin. Language variables such as {$lang_somekey} will also be replaced with contents from
\r
34 * the language packs.
\r
36 * @param {string} cn Editor control/button name to get HTML for.
\r
37 * @return HTML code for a specific control or empty string.
\r
40 getControlHTML : function(cn) {
\r
43 return tinyMCE.getButtonHTML(cn, 'lang_acheck_button_desc', '{$pluginurl}/images/acheck.gif', 'mceACheck');
\r
51 * Executes a specific command, this function handles plugin commands.
\r
53 * @param {string} editor_id TinyMCE editor instance id that issued the command.
\r
54 * @param {HTMLElement} element Body or root element for the editor instance.
\r
55 * @param {string} command Command name to be executed.
\r
56 * @param {string} user_interface True/false if a user interface should be presented.
\r
57 * @param {mixed} value Custom value argument, can be anything.
\r
58 * @return true/false if the command was executed by this plugin or not.
\r
61 execCommand : function(editor_id, element, command, user_interface, value) {
\r
65 var formObj = tinyMCE.selectedInstance.formElement.form;
\r
68 tinyMCE.triggerSave();
\r
70 // Disable all UI form elements that TinyMCE created
\r
71 for (var i=0; i<formObj.elements.length; i++) {
\r
72 var elementId = formObj.elements[i].name ? formObj.elements[i].name : formObj.elements[i].id;
\r
74 if (elementId.indexOf('mce_editor_') == 0)
\r
75 formObj.elements[i].disabled = true;
\r
78 // calls the JavaScript function
\r
79 //Acheck_newWindowWithCode();
\r
80 //alert('checking');
\r
82 var accessWin = null;
\r
86 var nodeList = document.getElementsByTagName("textarea");
\r
87 var elm = nodeList.item(0);
\r
91 var theCode = '<html><body onLoad="document.accessform.submit();"> \n';
\r
92 theCode += '<h1>Submitting Code for Accessibility Checking.....</h1>\n';
\r
93 theCode += '<form action="http://checker.atrc.utoronto.ca/servlet/Checkacc" name="accessform" method="post"> \n';
\r
94 theCode += '<input type="hidden" name="guide" value="wcag-2-0-aaa.xml" /> \n';
\r
95 theCode += '<input type="hidden" name="type" value="form" /> \n';
\r
96 theCode += '<textarea name="edittext">' + theVal + '</textarea>\n';
\r
97 theCode += '<input type="submit" /></form> \n';
\r
98 theCode += '</body></html> \n';
\r
99 accessWin = window.open('', 'accessWin', '');
\r
100 accessWin.document.writeln(theCode);
\r
101 accessWin.document.close();
\r
103 alert("Error: No form element found.");
\r
108 // Pass to next handler in chain
\r
113 * Gets called ones the cursor/selection in a TinyMCE instance changes. This is useful to enable/disable
\r
114 * button controls depending on where the user are and what they have selected. This method gets executed
\r
115 * alot and should be as performance tuned as possible.
\r
117 * @param {string} editor_id TinyMCE editor instance id that was changed.
\r
118 * @param {HTMLNode} node Current node location, where the cursor is in the DOM tree.
\r
119 * @param {int} undo_index The current undo index, if this is -1 custom undo/redo is disabled.
\r
120 * @param {int} undo_levels The current undo levels, if this is -1 custom undo/redo is disabled.
\r
121 * @param {boolean} visual_aid Is visual aids enabled/disabled ex: dotted lines on tables.
\r
122 * @param {boolean} any_selection Is there any selection at all or is there only a cursor.
\r
124 handleNodeChange : function(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) {
\r
128 * Gets called when a TinyMCE editor instance gets filled with content on startup.
\r
130 * @param {string} editor_id TinyMCE editor instance id that was filled with content.
\r
131 * @param {HTMLElement} body HTML body element of editor instance.
\r
132 * @param {HTMLDocument} doc HTML document instance.
\r
134 setupContent : function(editor_id, body, doc) {
\r
138 * Gets called when the contents of a TinyMCE area is modified, in other words when a undo level is
\r
141 * @param {TinyMCE_Control} inst TinyMCE editor area control instance that got modified.
\r
143 onChange : function(inst) {
\r
147 * Gets called when TinyMCE handles events such as keydown, mousedown etc. TinyMCE
\r
148 * doesn't listen on all types of events so custom event handling may be required for
\r
151 * @param {Event} e HTML editor event reference.
\r
152 * @return true - pass to next handler in chain, false - stop chain execution
\r
155 handleEvent : function(e) {
\r
160 * Gets called when HTML contents is inserted or retrived from a TinyMCE editor instance.
\r
161 * The type parameter contains what type of event that was performed and what format the content is in.
\r
162 * Possible valuses for type is get_from_editor, insert_to_editor, get_from_editor_dom, insert_to_editor_dom.
\r
164 * @param {string} type Cleanup event type.
\r
165 * @param {mixed} content Editor contents that gets inserted/extracted can be a string or DOM element.
\r
166 * @param {TinyMCE_Control} inst TinyMCE editor instance control that performes the cleanup.
\r
167 * @return New content or the input content depending on action.
\r
170 cleanup : function(type, content, inst) {
\r
174 // Private plugin internal methods
\r
177 * This is just a internal plugin method, prefix all internal methods with a _ character.
\r
178 * The prefix is needed so they doesn't collide with future TinyMCE callback functions.
\r
180 * @param {string} a Some arg1.
\r
181 * @param {string} b Some arg2.
\r
182 * @return Some return.
\r
185 _someInternalFunction : function(a, b) {
\r
191 tinyMCE.addPlugin("acheck", TinyMCE_ACheckPlugin);