X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/6e39d509471fe9b4e2660e0d1631b350d0c66f40..2e847cf21b8ab9d15fa167b315ca5b2fa92638fc:/src/widgets/layout/CardLayout.js diff --git a/src/widgets/layout/CardLayout.js b/src/widgets/layout/CardLayout.js index 1da61307..c657f773 100644 --- a/src/widgets/layout/CardLayout.js +++ b/src/widgets/layout/CardLayout.js @@ -1,6 +1,6 @@ /*! - * Ext JS Library 3.1.0 - * Copyright(c) 2006-2009 Ext JS, LLC + * Ext JS Library 3.1.1 + * Copyright(c) 2006-2010 Ext JS, LLC * licensing@extjs.com * http://www.extjs.com/license */ @@ -78,7 +78,7 @@ Ext.layout.CardLayout = Ext.extend(Ext.layout.FitLayout, { * true might improve performance. */ deferredRender : false, - + /** * @cfg {Boolean} layoutOnCardChange * True to force a layout of the active item when the active card is changed. Defaults to false. @@ -90,10 +90,11 @@ Ext.layout.CardLayout = Ext.extend(Ext.layout.FitLayout, { */ // private renderHidden : true, - + + type: 'card', + constructor: function(config){ Ext.layout.CardLayout.superclass.constructor.call(this, config); - // this.forceLayout = (this.deferredRender === false); }, /** @@ -101,20 +102,34 @@ Ext.layout.CardLayout = Ext.extend(Ext.layout.FitLayout, { * @param {String/Number} item The string component id or numeric index of the item to activate */ setActiveItem : function(item){ - var ai = this.activeItem; - item = this.container.getComponent(item); - if(ai != item){ + var ai = this.activeItem, + ct = this.container; + item = ct.getComponent(item); + + // Is this a valid, different card? + if(item && ai != item){ + + // Changing cards, hide the current one if(ai){ ai.hide(); + if (ai.hidden !== true) { + return false; + } ai.fireEvent('deactivate', ai); } - var layout = item.doLayout && (this.layoutOnCardChange || !item.rendered); + // Change activeItem reference this.activeItem = item; - if(item){ - item.show(); - } + + // The container is about to get a recursive layout, remove any deferLayout reference + // because it will trigger a redundant layout. + delete item.deferLayout; + + // Show the new component + item.show(); + this.layout(); - if(item && layout){ + + if(item.doLayout){ item.doLayout(); } item.fireEvent('activate', item);