bgneal@312: /** bgneal@312: * editor_plugin_src.js bgneal@312: * bgneal@312: * Copyright 2009, Moxiecode Systems AB bgneal@312: * Released under LGPL License. bgneal@312: * bgneal@312: * License: http://tinymce.moxiecode.com/license bgneal@312: * Contributing: http://tinymce.moxiecode.com/contributing bgneal@312: */ bgneal@312: bgneal@312: (function() { bgneal@312: tinymce.create('tinymce.plugins.Directionality', { bgneal@312: init : function(ed, url) { bgneal@312: var t = this; bgneal@312: bgneal@312: t.editor = ed; bgneal@312: bgneal@312: ed.addCommand('mceDirectionLTR', function() { bgneal@312: var e = ed.dom.getParent(ed.selection.getNode(), ed.dom.isBlock); bgneal@312: bgneal@312: if (e) { bgneal@312: if (ed.dom.getAttrib(e, "dir") != "ltr") bgneal@312: ed.dom.setAttrib(e, "dir", "ltr"); bgneal@312: else bgneal@312: ed.dom.setAttrib(e, "dir", ""); bgneal@312: } bgneal@312: bgneal@312: ed.nodeChanged(); bgneal@312: }); bgneal@312: bgneal@312: ed.addCommand('mceDirectionRTL', function() { bgneal@312: var e = ed.dom.getParent(ed.selection.getNode(), ed.dom.isBlock); bgneal@312: bgneal@312: if (e) { bgneal@312: if (ed.dom.getAttrib(e, "dir") != "rtl") bgneal@312: ed.dom.setAttrib(e, "dir", "rtl"); bgneal@312: else bgneal@312: ed.dom.setAttrib(e, "dir", ""); bgneal@312: } bgneal@312: bgneal@312: ed.nodeChanged(); bgneal@312: }); bgneal@312: bgneal@312: ed.addButton('ltr', {title : 'directionality.ltr_desc', cmd : 'mceDirectionLTR'}); bgneal@312: ed.addButton('rtl', {title : 'directionality.rtl_desc', cmd : 'mceDirectionRTL'}); bgneal@312: bgneal@312: ed.onNodeChange.add(t._nodeChange, t); bgneal@312: }, bgneal@312: bgneal@312: getInfo : function() { bgneal@312: return { bgneal@312: longname : 'Directionality', bgneal@312: author : 'Moxiecode Systems AB', bgneal@312: authorurl : 'http://tinymce.moxiecode.com', bgneal@312: infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/directionality', bgneal@312: version : tinymce.majorVersion + "." + tinymce.minorVersion bgneal@312: }; bgneal@312: }, bgneal@312: bgneal@312: // Private methods bgneal@312: bgneal@312: _nodeChange : function(ed, cm, n) { bgneal@312: var dom = ed.dom, dir; bgneal@312: bgneal@312: n = dom.getParent(n, dom.isBlock); bgneal@312: if (!n) { bgneal@312: cm.setDisabled('ltr', 1); bgneal@312: cm.setDisabled('rtl', 1); bgneal@312: return; bgneal@312: } bgneal@312: bgneal@312: dir = dom.getAttrib(n, 'dir'); bgneal@312: cm.setActive('ltr', dir == "ltr"); bgneal@312: cm.setDisabled('ltr', 0); bgneal@312: cm.setActive('rtl', dir == "rtl"); bgneal@312: cm.setDisabled('rtl', 0); bgneal@312: } bgneal@312: }); bgneal@312: bgneal@312: // Register plugin bgneal@312: tinymce.PluginManager.add('directionality', tinymce.plugins.Directionality); bgneal@312: })();