X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/6746dc89c47ed01b165cc1152533605f97eb8e8d..HEAD:/src/layout/Layout.js diff --git a/src/layout/Layout.js b/src/layout/Layout.js index ae5d0c4f..c869d1b3 100644 --- a/src/layout/Layout.js +++ b/src/layout/Layout.js @@ -13,8 +13,6 @@ If you are unsure which license is appropriate for your use, please contact the */ /** - * @class Ext.layout.Layout - * @extends Object * Base Layout class - extended by ComponentLayout and ContainerLayout */ Ext.define('Ext.layout.Layout', { @@ -37,7 +35,7 @@ Ext.define('Ext.layout.Layout', { layout = {}; } else { - type = layout.type; + type = layout.type || defaultType; } return Ext.createByAlias('layout.' + type, layout || {}); } @@ -73,27 +71,34 @@ Ext.define('Ext.layout.Layout', { }, beforeLayout : function() { - this.renderItems(this.getLayoutItems(), this.getRenderTarget()); + this.renderChildren(); return true; }, + renderChildren: function () { + this.renderItems(this.getLayoutItems(), this.getRenderTarget()); + }, + /** * @private * Iterates over all passed items, ensuring they are rendered. If the items are already rendered, * also determines if the items are in the proper place dom. */ renderItems : function(items, target) { - var ln = items.length, + var me = this, + ln = items.length, i = 0, item; for (; i < ln; i++) { item = items[i]; if (item && !item.rendered) { - this.renderItem(item, target, i); - } - else if (!this.isValidParent(item, target, i)) { - this.moveItem(item, target, i); + me.renderItem(item, target, i); + } else if (!me.isValidParent(item, target, i)) { + me.moveItem(item, target, i); + } else { + // still need to configure the item, it may have moved in the container. + me.configureItem(item); } } }, @@ -114,7 +119,7 @@ Ext.define('Ext.layout.Layout', { * @private * Renders the given Component into the target Element. * @param {Ext.Component} item The Component to render - * @param {Ext.core.Element} target The target Element + * @param {Ext.Element} target The target Element * @param {Number} position The position within the target to render the item to */ renderItem : function(item, target, position) { @@ -154,10 +159,13 @@ Ext.define('Ext.layout.Layout', { * initialized flag when complete. */ initLayout : function() { - if (!this.initialized && !Ext.isEmpty(this.targetCls)) { - this.getTarget().addCls(this.targetCls); + var me = this, + targetCls = me.targetCls; + + if (!me.initialized && !Ext.isEmpty(targetCls)) { + me.getTarget().addCls(targetCls); } - this.initialized = true; + me.initialized = true; }, // @private Sets the layout owner @@ -189,17 +197,18 @@ Ext.define('Ext.layout.Layout', { * Removes itemCls */ afterRemove : function(item) { - var me = this, - el = item.el, - owner = me.owner; + var el = item.el, + owner = this.owner, + itemCls = this.itemCls, + ownerCls = owner.itemCls; // Clear managed dimensions flag when removed from the layout. - if (item.rendered) { - if (me.itemCls) { - el.removeCls(me.itemCls); + if (item.rendered && !item.isDestroyed) { + if (itemCls) { + el.removeCls(itemCls); } - if (owner.itemCls) { - el.removeCls(owner.itemCls); + if (ownerCls) { + el.removeCls(ownerCls); } } @@ -210,16 +219,19 @@ Ext.define('Ext.layout.Layout', { delete item.layoutManagedHeight; }, - /* + /** * Destroys this layout. This is a template method that is empty by default, but should be implemented * by subclasses that require explicit destruction to purge event handlers or remove DOM nodes. - * @protected + * @template */ destroy : function() { - if (!Ext.isEmpty(this.targetCls)) { - var target = this.getTarget(); + var targetCls = this.targetCls, + target; + + if (!Ext.isEmpty(targetCls)) { + target = this.getTarget(); if (target) { - target.removeCls(this.targetCls); + target.removeCls(targetCls); } } this.onDestroy();