root / trunk / web / dojo / dijit / form / Textarea.js @ 12
History | View | Annotate | Download (2.82 KB)
1 |
/*
|
---|---|
2 |
Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
|
3 |
Available via Academic Free License >= 2.1 OR the modified BSD license.
|
4 |
see: http://dojotoolkit.org/license for details
|
5 |
*/
|
6 |
|
7 |
|
8 |
if(!dojo._hasResource["dijit.form.Textarea"]){ |
9 |
dojo._hasResource["dijit.form.Textarea"]=true; |
10 |
dojo.provide("dijit.form.Textarea");
|
11 |
dojo.require("dijit.form.SimpleTextarea");
|
12 |
dojo.declare("dijit.form.Textarea",dijit.form.SimpleTextarea,{cols:"",_previousNewlines:0,_strictMode:(dojo.doc.compatMode!="BackCompat"),_getHeight:function(_1){ |
13 |
var _2=_1.scrollHeight;
|
14 |
if(dojo.isIE){
|
15 |
_2+=_1.offsetHeight-_1.clientHeight-((dojo.isIE<8&&this._strictMode)?dojo._getPadBorderExtents(_1).h:0); |
16 |
}else{
|
17 |
if(dojo.isMoz){
|
18 |
_2+=_1.offsetHeight-_1.clientHeight; |
19 |
}else{
|
20 |
if(dojo.isWebKit&&!(dojo.isSafari<4)){ |
21 |
_2+=dojo._getBorderExtents(_1).h; |
22 |
}else{
|
23 |
_2+=dojo._getPadBorderExtents(_1).h; |
24 |
} |
25 |
} |
26 |
} |
27 |
return _2;
|
28 |
},_estimateHeight:function(_3){ |
29 |
_3.style.maxHeight="";
|
30 |
_3.style.height="auto";
|
31 |
_3.rows=(_3.value.match(/\n/g)||[]).length+1; |
32 |
},_needsHelpShrinking:dojo.isMoz||dojo.isWebKit,_onInput:function(){ |
33 |
this.inherited(arguments); |
34 |
if(this._busyResizing){ |
35 |
return;
|
36 |
} |
37 |
this._busyResizing=true; |
38 |
var _4=this.textbox; |
39 |
if(_4.scrollHeight&&_4.offsetHeight&&_4.clientHeight){
|
40 |
var _5=this._getHeight(_4)+"px"; |
41 |
if(_4.style.height!=_5){
|
42 |
_4.style.maxHeight=_4.style.height=_5; |
43 |
} |
44 |
if(this._needsHelpShrinking){ |
45 |
if(this._setTimeoutHandle){ |
46 |
clearTimeout(this._setTimeoutHandle);
|
47 |
} |
48 |
this._setTimeoutHandle=setTimeout(dojo.hitch(this,"_shrink"),0); |
49 |
} |
50 |
}else{
|
51 |
this._estimateHeight(_4);
|
52 |
} |
53 |
this._busyResizing=false; |
54 |
},_busyResizing:false,_shrink:function(){ |
55 |
this._setTimeoutHandle=null; |
56 |
if(this._needsHelpShrinking&&!this._busyResizing){ |
57 |
this._busyResizing=true; |
58 |
var _6=this.textbox; |
59 |
var _7=false; |
60 |
if(_6.value==""){ |
61 |
_6.value=" ";
|
62 |
_7=true;
|
63 |
} |
64 |
var _8=_6.scrollHeight;
|
65 |
if(!_8){
|
66 |
this._estimateHeight(_6);
|
67 |
}else{
|
68 |
var _9=_6.style.paddingBottom;
|
69 |
var _a=dojo._getPadExtents(_6);
|
70 |
_a=_a.h-_a.t; |
71 |
_6.style.paddingBottom=_a+1+"px"; |
72 |
var _b=this._getHeight(_6)-1+"px"; |
73 |
if(_6.style.maxHeight!=_b){
|
74 |
_6.style.paddingBottom=_a+_8+"px";
|
75 |
_6.scrollTop=0;
|
76 |
_6.style.maxHeight=this._getHeight(_6)-_8+"px"; |
77 |
} |
78 |
_6.style.paddingBottom=_9; |
79 |
} |
80 |
if(_7){
|
81 |
_6.value="";
|
82 |
} |
83 |
this._busyResizing=false; |
84 |
} |
85 |
},resize:function(){ |
86 |
this._onInput();
|
87 |
},_setValueAttr:function(){ |
88 |
this.inherited(arguments); |
89 |
this.resize();
|
90 |
},postCreate:function(){ |
91 |
this.inherited(arguments); |
92 |
dojo.style(this.textbox,{overflowY:"hidden",overflowX:"auto",boxSizing:"border-box",MsBoxSizing:"border-box",WebkitBoxSizing:"border-box",MozBoxSizing:"border-box"}); |
93 |
this.connect(this.textbox,"onscroll",this._onInput); |
94 |
this.connect(this.textbox,"onresize",this._onInput); |
95 |
this.connect(this.textbox,"onfocus",this._onInput); |
96 |
this._setTimeoutHandle=setTimeout(dojo.hitch(this,"resize"),0); |
97 |
},uninitialize:function(){ |
98 |
if(this._setTimeoutHandle){ |
99 |
clearTimeout(this._setTimeoutHandle);
|
100 |
} |
101 |
this.inherited(arguments); |
102 |
}}); |
103 |
} |