| 1 |
define([ |
| 2 |
"dojo/_base/declare", |
| 3 |
"dojo/dom-class", |
| 4 |
"dojo/sniff", |
| 5 |
"./TextBox" |
| 6 |
], function(declare, domClass, has, TextBox){ |
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
return declare("dijit.form.SimpleTextarea", TextBox, { |
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
baseClass: "dijitTextBox dijitTextArea", |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
rows: "3", |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
cols: "20", |
| 32 |
|
| 33 |
templateString: "<textarea ${!nameAttrSetting} data-dojo-attach-point='focusNode,containerNode,textbox' autocomplete='off'></textarea>", |
| 34 |
|
| 35 |
postMixInProperties: function(){ |
| 36 |
|
| 37 |
|
| 38 |
if(!this.value && this.srcNodeRef){ |
| 39 |
this.value = this.srcNodeRef.value; |
| 40 |
} |
| 41 |
this.inherited(arguments); |
| 42 |
}, |
| 43 |
|
| 44 |
buildRendering: function(){ |
| 45 |
this.inherited(arguments); |
| 46 |
if(has("ie") && this.cols){ |
| 47 |
domClass.add(this.textbox, "dijitTextAreaCols"); |
| 48 |
} |
| 49 |
}, |
| 50 |
|
| 51 |
filter: function( value){ |
| 52 |
|
| 53 |
|
| 54 |
if(value){ |
| 55 |
value = value.replace(/\r/g, ""); |
| 56 |
} |
| 57 |
return this.inherited(arguments); |
| 58 |
}, |
| 59 |
|
| 60 |
_onInput: function( e){ |
| 61 |
|
| 62 |
if(this.maxLength){ |
| 63 |
var maxLength = parseInt(this.maxLength); |
| 64 |
var value = this.textbox.value.replace(/\r/g, ''); |
| 65 |
var overflow = value.length - maxLength; |
| 66 |
if(overflow > 0){ |
| 67 |
var textarea = this.textbox; |
| 68 |
if(textarea.selectionStart){ |
| 69 |
var pos = textarea.selectionStart; |
| 70 |
var cr = 0; |
| 71 |
if(has("opera")){ |
| 72 |
cr = (this.textbox.value.substring(0, pos).match(/\r/g) || []).length; |
| 73 |
} |
| 74 |
this.textbox.value = value.substring(0, pos - overflow - cr) + value.substring(pos - cr); |
| 75 |
textarea.setSelectionRange(pos - overflow, pos - overflow); |
| 76 |
}else if(this.ownerDocument.selection){ |
| 77 |
textarea.focus(); |
| 78 |
var range = this.ownerDocument.selection.createRange(); |
| 79 |
|
| 80 |
range.moveStart("character", -overflow); |
| 81 |
range.text = ''; |
| 82 |
|
| 83 |
range.select(); |
| 84 |
} |
| 85 |
} |
| 86 |
} |
| 87 |
this.inherited(arguments); |
| 88 |
} |
| 89 |
}); |
| 90 |
}); |