3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
4 <title>The source code</title>
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8 <body onload="prettyPrint();">
9 <pre class="prettyprint lang-js">/*!
10 * Ext JS Library 3.3.1
11 * Copyright(c) 2006-2010 Sencha Inc.
12 * licensing@sencha.com
13 * http://www.sencha.com/license
15 // We are adding these custom layouts to a namespace that does not
16 // exist by default in Ext, so we have to add the namespace first:
17 Ext.ns('Ext.ux.layout');
20 * @class Ext.ux.layout.CenterLayout
21 * @extends Ext.layout.FitLayout
22 * <p>This is a very simple layout style used to center contents within a container. This layout works within
23 * nested containers and can also be used as expected as a Viewport layout to center the page layout.</p>
24 * <p>As a subclass of FitLayout, CenterLayout expects to have a single child panel of the container that uses
25 * the layout. The layout does not require any config options, although the child panel contained within the
26 * layout must provide a fixed or percentage width. The child panel's height will fit to the container by
27 * default, but you can specify <tt>autoHeight:true</tt> to allow it to autosize based on its content height.
30 // The content panel is centered in the container
31 var p = new Ext.Panel({
32 title: 'Center Layout',
35 title: 'Centered Content',
41 // If you leave the title blank and specify no border
42 // you'll create a non-visual, structural panel just
43 // for centering the contents in the main container.
44 var p = new Ext.Panel({
48 title: 'Centered Content',
56 Ext.ux.layout.CenterLayout = Ext.extend(Ext.layout.FitLayout, {
58 setItemSize : function(item, size){
59 this.container.addClass('ux-layout-center');
60 item.addClass('ux-layout-center-item');
61 if(item && size.height > 0){
63 size.width = item.width;
70 Ext.Container.LAYOUTS['ux.center'] = Ext.ux.layout.CenterLayout;