-/* Import plugin specific language pack */\r
-tinyMCE.importPluginLanguagePack('directionality', 'en,sv,fr_ca,zh_cn,cs,da,he,nb,de,hu,ru,ru_KOI8-R,ru_UTF-8,nn,es,cy,is,pl,nl,fr,pt_br');\r
-\r
-function TinyMCE_directionality_getInfo() {\r
- return {\r
- longname : 'Directionality',\r
- author : 'Moxiecode Systems',\r
- authorurl : 'http://tinymce.moxiecode.com',\r
- infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_directionality.html',\r
- version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion\r
- };\r
-};\r
-\r
-function TinyMCE_directionality_getControlHTML(control_name) {\r
- switch (control_name) {\r
- case "ltr":\r
- var cmd = 'tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceDirectionLTR\');return false;';\r
- return '<a href="javascript:' + cmd + '" onclick="' + cmd + '" target="_self" onmousedown="return false;"><img id="{$editor_id}_ltr" src="{$pluginurl}/images/ltr.gif" title="{$lang_directionality_ltr_desc}" width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');" /></a>';\r
-\r
- case "rtl":\r
- var cmd = 'tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceDirectionRTL\');return false;';\r
- return '<a href="javascript:' + cmd + '" onclick="' + cmd + '" target="_self" onmousedown="return false;"><img id="{$editor_id}_rtl" src="{$pluginurl}/images/rtl.gif" title="{$lang_directionality_rtl_desc}" width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');" /></a>';\r
- }\r
-\r
- return "";\r
-}\r
-\r
-function TinyMCE_directionality_execCommand(editor_id, element, command, user_interface, value) {\r
- // Handle commands\r
- switch (command) {\r
- case "mceDirectionLTR":\r
- var inst = tinyMCE.getInstanceById(editor_id);\r
- var elm = tinyMCE.getParentElement(inst.getFocusElement(), "p,div,td,h1,h2,h3,h4,h5,h6,pre,address");\r
-\r
- if (elm)\r
- elm.setAttribute("dir", "ltr");\r
-\r
- tinyMCE.triggerNodeChange(false);\r
- return true;\r
-\r
- case "mceDirectionRTL":\r
- var inst = tinyMCE.getInstanceById(editor_id);\r
- var elm = tinyMCE.getParentElement(inst.getFocusElement(), "p,div,td,h1,h2,h3,h4,h5,h6,pre,address");\r
-\r
- if (elm)\r
- elm.setAttribute("dir", "rtl");\r
-\r
- tinyMCE.triggerNodeChange(false);\r
- return true;\r
- }\r
-\r
- // Pass to next handler in chain\r
- return false;\r
-}\r
-\r
-function TinyMCE_directionality_handleNodeChange(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) {\r
- function getAttrib(elm, name) {\r
- return elm.getAttribute(name) ? elm.getAttribute(name) : "";\r
- }\r
-\r
- tinyMCE.switchClassSticky(editor_id + '_ltr', 'mceButtonNormal', false);\r
- tinyMCE.switchClassSticky(editor_id + '_rtl', 'mceButtonNormal', false);\r
-\r
- if (node == null)\r
- return;\r
-\r
- var elm = tinyMCE.getParentElement(node, "p,div,td,h1,h2,h3,h4,h5,h6,pre,address");\r
- if (!elm) {\r
- tinyMCE.switchClassSticky(editor_id + '_ltr', 'mceButtonDisabled', true);\r
- tinyMCE.switchClassSticky(editor_id + '_rtl', 'mceButtonDisabled', true);\r
- return;\r
- }\r
-\r
- var dir = getAttrib(elm, "dir");\r
- if (dir == "ltr" || dir == "")\r
- tinyMCE.switchClassSticky(editor_id + '_ltr', 'mceButtonSelected', false);\r
- else\r
- tinyMCE.switchClassSticky(editor_id + '_rtl', 'mceButtonSelected', false);\r
-\r
- return true;\r
-}\r
+/**\r
+ * editor_plugin_src.js\r
+ *\r
+ * Copyright 2009, Moxiecode Systems AB\r
+ * Released under LGPL License.\r
+ *\r
+ * License: http://tinymce.moxiecode.com/license\r
+ * Contributing: http://tinymce.moxiecode.com/contributing\r
+ */\r
+\r
+(function() {\r
+ tinymce.create('tinymce.plugins.Directionality', {\r
+ init : function(ed, url) {\r
+ var t = this;\r
+\r
+ t.editor = ed;\r
+\r
+ ed.addCommand('mceDirectionLTR', function() {\r
+ var e = ed.dom.getParent(ed.selection.getNode(), ed.dom.isBlock);\r
+\r
+ if (e) {\r
+ if (ed.dom.getAttrib(e, "dir") != "ltr")\r
+ ed.dom.setAttrib(e, "dir", "ltr");\r
+ else\r
+ ed.dom.setAttrib(e, "dir", "");\r
+ }\r
+\r
+ ed.nodeChanged();\r
+ });\r
+\r
+ ed.addCommand('mceDirectionRTL', function() {\r
+ var e = ed.dom.getParent(ed.selection.getNode(), ed.dom.isBlock);\r
+\r
+ if (e) {\r
+ if (ed.dom.getAttrib(e, "dir") != "rtl")\r
+ ed.dom.setAttrib(e, "dir", "rtl");\r
+ else\r
+ ed.dom.setAttrib(e, "dir", "");\r
+ }\r
+\r
+ ed.nodeChanged();\r
+ });\r
+\r
+ ed.addButton('ltr', {title : 'directionality.ltr_desc', cmd : 'mceDirectionLTR'});\r
+ ed.addButton('rtl', {title : 'directionality.rtl_desc', cmd : 'mceDirectionRTL'});\r
+\r
+ ed.onNodeChange.add(t._nodeChange, t);\r
+ },\r
+\r
+ getInfo : function() {\r
+ return {\r
+ longname : 'Directionality',\r
+ author : 'Moxiecode Systems AB',\r
+ authorurl : 'http://tinymce.moxiecode.com',\r
+ infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/directionality',\r
+ version : tinymce.majorVersion + "." + tinymce.minorVersion\r
+ };\r
+ },\r
+\r
+ // Private methods\r
+\r
+ _nodeChange : function(ed, cm, n) {\r
+ var dom = ed.dom, dir;\r
+\r
+ n = dom.getParent(n, dom.isBlock);\r
+ if (!n) {\r
+ cm.setDisabled('ltr', 1);\r
+ cm.setDisabled('rtl', 1);\r
+ return;\r
+ }\r
+\r
+ dir = dom.getAttrib(n, 'dir');\r
+ cm.setActive('ltr', dir == "ltr");\r
+ cm.setDisabled('ltr', 0);\r
+ cm.setActive('rtl', dir == "rtl");\r
+ cm.setDisabled('rtl', 0);\r
+ }\r
+ });\r
+\r
+ // Register plugin\r
+ tinymce.PluginManager.add('directionality', tinymce.plugins.Directionality);\r
+})();
\ No newline at end of file