1 <!DOCTYPE html><html><head><title>Sencha Documentation Project</title><link rel="stylesheet" href="../reset.css" type="text/css"><link rel="stylesheet" href="../prettify.css" type="text/css"><link rel="stylesheet" href="../prettify_sa.css" type="text/css"><script type="text/javascript" src="../prettify.js"></script></head><body onload="prettyPrint()"><pre class="prettyprint"><pre><span id='Ext-layout.container.AbstractCard'>/**
2 </span> * @class Ext.layout.container.AbstractCard
3 * @extends Ext.layout.container.Fit
4 * <p>This layout manages multiple child Components, each is fit to the Container, where only a single child Component
5 * can be visible at any given time. This layout style is most commonly used for wizards, tab implementations, etc.
6 * This class is intended to be extended or created via the layout:'card' {@link Ext.container.Container#layout} config,
7 * and should generally not need to be created directly via the new keyword.</p>
8 * <p>The CardLayout's focal method is {@link #setActiveItem}. Since only one panel is displayed at a time,
9 * the only way to move from one Component to the next is by calling setActiveItem, passing the id or index of
10 * the next panel to display. The layout itself does not provide a user interface for handling this navigation,
11 * so that functionality must be provided by the developer.</p>
12 * <p>Containers that are configured with a card layout will have a method setActiveItem dynamically added to it.
13 * <pre><code>
14 var p = new Ext.panel.Panel({
24 </code></pre>
28 Ext.define('Ext.layout.container.AbstractCard', {
30 /* Begin Definitions */
32 extend: 'Ext.layout.container.Fit',
42 <span id='Ext-layout.container.AbstractCard-cfg-deferredRender'> /**
43 </span> * @cfg {Boolean} deferredRender
44 * True to render each contained item at the time it becomes active, false to render all contained items
45 * as soon as the layout is rendered (defaults to false). If there is a significant amount of content or
46 * a lot of heavy controls being rendered into panels that are not displayed by default, setting this to
47 * true might improve performance.
49 deferredRender : false,
51 beforeLayout: function() {
53 me.activeItem = me.getActiveItem();
54 if (me.activeItem && me.deferredRender) {
55 me.renderItems([me.activeItem], me.getRenderTarget());
59 return this.callParent(arguments);
63 onLayout: function() {
65 activeItem = me.activeItem,
66 items = me.getVisibleItems(),
68 targetBox = me.getTargetBox(),
71 for (i = 0; i < ln; i++) {
73 me.setItemBox(item, targetBox);
76 if (!me.firstActivated && activeItem) {
77 if (activeItem.fireEvent('beforeactivate', activeItem) !== false) {
78 activeItem.fireEvent('activate', activeItem);
80 me.firstActivated = true;
84 isValidParent : function(item, target, position) {
85 // Note: Card layout does not care about order within the target because only one is ever visible.
86 // We only care whether the item is a direct child of the target.
87 var itemEl = item.el ? item.el.dom : Ext.getDom(item);
88 return (itemEl && itemEl.parentNode === (target.dom || target)) || false;
91 <span id='Ext-layout.container.AbstractCard-method-getActiveItem'> /**
92 </span> * Return the active (visible) component in the layout.
93 * @returns {Ext.Component}
95 getActiveItem: function() {
97 if (!me.activeItem && me.owner) {
98 me.activeItem = me.parseActiveItem(me.owner.activeItem);
101 if (me.activeItem && me.owner.items.indexOf(me.activeItem) != -1) {
102 return me.activeItem;
109 parseActiveItem: function(item) {
110 if (item && item.isComponent) {
113 else if (typeof item == 'number' || item === undefined) {
114 return this.getLayoutItems()[item || 0];
117 return this.owner.getComponent(item);
122 configureItem: function(item, position) {
123 this.callParent([item, position]);
124 if (this.hideInactive && this.activeItem !== item) {
132 onRemove: function(component) {
133 if (component === this.activeItem) {
134 this.activeItem = null;
135 if (this.owner.items.getCount() === 0) {
136 this.firstActivated = false;
142 getAnimation: function(newCard, owner) {
143 var newAnim = (newCard || {}).cardSwitchAnimation;
144 if (newAnim === false) {
147 return newAnim || owner.cardSwitchAnimation;
150 <span id='Ext-layout.container.AbstractCard-method-getNext'> /**
151 </span> * Return the active (visible) component in the layout to the next card
152 * @returns {Ext.Component}
154 getNext: function(wrap) {
155 //NOTE: Removed the JSDoc for this function's arguments because it is not actually supported in 4.0. This
156 //should come back in 4.1
158 var items = this.getLayoutItems(),
159 index = Ext.Array.indexOf(items, this.activeItem);
160 return items[index + 1] || (wrap ? items[0] : false);
163 <span id='Ext-layout.container.AbstractCard-method-next'> /**
164 </span> * Sets the active (visible) component in the layout to the next card
166 next: function(anim, wrap) {
167 //NOTE: Removed the JSDoc for this function's arguments because it is not actually supported in 4.0. This
168 //should come back in 4.1
170 return this.setActiveItem(this.getNext(wrap), anim);
173 <span id='Ext-layout.container.AbstractCard-method-getPrev'> /**
174 </span> * Return the active (visible) component in the layout to the previous card
175 * @returns {Ext.Component}
177 getPrev: function(wrap) {
178 //NOTE: Removed the JSDoc for this function's arguments because it is not actually supported in 4.0. This
179 //should come back in 4.1
181 var items = this.getLayoutItems(),
182 index = Ext.Array.indexOf(items, this.activeItem);
183 return items[index - 1] || (wrap ? items[items.length - 1] : false);
186 <span id='Ext-layout.container.AbstractCard-method-prev'> /**
187 </span> * Sets the active (visible) component in the layout to the previous card
189 prev: function(anim, wrap) {
190 //NOTE: Removed the JSDoc for this function's arguments because it is not actually supported in 4.0. This
191 //should come back in 4.1
193 return this.setActiveItem(this.getPrev(wrap), anim);
196 </pre></pre></body></html>