123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- define("dijit/form/SimpleTextarea", [
- "dojo/_base/declare",
- "dojo/dom-class",
- "dojo/_base/sniff",
- "dojo/_base/window",
- "./TextBox"
- ], function(declare, domClass, has, win, TextBox){
- return declare("dijit.form.SimpleTextarea", TextBox, {
-
-
-
-
-
-
-
-
-
-
- baseClass: "dijitTextBox dijitTextArea",
-
-
- rows: "3",
-
-
- cols: "20",
- templateString: "<textarea ${!nameAttrSetting} data-dojo-attach-point='focusNode,containerNode,textbox' autocomplete='off'></textarea>",
- postMixInProperties: function(){
-
-
- if(!this.value && this.srcNodeRef){
- this.value = this.srcNodeRef.value;
- }
- this.inherited(arguments);
- },
- buildRendering: function(){
- this.inherited(arguments);
- if(has("ie") && this.cols){
- domClass.add(this.textbox, "dijitTextAreaCols");
- }
- },
- filter: function(/*String*/ value){
-
-
- if(value){
- value = value.replace(/\r/g,"");
- }
- return this.inherited(arguments);
- },
- _onInput: function(/*Event?*/ e){
-
- if(this.maxLength){
- var maxLength = parseInt(this.maxLength);
- var value = this.textbox.value.replace(/\r/g,'');
- var overflow = value.length - maxLength;
- if(overflow > 0){
- var textarea = this.textbox;
- if(textarea.selectionStart){
- var pos = textarea.selectionStart;
- var cr = 0;
- if(has("opera")){
- cr = (this.textbox.value.substring(0,pos).match(/\r/g) || []).length;
- }
- this.textbox.value = value.substring(0,pos-overflow-cr)+value.substring(pos-cr);
- textarea.setSelectionRange(pos-overflow, pos-overflow);
- }else if(win.doc.selection){
- textarea.focus();
- var range = win.doc.selection.createRange();
-
- range.moveStart("character", -overflow);
- range.text = '';
-
- range.select();
- }
- }
- }
- this.inherited(arguments);
- }
- });
- });
|