bgneal@45: /** bgneal@45: * $Id: editor_plugin_src.js 520 2008-01-07 16:30:32Z spocke $ bgneal@45: * bgneal@45: * @author Moxiecode bgneal@45: * @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved. bgneal@45: */ bgneal@45: bgneal@45: (function() { bgneal@45: tinymce.create('tinymce.plugins.Directionality', { bgneal@45: init : function(ed, url) { bgneal@45: var t = this; bgneal@45: bgneal@45: t.editor = ed; bgneal@45: bgneal@45: ed.addCommand('mceDirectionLTR', function() { bgneal@45: var e = ed.dom.getParent(ed.selection.getNode(), ed.dom.isBlock); bgneal@45: bgneal@45: if (e) { bgneal@45: if (ed.dom.getAttrib(e, "dir") != "ltr") bgneal@45: ed.dom.setAttrib(e, "dir", "ltr"); bgneal@45: else bgneal@45: ed.dom.setAttrib(e, "dir", ""); bgneal@45: } bgneal@45: bgneal@45: ed.nodeChanged(); bgneal@45: }); bgneal@45: bgneal@45: ed.addCommand('mceDirectionRTL', function() { bgneal@45: var e = ed.dom.getParent(ed.selection.getNode(), ed.dom.isBlock); bgneal@45: bgneal@45: if (e) { bgneal@45: if (ed.dom.getAttrib(e, "dir") != "rtl") bgneal@45: ed.dom.setAttrib(e, "dir", "rtl"); bgneal@45: else bgneal@45: ed.dom.setAttrib(e, "dir", ""); bgneal@45: } bgneal@45: bgneal@45: ed.nodeChanged(); bgneal@45: }); bgneal@45: bgneal@45: ed.addButton('ltr', {title : 'directionality.ltr_desc', cmd : 'mceDirectionLTR'}); bgneal@45: ed.addButton('rtl', {title : 'directionality.rtl_desc', cmd : 'mceDirectionRTL'}); bgneal@45: bgneal@45: ed.onNodeChange.add(t._nodeChange, t); bgneal@45: }, bgneal@45: bgneal@45: getInfo : function() { bgneal@45: return { bgneal@45: longname : 'Directionality', bgneal@45: author : 'Moxiecode Systems AB', bgneal@45: authorurl : 'http://tinymce.moxiecode.com', bgneal@45: infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/directionality', bgneal@45: version : tinymce.majorVersion + "." + tinymce.minorVersion bgneal@45: }; bgneal@45: }, bgneal@45: bgneal@45: // Private methods bgneal@45: bgneal@45: _nodeChange : function(ed, cm, n) { bgneal@45: var dom = ed.dom, dir; bgneal@45: bgneal@45: n = dom.getParent(n, dom.isBlock); bgneal@45: if (!n) { bgneal@45: cm.setDisabled('ltr', 1); bgneal@45: cm.setDisabled('rtl', 1); bgneal@45: return; bgneal@45: } bgneal@45: bgneal@45: dir = dom.getAttrib(n, 'dir'); bgneal@45: cm.setActive('ltr', dir == "ltr"); bgneal@45: cm.setDisabled('ltr', 0); bgneal@45: cm.setActive('rtl', dir == "rtl"); bgneal@45: cm.setDisabled('rtl', 0); bgneal@45: } bgneal@45: }); bgneal@45: bgneal@45: // Register plugin bgneal@45: tinymce.PluginManager.add('directionality', tinymce.plugins.Directionality); bgneal@45: })();