1 | /* |
---|
2 | * Ext JS Library 2.2.1 |
---|
3 | * Copyright(c) 2006-2009, Ext JS, LLC. |
---|
4 | * licensing@extjs.com |
---|
5 | * |
---|
6 | * http://extjs.com/license |
---|
7 | */ |
---|
8 | |
---|
9 | /** |
---|
10 | * @class Ext.layout.FitLayout |
---|
11 | * @extends Ext.layout.ContainerLayout |
---|
12 | * <p>This is a base class for layouts that contain a single item that automatically expands to fill the layout's |
---|
13 | * container. This class is intended to be extended or created via the layout:'fit' {@link Ext.Container#layout} |
---|
14 | * config, and should generally not need to be created directly via the new keyword.</p> |
---|
15 | * <p>FitLayout does not have any direct config options (other than inherited ones). To fit a panel to a container |
---|
16 | * using FitLayout, simply set layout:'fit' on the container and add a single panel to it. If the container has |
---|
17 | * multiple panels, only the first one will be displayed. Example usage:</p> |
---|
18 | * <pre><code> |
---|
19 | var p = new Ext.Panel({ |
---|
20 | title: 'Fit Layout', |
---|
21 | layout:'fit', |
---|
22 | items: { |
---|
23 | title: 'Inner Panel', |
---|
24 | html: '<p>This is the inner panel content</p>', |
---|
25 | border: false |
---|
26 | } |
---|
27 | }); |
---|
28 | </code></pre> |
---|
29 | */ |
---|
30 | Ext.layout.FitLayout = Ext.extend(Ext.layout.ContainerLayout, { |
---|
31 | // private |
---|
32 | monitorResize:true, |
---|
33 | |
---|
34 | // private |
---|
35 | onLayout : function(ct, target){ |
---|
36 | Ext.layout.FitLayout.superclass.onLayout.call(this, ct, target); |
---|
37 | if(!this.container.collapsed){ |
---|
38 | this.setItemSize(this.activeItem || ct.items.itemAt(0), target.getStyleSize()); |
---|
39 | } |
---|
40 | }, |
---|
41 | |
---|
42 | // private |
---|
43 | setItemSize : function(item, size){ |
---|
44 | if(item && size.height > 0){ // display none? |
---|
45 | item.setSize(size); |
---|
46 | } |
---|
47 | } |
---|
48 | }); |
---|
49 | Ext.Container.LAYOUTS['fit'] = Ext.layout.FitLayout; |
---|