Ext.ux.Wizard.CardLayout.js (1919B)
1 /** 2 * Licensed under GNU LESSER GENERAL PUBLIC LICENSE Version 3 3 * 4 * @author Thorsten Suckow-Homberg <ts@siteartwork.de> 5 * @url http://www.siteartwork.de/cardlayout 6 */ 7 8 /** 9 * @class Ext.ux.layout.CardLayout 10 * @extends Ext.layout.CardLayout 11 * 12 * A specific {@link Ext.layout.CardLayout} that only sets the active item 13 * if the 'beforehide'-method of the card to hide did not return false (in this case, 14 * components usually won't be hidden). 15 * The original implementation of {@link Ext.layout.CardLayout} does not take 16 * the return value of the 'beforehide'-method into account. 17 * 18 * @constructor 19 * @param {Object} config The config object 20 */ 21 Ext.define('Ext.ux.wizard.CardLayout', { 22 23 extend: 'Ext.layout.container.Card', 24 25 /** 26 * Sets the active (visible) item in the layout. 27 * 28 * If the currently visible item is still visible after calling the 'hide() 29 * method on it, this implementation assumes that the 'beforehide'-event returned 30 * false, thus not the item was not allowed to be hidden. The active item will then 31 * equal to the item that was active, before this method was called. 32 * 33 * @param {String/Number} item The string component id or numeric index of the item to activate 34 */ 35 setActiveItem : function(item){ 36 item = this.container.getComponent(item); 37 if(this.activeItem != item){ 38 if(this.activeItem){ 39 this.activeItem.hide(); 40 } 41 // check if the beforehide method allowed to 42 // hide the current item 43 if (this.activeItem && !this.activeItem.hidden) { 44 return; 45 } 46 var layout = item.doLayout && (this.layoutOnCardChange || !item.rendered); 47 this.activeItem = item; 48 item.show(); 49 this.layout(); 50 if(layout){ 51 item.doLayout(); 52 } 53 } 54 } 55 56 });