annotate media/js/tiny_mce/plugins/directionality/editor_plugin_src.js @ 106:cb72577785df

Forums: implemented the edit post function.
author Brian Neal <bgneal@gmail.com>
date Sat, 19 Sep 2009 21:49:56 +0000
parents a5b4c5ce0658
children 149c3567fec1
rev   line source
bgneal@45 1 /**
bgneal@45 2 * $Id: editor_plugin_src.js 520 2008-01-07 16:30:32Z spocke $
bgneal@45 3 *
bgneal@45 4 * @author Moxiecode
bgneal@45 5 * @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved.
bgneal@45 6 */
bgneal@45 7
bgneal@45 8 (function() {
bgneal@45 9 tinymce.create('tinymce.plugins.Directionality', {
bgneal@45 10 init : function(ed, url) {
bgneal@45 11 var t = this;
bgneal@45 12
bgneal@45 13 t.editor = ed;
bgneal@45 14
bgneal@45 15 ed.addCommand('mceDirectionLTR', function() {
bgneal@45 16 var e = ed.dom.getParent(ed.selection.getNode(), ed.dom.isBlock);
bgneal@45 17
bgneal@45 18 if (e) {
bgneal@45 19 if (ed.dom.getAttrib(e, "dir") != "ltr")
bgneal@45 20 ed.dom.setAttrib(e, "dir", "ltr");
bgneal@45 21 else
bgneal@45 22 ed.dom.setAttrib(e, "dir", "");
bgneal@45 23 }
bgneal@45 24
bgneal@45 25 ed.nodeChanged();
bgneal@45 26 });
bgneal@45 27
bgneal@45 28 ed.addCommand('mceDirectionRTL', function() {
bgneal@45 29 var e = ed.dom.getParent(ed.selection.getNode(), ed.dom.isBlock);
bgneal@45 30
bgneal@45 31 if (e) {
bgneal@45 32 if (ed.dom.getAttrib(e, "dir") != "rtl")
bgneal@45 33 ed.dom.setAttrib(e, "dir", "rtl");
bgneal@45 34 else
bgneal@45 35 ed.dom.setAttrib(e, "dir", "");
bgneal@45 36 }
bgneal@45 37
bgneal@45 38 ed.nodeChanged();
bgneal@45 39 });
bgneal@45 40
bgneal@45 41 ed.addButton('ltr', {title : 'directionality.ltr_desc', cmd : 'mceDirectionLTR'});
bgneal@45 42 ed.addButton('rtl', {title : 'directionality.rtl_desc', cmd : 'mceDirectionRTL'});
bgneal@45 43
bgneal@45 44 ed.onNodeChange.add(t._nodeChange, t);
bgneal@45 45 },
bgneal@45 46
bgneal@45 47 getInfo : function() {
bgneal@45 48 return {
bgneal@45 49 longname : 'Directionality',
bgneal@45 50 author : 'Moxiecode Systems AB',
bgneal@45 51 authorurl : 'http://tinymce.moxiecode.com',
bgneal@45 52 infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/directionality',
bgneal@45 53 version : tinymce.majorVersion + "." + tinymce.minorVersion
bgneal@45 54 };
bgneal@45 55 },
bgneal@45 56
bgneal@45 57 // Private methods
bgneal@45 58
bgneal@45 59 _nodeChange : function(ed, cm, n) {
bgneal@45 60 var dom = ed.dom, dir;
bgneal@45 61
bgneal@45 62 n = dom.getParent(n, dom.isBlock);
bgneal@45 63 if (!n) {
bgneal@45 64 cm.setDisabled('ltr', 1);
bgneal@45 65 cm.setDisabled('rtl', 1);
bgneal@45 66 return;
bgneal@45 67 }
bgneal@45 68
bgneal@45 69 dir = dom.getAttrib(n, 'dir');
bgneal@45 70 cm.setActive('ltr', dir == "ltr");
bgneal@45 71 cm.setDisabled('ltr', 0);
bgneal@45 72 cm.setActive('rtl', dir == "rtl");
bgneal@45 73 cm.setDisabled('rtl', 0);
bgneal@45 74 }
bgneal@45 75 });
bgneal@45 76
bgneal@45 77 // Register plugin
bgneal@45 78 tinymce.PluginManager.add('directionality', tinymce.plugins.Directionality);
bgneal@45 79 })();