[483] | 1 | define([ |
---|
| 2 | "dojo/_base/array", |
---|
| 3 | "dojo/_base/declare", |
---|
| 4 | "./common" |
---|
| 5 | ], function(array, declare, common){ |
---|
| 6 | |
---|
| 7 | // module: |
---|
| 8 | // dojox/mobile/bidi/Tooltip |
---|
| 9 | |
---|
| 10 | return declare(null, { |
---|
| 11 | // summary: |
---|
| 12 | // Support for control over text direction for mobile Tooltip widget, using Unicode Control Characters to control text direction. |
---|
| 13 | // description: |
---|
| 14 | // Implementation for text direction support for Tooltip's text containing embedded nodes. |
---|
| 15 | // Complicated embedded nodes (like tables) are not supported. |
---|
| 16 | // This class should not be used directly. |
---|
| 17 | // Mobile Tooltip widget loads this module when user sets "has: {'dojo-bidi': true }" in data-dojo-config. |
---|
| 18 | postCreate: function(){ |
---|
| 19 | this.inherited(arguments); |
---|
| 20 | if(this.textDir){ |
---|
| 21 | this._applyTextDirToTextElements(); |
---|
| 22 | } |
---|
| 23 | }, |
---|
| 24 | buildRendering: function(){ |
---|
| 25 | this.inherited(arguments); |
---|
| 26 | //dojox.mobile mirroring support |
---|
| 27 | if(!this.isLeftToRight()){ |
---|
| 28 | this.arrow.style.left = "0px"; |
---|
| 29 | } |
---|
| 30 | }, |
---|
| 31 | |
---|
| 32 | _setTextDirAttr: function(textDir){ |
---|
| 33 | if(textDir && this.textDir !== textDir){ |
---|
| 34 | this.textDir = textDir; |
---|
| 35 | this._applyTextDirToTextElements(); |
---|
| 36 | } |
---|
| 37 | }, |
---|
| 38 | |
---|
| 39 | _applyTextDirToTextElements: function(){ |
---|
| 40 | // summary: |
---|
| 41 | // Wrap relevant child text nodes in directional UCC marks |
---|
| 42 | array.forEach(this.domNode.childNodes, function(node){ |
---|
| 43 | var currentNode = (node.nodeType === 1 && node.childNodes.length === 1) ? node.firstChild : node; |
---|
| 44 | if(currentNode.nodeType === 3 && currentNode.nodeValue){ |
---|
| 45 | if(currentNode.nodeValue.search(/[.\S]/) != -1){ |
---|
| 46 | currentNode.nodeValue = common.removeUCCFromText(currentNode.nodeValue); |
---|
| 47 | currentNode.nodeValue = common.enforceTextDirWithUcc(currentNode.nodeValue, this.textDir); |
---|
| 48 | } |
---|
| 49 | } |
---|
| 50 | }, this); |
---|
| 51 | } |
---|
| 52 | }); |
---|
| 53 | }); |
---|
| 54 | |
---|