root / trunk / web / dojo / dijit / _editor / plugins / ToggleDir.js
History | View | Annotate | Download (1.4 KB)
1 |
/*
|
---|---|
2 |
Copyright (c) 2004-2010, 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
|
5 |
*/
|
6 |
|
7 |
|
8 |
if(!dojo._hasResource["dijit._editor.plugins.ToggleDir"]){ |
9 |
dojo._hasResource["dijit._editor.plugins.ToggleDir"]=true; |
10 |
dojo.provide("dijit._editor.plugins.ToggleDir");
|
11 |
dojo.experimental("dijit._editor.plugins.ToggleDir");
|
12 |
dojo.require("dijit._editor._Plugin");
|
13 |
dojo.require("dijit.form.ToggleButton");
|
14 |
dojo.declare("dijit._editor.plugins.ToggleDir",dijit._editor._Plugin,{useDefaultCommand:false,command:"toggleDir",buttonClass:dijit.form.ToggleButton,_initButton:function(){ |
15 |
this.inherited(arguments); |
16 |
this.editor.onLoadDeferred.addCallback(dojo.hitch(this,function(){ |
17 |
var _1=this.editor.editorObject.contentWindow.document.documentElement; |
18 |
_1=_1.getElementsByTagName("body")[0]; |
19 |
var _2=dojo.getComputedStyle(_1).direction=="ltr"; |
20 |
this.button.set("checked",!_2); |
21 |
this.connect(this.button,"onChange","_setRtl"); |
22 |
})); |
23 |
},updateState:function(){ |
24 |
},_setRtl:function(_3){ |
25 |
var _4="ltr"; |
26 |
if(_3){
|
27 |
_4="rtl";
|
28 |
} |
29 |
var _5=this.editor.editorObject.contentWindow.document.documentElement; |
30 |
_5=_5.getElementsByTagName("body")[0]; |
31 |
_5.dir=_4; |
32 |
}}); |
33 |
dojo.subscribe(dijit._scopeName+".Editor.getPlugin",null,function(o){ |
34 |
if(o.plugin){
|
35 |
return;
|
36 |
} |
37 |
switch(o.args.name){
|
38 |
case "toggleDir": |
39 |
o.plugin=new dijit._editor.plugins.ToggleDir({command:o.args.name}); |
40 |
} |
41 |
}); |
42 |
} |