define([], function(){ // module: // dijit/_BidiMixin // UCC - constants that will be used by bidi support. var bidi_const = { LRM : '\u200E', LRE : '\u202A', PDF : '\u202C', RLM : '\u200f', RLE : '\u202B' }; return { // summary: // When has("dojo-bidi") is true, _WidgetBase will mixin this class. It enables support for the textdir // property to control text direction independently from the GUI direction. // 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". // textDir: String // Bi-directional support, the main variable which is responsible for the direction of the text. // The text direction can be different than the GUI direction by using this parameter in creation // of a widget. // // Allowed values: // // 1. "ltr" // 2. "rtl" // 3. "auto" - contextual the direction of a text defined by first strong letter. // // By default is as the page direction. textDir: "", 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(/*DOMNode*/ element, /*String?*/ text){ // summary: // Set element.dir according to this.textDir, assuming this.textDir has a value. // element: // The text element to be set. Should have dir property. // text: // If specified, and this.textDir is "auto", for calculating the right transformation // Otherwise text read from element. // 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. if(this.textDir){ var textDir = this.textDir; if(textDir == "auto"){ // convert "auto" to either "ltr" or "rtl" if(typeof text === "undefined"){ // text not specified, get text from element var tagName = element.tagName.toLowerCase(); text = (tagName == "input" || tagName == "textarea") ? element.value : element.innerText || element.textContent || ""; } textDir = this._checkContextual(text); } if(element.dir != textDir){ // set element's dir to match textDir, but not when textDir is null and not when it already matches element.dir = textDir; } } }, enforceTextDirWithUcc: function(option, text){ // summary: // Wraps by UCC (Unicode control characters) option's text according to this.textDir // option: // The element (`