9 * @class Roo.bootstrap.TextArea
10 * @extends Roo.bootstrap.Input
11 * Bootstrap TextArea class
12 * @cfg {Number} cols Specifies the visible width of a text area
13 * @cfg {Number} rows Specifies the visible number of lines in a text area
14 * @cfg {string} wrap (soft|hard)Specifies how the text in a text area is to be wrapped when submitted in a form
15 * @cfg {string} resize (none|both|horizontal|vertical|inherit|initial)
16 * @cfg {string} html text
19 * Create a new TextArea
20 * @param {Object} config The config object
23 Roo.bootstrap.TextArea = function(config){
24 Roo.bootstrap.TextArea.superclass.constructor.call(this, config);
28 Roo.extend(Roo.bootstrap.TextArea, Roo.bootstrap.Input, {
38 getAutoCreate : function(){
40 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
51 value : this.value || '',
52 html: this.html || '',
54 placeholder : this.placeholder || ''
58 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
59 input.maxLength = this.maxLength;
63 input.style = (typeof(input.style) == 'undefined') ? 'resize:' + this.resize : input.style + 'resize:' + this.resize;
67 input.cols = this.cols;
71 input.readonly = true;
75 input.name = this.name;
79 input.cls = (typeof(input.cls) == 'undefined') ? 'input-' + this.size : input.cls + ' input-' + this.size;
83 ['xs','sm','md','lg'].map(function(size){
85 cfg.cls += ' col-' + size + '-' + settings[size];
89 var inputblock = input;
91 if(this.hasFeedback && !this.allowBlank){
95 cls: 'glyphicon form-control-feedback'
108 if (this.before || this.after) {
117 cls : 'input-group-addon',
122 inputblock.cn.push(input);
124 if(this.hasFeedback && !this.allowBlank){
125 inputblock.cls += ' has-feedback';
126 inputblock.cn.push(feedback);
132 cls : 'input-group-addon',
139 if (align ==='left' && this.fieldLabel.length) {
140 // Roo.log("left and has label");
146 cls : 'control-label col-sm-' + this.labelWidth,
147 html : this.fieldLabel
151 cls : "col-sm-" + (12 - this.labelWidth),
158 } else if ( this.fieldLabel.length) {
159 // Roo.log(" label");
164 //cls : 'input-group-addon',
165 html : this.fieldLabel
175 // Roo.log(" no label && no align");
193 * return the real textarea element.
197 return this.el.select('textarea.form-control',true).first();
201 * Clear any invalid styles/messages for this field
203 clearInvalid : function()
206 if(!this.el || this.preventMark){ // not rendered
210 var label = this.el.select('label', true).first();
211 var icon = this.el.select('i.fa-star', true).first();
217 this.el.removeClass(this.invalidClass);
219 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
221 var feedback = this.el.select('.form-control-feedback', true).first();
224 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
229 this.fireEvent('valid', this);
233 * Mark this field as valid
235 markValid : function()
237 if(!this.el || this.preventMark){ // not rendered
241 this.el.removeClass([this.invalidClass, this.validClass]);
243 var feedback = this.el.select('.form-control-feedback', true).first();
246 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
249 if(this.disabled || this.allowBlank){
253 var label = this.el.select('label', true).first();
254 var icon = this.el.select('i.fa-star', true).first();
260 this.el.addClass(this.validClass);
262 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
264 var feedback = this.el.select('.form-control-feedback', true).first();
267 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
268 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
273 this.fireEvent('valid', this);
277 * Mark this field as invalid
278 * @param {String} msg The validation message
280 markInvalid : function(msg)
282 if(!this.el || this.preventMark){ // not rendered
286 this.el.removeClass([this.invalidClass, this.validClass]);
288 var feedback = this.el.select('.form-control-feedback', true).first();
291 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
294 if(this.disabled || this.allowBlank){
298 var label = this.el.select('label', true).first();
299 var icon = this.el.select('i.fa-star', true).first();
301 if(!this.getValue().length && label && !icon){
302 this.el.createChild({
304 cls : 'text-danger fa fa-lg fa-star',
305 tooltip : 'This field is required',
306 style : 'margin-right:5px;'
310 this.el.addClass(this.invalidClass);
312 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
314 var feedback = this.el.select('.form-control-feedback', true).first();
317 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
319 if(this.getValue().length || this.forceFeedback){
320 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
327 this.fireEvent('invalid', this, msg);