| 1 |
define([ |
| 2 |
"dojo/_base/declare", |
| 3 |
"./common", |
| 4 |
"dojo/dom-class" |
| 5 |
], function(declare, common, domClass){ |
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
return declare(null, { |
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
postCreate: function(){ |
| 18 |
this.inherited(arguments); |
| 19 |
if(!this.textDir && this.getParent() && this.getParent().get("textDir")){ |
| 20 |
this.set("textDir", this.getParent().get("textDir")); |
| 21 |
} |
| 22 |
}, |
| 23 |
buildRendering: function(){ |
| 24 |
this.inherited(arguments); |
| 25 |
|
| 26 |
if(!this.isLeftToRight()){ |
| 27 |
domClass.add(this.left, "mblSwitchBgLeftRtl"); |
| 28 |
domClass.add(this.left.firstChild, "mblSwitchTextLeftRtl"); |
| 29 |
domClass.add(this.right, "mblSwitchBgRightRtl"); |
| 30 |
domClass.add(this.right.firstChild, "mblSwitchTextRightRtl"); |
| 31 |
} |
| 32 |
}, |
| 33 |
_newState: function(newState){ |
| 34 |
if(this.isLeftToRight()){ |
| 35 |
return this.inherited(arguments); |
| 36 |
} |
| 37 |
return (this.inner.offsetLeft < -(this._width/2)) ? "on" : "off"; |
| 38 |
}, |
| 39 |
_setLeftLabelAttr: function(label){ |
| 40 |
this.inherited(arguments); |
| 41 |
this.left.firstChild.innerHTML = common.enforceTextDirWithUcc(this.left.firstChild.innerHTML, this.textDir); |
| 42 |
}, |
| 43 |
|
| 44 |
_setRightLabelAttr: function(label){ |
| 45 |
this.inherited(arguments); |
| 46 |
this.right.firstChild.innerHTML = common.enforceTextDirWithUcc(this.right.firstChild.innerHTML, this.textDir); |
| 47 |
}, |
| 48 |
|
| 49 |
_setTextDirAttr: function(textDir){ |
| 50 |
if(textDir && (!this._created || this.textDir !== textDir)){ |
| 51 |
this.textDir = textDir; |
| 52 |
this.left.firstChild.innerHTML = common.removeUCCFromText(this.left.firstChild.innerHTML); |
| 53 |
this.left.firstChild.innerHTML = common.enforceTextDirWithUcc(this.left.firstChild.innerHTML, this.textDir); |
| 54 |
this.right.firstChild.innerHTML = common.removeUCCFromText(this.right.firstChild.innerHTML); |
| 55 |
this.right.firstChild.innerHTML = common.enforceTextDirWithUcc(this.right.firstChild.innerHTML, this.textDir); |
| 56 |
} |
| 57 |
} |
| 58 |
}); |
| 59 |
}); |