| 1 |
define([ |
| 2 |
"dojo/_base/declare", |
| 3 |
"dojo/_base/array", |
| 4 |
"dojo/dom-construct", |
| 5 |
"./common", |
| 6 |
"dojo/_base/window" |
| 7 |
], function(declare, array, domConstruct, common, win){ |
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
return declare(null, { |
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
_applyAttributes: function(){ |
| 22 |
if(!this.textDir && this.getParent() && this.getParent().get("textDir")){ |
| 23 |
this.textDir = this.getParent().get("textDir"); |
| 24 |
} |
| 25 |
this.inherited( arguments); |
| 26 |
if(this.textDir){ |
| 27 |
this._applyTextDirToTextElements(); |
| 28 |
} |
| 29 |
}, |
| 30 |
|
| 31 |
_setRightTextAttr: function(text){ |
| 32 |
if(!this.templateString && !this.rightTextNode){ |
| 33 |
|
| 34 |
this.rightTextNode = domConstruct.create("div", {className:"mblListItemRightText"}, this.labelNode, "before"); |
| 35 |
} |
| 36 |
if(this.rightTextNode){ |
| 37 |
this.rightText = text; |
| 38 |
this.rightTextNode.innerHTML = this._cv ? this._cv(text) : text; |
| 39 |
if(this.textDir){ |
| 40 |
this.rightTextNode.innerHTML = common.enforceTextDirWithUcc(this.rightTextNode.innerHTML, this.textDir); |
| 41 |
} |
| 42 |
} |
| 43 |
}, |
| 44 |
|
| 45 |
_setLabelAttr: function(text){ |
| 46 |
this.inherited("_setLabelAttr",arguments); |
| 47 |
this.labelNode.innerHTML = common.enforceTextDirWithUcc(this.labelNode.innerHTML, this.textDir); |
| 48 |
}, |
| 49 |
|
| 50 |
_applyTextDirToTextElements: function(){ |
| 51 |
|
| 52 |
|
| 53 |
if(this.labelNode.innerHTML){ |
| 54 |
this.labelNode.innerHTML = common.removeUCCFromText(this.labelNode.innerHTML); |
| 55 |
this.labelNode.innerHTML = common.enforceTextDirWithUcc(this.labelNode.innerHTML, this.textDir); |
| 56 |
this.labelNode.style.cssText = "text-align: start"; |
| 57 |
return; |
| 58 |
} |
| 59 |
var nEncount = 0; |
| 60 |
array.forEach(this.domNode.childNodes, function(node){ |
| 61 |
var textNode; |
| 62 |
if(nEncount === 0){ |
| 63 |
|
| 64 |
if(node.nodeType === 3 && (node.nodeValue === common.MARK.RLE || node.nodeValue === common.MARK.LRE)){ |
| 65 |
node.nodeValue = (node.nodeValue === common.MARK.RLE) ? common.MARK.LRE : common.MARK.RLE; |
| 66 |
nEncount = 2; |
| 67 |
return; |
| 68 |
} |
| 69 |
var currentNode = (node.nodeType === 1 && node.childNodes.length === 1) ? node.firstChild : node; |
| 70 |
if(currentNode.nodeType === 3 && currentNode.nodeValue){ |
| 71 |
|
| 72 |
if(currentNode.nodeValue.search(/[.\S]/) != -1){ |
| 73 |
nEncount = 1; |
| 74 |
textNode = win.doc.createTextNode((this.getTextDir(currentNode.nodeValue).toLowerCase() === 'rtl') ? common.MARK.RLE : common.MARK.LRE); |
| 75 |
domConstruct.place(textNode, node, "before"); |
| 76 |
} |
| 77 |
} |
| 78 |
} |
| 79 |
|
| 80 |
else if(nEncount === 1 && node.nodeName.toLowerCase() === "div"){ |
| 81 |
nEncount = 2; |
| 82 |
textNode = win.doc.createTextNode(common.MARK.PDF); |
| 83 |
domConstruct.place(textNode, node, "before"); |
| 84 |
} |
| 85 |
}, this); |
| 86 |
}, |
| 87 |
|
| 88 |
_setTextDirAttr: function(textDir){ |
| 89 |
if(textDir && this.textDir !== textDir){ |
| 90 |
this.textDir = textDir; |
| 91 |
this._applyTextDirToTextElements(); |
| 92 |
if(this.rightTextNode){ |
| 93 |
this.rightTextNode.innerHTML = common.removeUCCFromText(this.rightTextNode.innerHTML); |
| 94 |
this.rightTextNode.innerHTML = common.enforceTextDirWithUcc(this.rightTextNode.innerHTML, this.textDir); |
| 95 |
} |
| 96 |
} |
| 97 |
} |
| 98 |
}); |
| 99 |
}); |