]>
git.wh0rd.org - tt-rss.git/blob - lib/dijit/_BidiSupport.js.uncompressed.js
1 define("dijit/_BidiSupport", ["./_WidgetBase"], function(_WidgetBase
){
4 var _WidgetBase = dijit._WidgetBase;
10 // Module that deals with BIDI, special with the auto
11 // direction if needed without changing the GUI direction.
12 // Including this module will extend _WidgetBase with BIDI related methods.
14 // There's a special need for displaying BIDI text in rtl direction
15 // in ltr GUI, sometimes needed auto support.
16 // In creation of widget, if it's want to activate this class,
17 // the widget should define the "textDir".
21 getTextDir: function(/*String*/ text
){
23 // Gets the right direction of text.
25 // If textDir is ltr or rtl returns the value.
26 // If it's auto, calls to another function that responsible
27 // for checking the value, and defining the direction.
30 return this.textDir
== "auto" ? this._checkContextual(text
) : this.textDir
;
33 _checkContextual: function(text
){
35 // Finds the first strong (directional) character, return ltr if isLatin
36 // or rtl if isBidiChar.
40 // look for strong (directional) characters
41 var fdc
= /[A-Za-z\u05d0-\u065f\u066a-\u06ef\u06fa-\u07ff\ufb1d-\ufdff\ufe70-\ufefc]/.exec(text
);
42 // if found return the direction that defined by the character, else return widgets dir as defult.
43 return fdc
? ( fdc
[0] <= 'z' ? "ltr" : "rtl" ) : this.dir
? this.dir
: this.isLeftToRight() ? "ltr" : "rtl";
46 applyTextDir: function(/*Object*/ element
, /*String*/ text
){
48 // Set element.dir according to this.textDir
50 // The text element to be set. Should have dir property.
52 // Used in case this.textDir is "auto", for calculating the right transformation
54 // If textDir is ltr or rtl returns the value.
55 // If it's auto, calls to another function that responsible
56 // for checking the value, and defining the direction.
60 var textDir
= this.textDir
== "auto" ? this._checkContextual(text
) : this.textDir
;
61 // update only when there's a difference
62 if(element
.dir
!= textDir
){
63 element
.dir
= textDir
;