diff options
author | Andrew Dolgov <[email protected]> | 2012-08-14 18:59:10 +0400 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2012-08-14 18:59:18 +0400 |
commit | 1354d17270961fff662d40f90521223f8fd0d73b (patch) | |
tree | e9266be71587e47c800303446e968a6d3565e2cf /lib/dijit/_BidiSupport.js.uncompressed.js | |
parent | d04f8c826f5283765f52cf6b98b42a1ed8f2d6bc (diff) |
update dojo to 1.7.3
Diffstat (limited to 'lib/dijit/_BidiSupport.js.uncompressed.js')
-rw-r--r-- | lib/dijit/_BidiSupport.js.uncompressed.js | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/lib/dijit/_BidiSupport.js.uncompressed.js b/lib/dijit/_BidiSupport.js.uncompressed.js new file mode 100644 index 000000000..ef43a158c --- /dev/null +++ b/lib/dijit/_BidiSupport.js.uncompressed.js @@ -0,0 +1,69 @@ +define("dijit/_BidiSupport", ["./_WidgetBase"], function(_WidgetBase){ + +/*===== + var _WidgetBase = dijit._WidgetBase; +====*/ + + // module: + // dijit/_BidiSupport + // summary: + // Module that deals with BIDI, special with the auto + // direction if needed without changing the GUI direction. + // Including this module will extend _WidgetBase with BIDI related methods. + // description: + // There's a special need for displaying BIDI text in rtl direction + // in ltr GUI, sometimes needed auto support. + // In creation of widget, if it's want to activate this class, + // the widget should define the "textDir". + + _WidgetBase.extend({ + + getTextDir: function(/*String*/ text){ + // summary: + // Gets the right direction of text. + // description: + // If textDir is ltr or rtl returns the value. + // If it's auto, calls to another function that responsible + // for checking the value, and defining the direction. + // tags: + // protected. + return this.textDir == "auto" ? this._checkContextual(text) : this.textDir; + }, + + _checkContextual: function(text){ + // summary: + // Finds the first strong (directional) character, return ltr if isLatin + // or rtl if isBidiChar. + // tags: + // private. + + // look for strong (directional) characters + var fdc = /[A-Za-z\u05d0-\u065f\u066a-\u06ef\u06fa-\u07ff\ufb1d-\ufdff\ufe70-\ufefc]/.exec(text); + // if found return the direction that defined by the character, else return widgets dir as defult. + return fdc ? ( fdc[0] <= 'z' ? "ltr" : "rtl" ) : this.dir ? this.dir : this.isLeftToRight() ? "ltr" : "rtl"; + }, + + applyTextDir: function(/*Object*/ element, /*String*/ text){ + // summary: + // Set element.dir according to this.textDir + // element: + // The text element to be set. Should have dir property. + // text: + // Used in case this.textDir is "auto", for calculating the right transformation + // description: + // If textDir is ltr or rtl returns the value. + // If it's auto, calls to another function that responsible + // for checking the value, and defining the direction. + // tags: + // protected. + + var textDir = this.textDir == "auto" ? this._checkContextual(text) : this.textDir; + // update only when there's a difference + if(element.dir != textDir){ + element.dir = textDir; + } + } + }); + + return _WidgetBase; +}); |