root / trunk / web / dojo / dijit / form / SimpleTextarea.js @ 10
History | View | Annotate | Download (1.73 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.SimpleTextarea"]){ |
9 |
dojo._hasResource["dijit.form.SimpleTextarea"]=true; |
10 |
dojo.provide("dijit.form.SimpleTextarea");
|
11 |
dojo.require("dijit.form.TextBox");
|
12 |
dojo.declare("dijit.form.SimpleTextarea",dijit.form.TextBox,{baseClass:"dijitTextBox dijitTextArea",attributeMap:dojo.delegate(dijit.form._FormValueWidget.prototype.attributeMap,{rows:"textbox",cols:"textbox"}),rows:"3",cols:"20",templateString:"<textarea ${!nameAttrSetting} dojoAttachPoint='focusNode,containerNode,textbox' autocomplete='off'></textarea>",postMixInProperties:function(){ |
13 |
if(!this.value&&this.srcNodeRef){ |
14 |
this.value=this.srcNodeRef.value; |
15 |
} |
16 |
this.inherited(arguments); |
17 |
},filter:function(_1){ |
18 |
if(_1){
|
19 |
_1=_1.replace(/\r/g,""); |
20 |
} |
21 |
return this.inherited(arguments); |
22 |
},postCreate:function(){ |
23 |
this.inherited(arguments); |
24 |
if(dojo.isIE&&this.cols){ |
25 |
dojo.addClass(this.textbox,"dijitTextAreaCols"); |
26 |
} |
27 |
},_previousValue:"",_onInput:function(e){ |
28 |
if(this.maxLength){ |
29 |
var _2=parseInt(this.maxLength); |
30 |
var _3=this.textbox.value.replace(/\r/g,""); |
31 |
var _4=_3.length-_2;
|
32 |
if(_4>0){ |
33 |
if(e){
|
34 |
dojo.stopEvent(e); |
35 |
} |
36 |
var _5=this.textbox; |
37 |
if(_5.selectionStart){
|
38 |
var _6=_5.selectionStart;
|
39 |
var cr=0; |
40 |
if(dojo.isOpera){
|
41 |
cr=(this.textbox.value.substring(0,_6).match(/\r/g)||[]).length; |
42 |
} |
43 |
this.textbox.value=_3.substring(0,_6-_4-cr)+_3.substring(_6-cr); |
44 |
_5.setSelectionRange(_6-_4,_6-_4); |
45 |
}else{
|
46 |
if(dojo.doc.selection){
|
47 |
_5.focus(); |
48 |
var _7=dojo.doc.selection.createRange();
|
49 |
_7.moveStart("character",-_4);
|
50 |
_7.text="";
|
51 |
_7.select(); |
52 |
} |
53 |
} |
54 |
} |
55 |
this._previousValue=this.textbox.value; |
56 |
} |
57 |
this.inherited(arguments); |
58 |
}}); |
59 |
} |