TextBox.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. //>>built
  2. require({cache:{"url:dijit/form/templates/TextBox.html":"<div class=\"dijit dijitReset dijitInline dijitLeft\" id=\"widget_${id}\" role=\"presentation\"\n\t><div class=\"dijitReset dijitInputField dijitInputContainer\"\n\t\t><input class=\"dijitReset dijitInputInner\" data-dojo-attach-point='textbox,focusNode' autocomplete=\"off\"\n\t\t\t${!nameAttrSetting} type='${type}'\n\t/></div\n></div>\n"}});
  3. define("dijit/form/TextBox",["dojo/_base/declare","dojo/dom-construct","dojo/dom-style","dojo/_base/kernel","dojo/_base/lang","dojo/on","dojo/sniff","./_FormValueWidget","./_TextBoxMixin","dojo/text!./templates/TextBox.html","../main"],function(_1,_2,_3,_4,_5,on,_6,_7,_8,_9,_a){
  4. var _b=_1("dijit.form.TextBox"+(_6("dojo-bidi")?"_NoBidi":""),[_7,_8],{templateString:_9,_singleNodeTemplate:"<input class=\"dijit dijitReset dijitLeft dijitInputField\" data-dojo-attach-point=\"textbox,focusNode\" autocomplete=\"off\" type=\"${type}\" ${!nameAttrSetting} />",_buttonInputDisabled:_6("ie")?"disabled":"",baseClass:"dijitTextBox",postMixInProperties:function(){
  5. var _c=this.type.toLowerCase();
  6. if(this.templateString&&this.templateString.toLowerCase()=="input"||((_c=="hidden"||_c=="file")&&this.templateString==this.constructor.prototype.templateString)){
  7. this.templateString=this._singleNodeTemplate;
  8. }
  9. this.inherited(arguments);
  10. },postCreate:function(){
  11. this.inherited(arguments);
  12. if(_6("ie")<9){
  13. this.defer(function(){
  14. try{
  15. var s=_3.getComputedStyle(this.domNode);
  16. if(s){
  17. var ff=s.fontFamily;
  18. if(ff){
  19. var _d=this.domNode.getElementsByTagName("INPUT");
  20. if(_d){
  21. for(var i=0;i<_d.length;i++){
  22. _d[i].style.fontFamily=ff;
  23. }
  24. }
  25. }
  26. }
  27. }
  28. catch(e){
  29. }
  30. });
  31. }
  32. },_setPlaceHolderAttr:function(v){
  33. this._set("placeHolder",v);
  34. if(!this._phspan){
  35. this._attachPoints.push("_phspan");
  36. this._phspan=_2.create("span",{onmousedown:function(e){
  37. e.preventDefault();
  38. },className:"dijitPlaceHolder dijitInputField"},this.textbox,"after");
  39. this.own(on(this._phspan,"touchend, MSPointerUp",_5.hitch(this,function(){
  40. this.focus();
  41. })));
  42. }
  43. this._phspan.innerHTML="";
  44. this._phspan.appendChild(this._phspan.ownerDocument.createTextNode(v));
  45. this._updatePlaceHolder();
  46. },_onInput:function(_e){
  47. this.inherited(arguments);
  48. this._updatePlaceHolder();
  49. },_updatePlaceHolder:function(){
  50. if(this._phspan){
  51. this._phspan.style.display=(this.placeHolder&&!this.textbox.value)?"":"none";
  52. }
  53. },_setValueAttr:function(_f,_10,_11){
  54. this.inherited(arguments);
  55. this._updatePlaceHolder();
  56. },getDisplayedValue:function(){
  57. _4.deprecated(this.declaredClass+"::getDisplayedValue() is deprecated. Use get('displayedValue') instead.","","2.0");
  58. return this.get("displayedValue");
  59. },setDisplayedValue:function(_12){
  60. _4.deprecated(this.declaredClass+"::setDisplayedValue() is deprecated. Use set('displayedValue', ...) instead.","","2.0");
  61. this.set("displayedValue",_12);
  62. },_onBlur:function(e){
  63. if(this.disabled){
  64. return;
  65. }
  66. this.inherited(arguments);
  67. this._updatePlaceHolder();
  68. if(_6("mozilla")){
  69. if(this.selectOnClick){
  70. this.textbox.selectionStart=this.textbox.selectionEnd=undefined;
  71. }
  72. }
  73. },_onFocus:function(by){
  74. if(this.disabled||this.readOnly){
  75. return;
  76. }
  77. this.inherited(arguments);
  78. this._updatePlaceHolder();
  79. }});
  80. if(_6("ie")){
  81. _b.prototype._isTextSelected=function(){
  82. var _13=this.ownerDocument.selection.createRange();
  83. var _14=_13.parentElement();
  84. return _14==this.textbox&&_13.text.length>0;
  85. };
  86. _a._setSelectionRange=_8._setSelectionRange=function(_15,_16,_17){
  87. if(_15.createTextRange){
  88. var r=_15.createTextRange();
  89. r.collapse(true);
  90. r.moveStart("character",-99999);
  91. r.moveStart("character",_16);
  92. r.moveEnd("character",_17-_16);
  93. r.select();
  94. }
  95. };
  96. }
  97. if(_6("dojo-bidi")){
  98. _b=_1("dijit.form.TextBox",_b,{_setPlaceHolderAttr:function(v){
  99. this.inherited(arguments);
  100. this.applyTextDir(this._phspan);
  101. }});
  102. }
  103. return _b;
  104. });