comparison media/js/tiny_mce/plugins/directionality/editor_plugin_src.js @ 45:a5b4c5ce0658

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