annotate WebContent/jscripts/tiny_mce/plugins/directionality/editor_plugin_src.js @ 5:0be9d53a6967

editor for annotations
author dwinter
date Tue, 13 Dec 2011 17:43:46 +0100
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1 /**
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2 * editor_plugin_src.js
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3 *
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4 * Copyright 2009, Moxiecode Systems AB
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5 * Released under LGPL License.
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6 *
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
7 * License: http://tinymce.moxiecode.com/license
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
8 * Contributing: http://tinymce.moxiecode.com/contributing
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
9 */
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
10
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
11 (function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
12 tinymce.create('tinymce.plugins.Directionality', {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
13 init : function(ed, url) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
14 var t = this;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
15
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
16 t.editor = ed;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
17
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
18 ed.addCommand('mceDirectionLTR', function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
19 var e = ed.dom.getParent(ed.selection.getNode(), ed.dom.isBlock);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
20
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
21 if (e) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
22 if (ed.dom.getAttrib(e, "dir") != "ltr")
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
23 ed.dom.setAttrib(e, "dir", "ltr");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
24 else
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
25 ed.dom.setAttrib(e, "dir", "");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
26 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
27
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
28 ed.nodeChanged();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
29 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
30
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
31 ed.addCommand('mceDirectionRTL', function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
32 var e = ed.dom.getParent(ed.selection.getNode(), ed.dom.isBlock);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
33
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
34 if (e) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
35 if (ed.dom.getAttrib(e, "dir") != "rtl")
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
36 ed.dom.setAttrib(e, "dir", "rtl");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
37 else
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
38 ed.dom.setAttrib(e, "dir", "");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
39 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
40
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
41 ed.nodeChanged();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
42 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
43
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
44 ed.addButton('ltr', {title : 'directionality.ltr_desc', cmd : 'mceDirectionLTR'});
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
45 ed.addButton('rtl', {title : 'directionality.rtl_desc', cmd : 'mceDirectionRTL'});
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
46
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
47 ed.onNodeChange.add(t._nodeChange, t);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
48 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
49
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
50 getInfo : function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
51 return {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
52 longname : 'Directionality',
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
53 author : 'Moxiecode Systems AB',
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
54 authorurl : 'http://tinymce.moxiecode.com',
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
55 infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/directionality',
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
56 version : tinymce.majorVersion + "." + tinymce.minorVersion
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
57 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
58 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
59
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
60 // Private methods
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
61
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
62 _nodeChange : function(ed, cm, n) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
63 var dom = ed.dom, dir;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
64
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
65 n = dom.getParent(n, dom.isBlock);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
66 if (!n) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
67 cm.setDisabled('ltr', 1);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
68 cm.setDisabled('rtl', 1);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
69 return;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
70 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
71
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
72 dir = dom.getAttrib(n, 'dir');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
73 cm.setActive('ltr', dir == "ltr");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
74 cm.setDisabled('ltr', 0);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
75 cm.setActive('rtl', dir == "rtl");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
76 cm.setDisabled('rtl', 0);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
77 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
78 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
79
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
80 // Register plugin
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
81 tinymce.PluginManager.add('directionality', tinymce.plugins.Directionality);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
82 })();