Upgrade to ExtJS 4.0.0 - Released 04/26/2011
[extjs.git] / examples / desktop / js / FitAllLayout.js
1 /*!
2  * Ext JS Library 4.0
3  * Copyright(c) 2006-2011 Sencha Inc.
4  * licensing@sencha.com
5  * http://www.sencha.com/license
6  */
7
8 /**
9  * @class Ext.ux.desktop.FitAllLayout
10  * @extends Ext.layout.container.AbstractFit
11  * <p>This layout applies a "fit" layout to all items, overlaying them on top of each
12  * other.</p>
13  */
14 Ext.define('Ext.ux.desktop.FitAllLayout', {
15     extend: 'Ext.layout.container.AbstractFit',
16     alias: 'layout.fitall',
17
18     // @private
19     onLayout : function() {
20         var me = this;
21         me.callParent();
22
23         var size = me.getLayoutTargetSize();
24
25         me.owner.items.each(function (item) {
26             me.setItemBox(item, size);
27         });
28     },
29
30     getTargetBox : function() {
31         return this.getLayoutTargetSize();
32     },
33
34     setItemBox : function(item, box) {
35         var me = this;
36         if (item && box.height > 0) {
37             if (me.isManaged('width') === true) {
38                box.width = undefined;
39             }
40             if (me.isManaged('height') === true) {
41                box.height = undefined;
42             }
43
44             item.getEl().position('absolute', null, 0, 0);
45             me.setItemSize(item, box.width, box.height);
46         }
47     }
48 });