]>
git.wh0rd.org - tt-rss.git/blob - lib/dijit/_editor/plugins/ToggleDir.js
2 Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
3 Available via Academic Free License >= 2.1 OR the modified BSD license.
4 see: http://dojotoolkit.org/license for details
8 if(!dojo
._hasResource
["dijit._editor.plugins.ToggleDir"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
9 dojo
._hasResource
["dijit._editor.plugins.ToggleDir"] = true;
10 dojo
.provide("dijit._editor.plugins.ToggleDir");
11 dojo
.require("dijit._editor._Plugin");
12 dojo
.require("dijit.form.ToggleButton");
15 dojo
.experimental("dijit._editor.plugins.ToggleDir");
17 dojo
.require("dijit._editor._Plugin");
18 dojo
.require("dijit.form.ToggleButton");
20 dojo
.declare("dijit._editor.plugins.ToggleDir",
21 dijit
._editor
._Plugin
,
24 // This plugin is used to toggle direction of the edited document,
25 // independent of what direction the whole page is.
27 // Override _Plugin.useDefaultCommand: processing is done in this plugin
28 // rather than by sending commands to the Editor
29 useDefaultCommand
: false,
33 // Override _Plugin.buttonClass to use a ToggleButton for this plugin rather than a vanilla Button
34 buttonClass
: dijit
.form
.ToggleButton
,
36 _initButton: function(){
37 // Override _Plugin._initButton() to setup handler for button click events.
38 this.inherited(arguments
);
39 this.editor
.onLoadDeferred
.addCallback(dojo
.hitch(this, function(){
40 var editDoc
= this.editor
.editorObject
.contentWindow
.document
.documentElement
;
41 //IE direction has to toggle on the body, not document itself.
42 //If you toggle just the document, things get very strange in the
43 //view. But, the nice thing is this works for all supported browsers.
44 editDoc
= editDoc
.getElementsByTagName("body")[0];
45 var isLtr
= dojo
.getComputedStyle(editDoc
).direction
== "ltr";
46 this.button
.set("checked", !isLtr
);
47 this.connect(this.button
, "onChange", "_setRtl");
51 updateState: function(){
53 // Over-ride for button state control for disabled to work.
54 this.button
.set("disabled", this.get("disabled"));
57 _setRtl: function(rtl
){
59 // Handler for button click events, to switch the text direction of the editor
64 var editDoc
= this.editor
.editorObject
.contentWindow
.document
.documentElement
;
65 editDoc
= editDoc
.getElementsByTagName("body")[0];
66 editDoc
.dir
/*html node*/ = dir
;
71 // Register this plugin.
72 dojo
.subscribe(dijit
._scopeName
+ ".Editor.getPlugin",null,function(o
){
73 if(o
.plugin
){ return; }
76 o
.plugin
= new dijit
._editor
.plugins
.ToggleDir({command
: o
.args
.name
});