3 <title>The source code</title>
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
7 <body onload="prettyPrint();">
8 <pre class="prettyprint lang-js">/*!
10 * Copyright(c) 2006-2009 Ext JS, LLC
12 * http://www.extjs.com/license
14 <div id="cls-Ext.layout.FitLayout"></div>/**
\r
15 * @class Ext.layout.FitLayout
\r
16 * @extends Ext.layout.ContainerLayout
\r
17 * <p>This is a base class for layouts that contain <b>a single item</b> that automatically expands to fill the layout's
\r
18 * container. This class is intended to be extended or created via the <tt>layout:'fit'</tt> {@link Ext.Container#layout}
\r
19 * config, and should generally not need to be created directly via the new keyword.</p>
\r
20 * <p>FitLayout does not have any direct config options (other than inherited ones). To fit a panel to a container
\r
21 * using FitLayout, simply set layout:'fit' on the container and add a single panel to it. If the container has
\r
22 * multiple panels, only the first one will be displayed. Example usage:</p>
\r
24 var p = new Ext.Panel({
\r
25 title: 'Fit Layout',
\r
28 title: 'Inner Panel',
\r
29 html: '<p>This is the inner panel content</p>',
\r
35 Ext.layout.FitLayout = Ext.extend(Ext.layout.ContainerLayout, {
\r
40 onLayout : function(ct, target){
\r
41 Ext.layout.FitLayout.superclass.onLayout.call(this, ct, target);
\r
42 if(!this.container.collapsed){
\r
43 var sz = (Ext.isIE6 && Ext.isStrict && target.dom == document.body) ? target.getViewSize() : target.getStyleSize();
\r
44 this.setItemSize(this.activeItem || ct.items.itemAt(0), sz);
\r
49 setItemSize : function(item, size){
\r
50 if(item && size.height > 0){ // display none?
\r
55 Ext.Container.LAYOUTS['fit'] = Ext.layout.FitLayout;</pre>