X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/25ef3491bd9ae007ff1fc2b0d7943e6eaaccf775..6a7e4474cba9d8be4b2ec445e10f1691f7277c50:/src/widgets/layout/FormLayout.js diff --git a/src/widgets/layout/FormLayout.js b/src/widgets/layout/FormLayout.js index b327353f..fb971beb 100644 --- a/src/widgets/layout/FormLayout.js +++ b/src/widgets/layout/FormLayout.js @@ -1,6 +1,6 @@ /*! - * Ext JS Library 3.0.3 - * Copyright(c) 2006-2009 Ext JS, LLC + * Ext JS Library 3.2.0 + * Copyright(c) 2006-2010 Ext JS, Inc. * licensing@extjs.com * http://www.extjs.com/license */ @@ -114,33 +114,36 @@ Ext.layout.FormLayout = Ext.extend(Ext.layout.AnchorLayout, { * @type String * @property labelStyle */ - + /** * @cfg {Boolean} trackLabels * True to show/hide the field label when the field is hidden. Defaults to false. */ trackLabels: false, - + + type: 'form', onRemove: function(c){ Ext.layout.FormLayout.superclass.onRemove.call(this, c); - if(this.trackLabels && !this.isHide(c)){ + if(this.trackLabels){ c.un('show', this.onFieldShow, this); c.un('hide', this.onFieldHide, this); } // check for itemCt, since we may be removing a fieldset or something similar var el = c.getPositionEl(), - ct = c.getItemCt && c.getItemCt(); - if(c.rendered && ct){ - el.insertAfter(ct); + ct = c.getItemCt && c.getItemCt(); + if (c.rendered && ct) { + if (el && el.dom) { + el.insertAfter(ct); + } Ext.destroy(ct); Ext.destroyMembers(c, 'label', 'itemCt'); - if(c.customItemCt){ + if (c.customItemCt) { Ext.destroyMembers(c, 'getItemCt', 'customItemCt'); } } }, - + // private setContainer : function(ct){ Ext.layout.FormLayout.superclass.setContainer.call(this, ct); @@ -174,17 +177,18 @@ Ext.layout.FormLayout = Ext.extend(Ext.layout.AnchorLayout, { } } }, - + + // private isHide: function(c){ return c.hideLabel || this.container.hideLabels; }, - + onFieldShow: function(c){ c.getItemCt().removeClass('x-hide-' + c.hideMode); }, - + onFieldHide: function(c){ - c.getItemCt().addClass('x-hide-' + c.hideMode); + c.getItemCt().addClass('x-hide-' + c.hideMode); }, //private @@ -194,7 +198,7 @@ Ext.layout.FormLayout = Ext.extend(Ext.layout.AnchorLayout, { if (items[i]){ ls += items[i]; if (ls.substr(-1, 1) != ';'){ - ls += ';' + ls += ';'; } } } @@ -235,7 +239,10 @@ new Ext.Template( *

Also see {@link #getTemplateArgs}

*/ - // private + /** + * @private + * + */ renderItem : function(c, position, target){ if(c && (c.isFormField || c.fieldLabel) && c.inputType != 'hidden'){ var args = this.getTemplateArgs(c); @@ -247,11 +254,6 @@ new Ext.Template( }else{ c.itemCt = this.fieldTpl.append(target, args, true); } - if(!c.rendered){ - c.render('x-form-el-' + c.id); - }else if(!this.isValidParent(c, target)){ - Ext.fly('x-form-el-' + c.id).appendChild(c.getPositionEl()); - } if(!c.getItemCt){ // Non form fields don't have getItemCt, apply it here // This will get cleaned up in onRemove @@ -263,7 +265,12 @@ new Ext.Template( }); } c.label = c.getItemCt().child('label.x-form-item-label'); - if(this.trackLabels && !this.isHide(c)){ + if(!c.rendered){ + c.render('x-form-el-' + c.id); + }else if(!this.isValidParent(c, target)){ + Ext.fly('x-form-el-' + c.id).appendChild(c.getPositionEl()); + } + if(this.trackLabels){ if(c.hidden){ this.onFieldHide(c); } @@ -293,7 +300,7 @@ new Ext.Template( * A CSS style specification string to add to the field label for this field (defaults to '' or the * {@link #labelStyle layout's value for labelStyle}). *
  • label : String
    The text to display as the label for this - * field (defaults to '')
  • + * field (defaults to the field's configured fieldLabel property) *
  • {@link #labelSeparator} : String
    The separator to display after * the text of the label for this field (defaults to a colon ':' or the * {@link #labelSeparator layout's value for labelSeparator}). To hide the separator use empty string ''.
  • @@ -301,19 +308,20 @@ new Ext.Template( *
  • clearCls : String
    The CSS class to apply to the special clearing div * rendered directly after each form field wrapper (defaults to 'x-form-clear-left')
  • * - * @param field The {@link Field Ext.form.Field} being rendered. - * @return An object hash containing the properties required to render the Field. + * @param (Ext.form.Field} field The {@link Ext.form.Field Field} being rendered. + * @return {Object} An object hash containing the properties required to render the Field. */ getTemplateArgs: function(field) { var noLabelSep = !field.fieldLabel || field.hideLabel; + return { - id: field.id, - label: field.fieldLabel, - labelStyle: this.getLabelStyle(field.labelStyle), - elementStyle: this.elementStyle||'', - labelSeparator: noLabelSep ? '' : (Ext.isDefined(field.labelSeparator) ? field.labelSeparator : this.labelSeparator), - itemCls: (field.itemCls||this.container.itemCls||'') + (field.hideLabel ? ' x-hide-label' : ''), - clearCls: field.clearCls || 'x-form-clear-left' + id : field.id, + label : field.fieldLabel, + itemCls : (field.itemCls || this.container.itemCls || '') + (field.hideLabel ? ' x-hide-label' : ''), + clearCls : field.clearCls || 'x-form-clear-left', + labelStyle : this.getLabelStyle(field.labelStyle), + elementStyle : this.elementStyle || '', + labelSeparator: noLabelSep ? '' : (Ext.isDefined(field.labelSeparator) ? field.labelSeparator : this.labelSeparator) }; }, @@ -325,7 +333,7 @@ new Ext.Template( } return value; }, - + adjustHeightAnchor : function(value, c){ if(c.label && !this.isHide(c) && (this.container.labelAlign == 'top')){ return value - c.label.getHeight(); @@ -335,7 +343,7 @@ new Ext.Template( // private isValidParent : function(c, target){ - return target && this.container.getEl().contains(c.getDomPositionEl()); + return target && this.container.getEl().contains(c.getPositionEl()); } /** @@ -344,4 +352,4 @@ new Ext.Template( */ }); -Ext.Container.LAYOUTS['form'] = Ext.layout.FormLayout; \ No newline at end of file +Ext.Container.LAYOUTS['form'] = Ext.layout.FormLayout;