--- /dev/null
+/**\r
+ * $Id: editor_plugin_src.js 42 2006-08-08 14:32:24Z spocke $\r
+ *\r
+ * @author Moxiecode\r
+ * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.\r
+ */\r
+\r
+/* Import plugin specific language pack */\r
+tinyMCE.importPluginLanguagePack('visualchars');\r
+\r
+var TinyMCE_VisualCharsPlugin = {\r
+ getInfo : function() {\r
+ return {\r
+ longname : 'Visual characters',\r
+ author : 'Moxiecode Systems AB',\r
+ authorurl : 'http://tinymce.moxiecode.com',\r
+ infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/visualchars',\r
+ version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion\r
+ };\r
+ },\r
+\r
+ initInstance : function(inst) {\r
+ inst.visualChars = {\r
+ state : false\r
+ };\r
+ },\r
+\r
+ getControlHTML : function(cn) {\r
+ switch (cn) {\r
+ case "visualchars":\r
+ return tinyMCE.getButtonHTML(cn, 'lang_visualchars_desc', '{$pluginurl}/images/visualchars.gif', 'mceVisualChars', false);\r
+ }\r
+\r
+ return "";\r
+ },\r
+\r
+ execCommand : function(editor_id, element, command, user_interface, value) {\r
+ var inst = tinyMCE.getInstanceById(editor_id);\r
+\r
+ switch (command) {\r
+ case "mceVisualChars":\r
+ this._toggleVisualChars(editor_id, inst);\r
+ return true;\r
+ }\r
+\r
+ return false;\r
+ },\r
+\r
+ cleanup : function(type, content, inst) {\r
+ if (type == "insert_to_editor_dom" || type == "get_from_editor_dom") {\r
+ inst.visualChars.state = true;\r
+ this._toggleVisualChars(inst.editorId, inst);\r
+ }\r
+\r
+ return content;\r
+ },\r
+\r
+ // Private plugin internal methods\r
+\r
+ _toggleVisualChars : function(editor_id, inst) {\r
+ var nl, i, h, d = inst.getDoc(), b = inst.getBody(), nv, s = inst.selection, bo;\r
+\r
+ inst.visualChars.state = !inst.visualChars.state;\r
+\r
+ bo = s.getBookmark(true);\r
+\r
+ tinyMCE.switchClass(editor_id + '_visualchars', inst.visualChars.state ? 'mceButtonSelected' : 'mceButtonNormal');\r
+\r
+ if (inst.visualChars.state) {\r
+ nl = tinyMCE.selectNodes(b, function(n) {return n.nodeType == 3 && n.nodeValue && n.nodeValue.indexOf('\u00a0') != -1;});\r
+\r
+ for (i=0; i<nl.length; i++) {\r
+ nv = nl[i].nodeValue;\r
+ nv = nv.replace(/(\u00a0+)/g, '<span class="mceItemHiddenVisualChar">$1</span>');\r
+ nv = nv.replace(/\u00a0/g, '\u00b7');\r
+ tinyMCE.setOuterHTML(nl[i], nv, d);\r
+ }\r
+ } else {\r
+ nl = tinyMCE.selectNodes(b, function(n) {return n.nodeType == 1 && n.nodeName == 'SPAN' && n.className == 'mceItemHiddenVisualChar';});\r
+\r
+ for (i=0; i<nl.length; i++)\r
+ tinyMCE.setOuterHTML(nl[i], nl[i].innerHTML.replace(/(·|\u00b7)/g, ' '), d);\r
+ }\r
+\r
+ //s.moveToBookmark(bo);\r
+ }\r
+};\r
+\r
+tinyMCE.addPlugin("visualchars", TinyMCE_VisualCharsPlugin);\r