Upgrade to ExtJS 3.0.0 - Released 07/06/2009
[extjs.git] / examples / layout-browser / layouts / custom.js
index b094d82..9581da7 100644 (file)
-/*\r
- * Ext JS Library 2.2.1\r
- * Copyright(c) 2006-2009, Ext JS, LLC.\r
- * licensing@extjs.com\r
- * \r
- * http://extjs.com/license\r
- */\r
-\r
-\r
-// We are adding these custom layouts to a namespace that does not\r
-// exist by default in Ext, so we have to add the namespace first:\r
-Ext.ns('Ext.ux.layout');\r
-\r
-/*\r
- * ================  CenterLayout  =======================\r
- */\r
-/**\r
- * @class Ext.ux.layout.CenterLayout\r
- * @extends Ext.layout.FitLayout\r
- * <p>This is a very simple layout style used to center contents within a container.  This layout works within\r
- * nested containers and can also be used as expected as a Viewport layout to center the page layout.</p>\r
- * <p>As a subclass of FitLayout, CenterLayout expects to have a single child panel of the container that uses \r
- * the layout.  The layout does not require any config options, although the child panel contained within the\r
- * layout must provide a fixed or percentage width.  The child panel's height will fit to the container by\r
- * default, but you can specify <tt>autoHeight:true</tt> to allow it to autosize based on its content height.  \r
- * Example usage:</p> \r
- * <pre><code>\r
-// The content panel is centered in the container\r
-var p = new Ext.Panel({\r
-    title: 'Center Layout',\r
-    layout: 'ux.center',\r
-    items: [{\r
-        title: 'Centered Content',\r
-        width: '75%',\r
-        html: 'Some content'\r
-    }]\r
-});\r
-\r
-// If you leave the title blank and specify no border\r
-// you'll create a non-visual, structural panel just\r
-// for centering the contents in the main container.\r
-var p = new Ext.Panel({\r
-    layout: 'ux.center',\r
-    border: false,\r
-    items: [{\r
-        title: 'Centered Content',\r
-        width: 300,\r
-        autoHeight: true,\r
-        html: 'Some content'\r
-    }]\r
-});\r
-</code></pre>\r
- */\r
-Ext.ux.layout.CenterLayout = Ext.extend(Ext.layout.FitLayout, {\r
-       // private\r
-    setItemSize : function(item, size){\r
-        this.container.addClass('ux-layout-center');\r
-        item.addClass('ux-layout-center-item');\r
-        if(item && size.height > 0){\r
-            if(item.width){\r
-                size.width = item.width;\r
-            }\r
-            item.setSize(size);\r
-        }\r
-    }\r
-});\r
-Ext.Container.LAYOUTS['ux.center'] = Ext.ux.layout.CenterLayout;\r
-\r
-/*\r
- * CenterLayout demo panel\r
- */\r
-var centerLayout = {\r
-       id: 'center-panel',\r
-    layout:'ux.center',\r
-    items: {\r
-        title: 'Centered Panel: 75% of container width and fit height',\r
-        layout: 'ux.center',\r
-        autoScroll: true,\r
-        width: '75%',\r
-        bodyStyle: 'padding:20px 0;',\r
-        items: [{\r
-               title: 'Inner Centered Panel',\r
-               html: 'Fixed 300px wide and auto height. The container panel will also autoscroll if narrower than 300px.',\r
-               width: 300,\r
-               frame: true,\r
-               autoHeight: true,\r
-               bodyStyle: 'padding:10px 20px;'\r
-        }]\r
-    }\r
-};\r
-\r
-/*\r
- * ================  RowLayout  =======================\r
- */\r
-/**\r
- * @class Ext.ux.layout.RowLayout\r
- * @extends Ext.layout.ContainerLayout\r
- * <p>This is the layout style of choice for creating structural layouts in a multi-row format where the height of\r
- * each row can be specified as a percentage or fixed height.  Row widths can also be fixed, percentage or auto.\r
- * This class is intended to be extended or created via the layout:'ux.row' {@link Ext.Container#layout} config,\r
- * and should generally not need to be created directly via the new keyword.</p>\r
- * <p>RowLayout does not have any direct config options (other than inherited ones), but it does support a\r
- * specific config property of <b><tt>rowHeight</tt></b> that can be included in the config of any panel added to it.  The\r
- * layout will use the rowHeight (if present) or height of each panel during layout to determine how to size each panel.\r
- * If height or rowHeight is not specified for a given panel, its height will default to the panel's height (or auto).</p>\r
- * <p>The height property is always evaluated as pixels, and must be a number greater than or equal to 1.\r
- * The rowHeight property is always evaluated as a percentage, and must be a decimal value greater than 0 and\r
- * less than 1 (e.g., .25).</p>\r
- * <p>The basic rules for specifying row heights are pretty simple.  The logic makes two passes through the\r
- * set of contained panels.  During the first layout pass, all panels that either have a fixed height or none\r
- * specified (auto) are skipped, but their heights are subtracted from the overall container height.  During the second\r
- * pass, all panels with rowHeights are assigned pixel heights in proportion to their percentages based on\r
- * the total <b>remaining</b> container height.  In other words, percentage height panels are designed to fill the space\r
- * left over by all the fixed-height and/or auto-height panels.  Because of this, while you can specify any number of rows\r
- * with different percentages, the rowHeights must always add up to 1 (or 100%) when added together, otherwise your\r
- * layout may not render as expected.  Example usage:</p>\r
- * <pre><code>\r
-// All rows are percentages -- they must add up to 1\r
-var p = new Ext.Panel({\r
-    title: 'Row Layout - Percentage Only',\r
-    layout:'ux.row',\r
-    items: [{\r
-        title: 'Row 1',\r
-        rowHeight: .25 \r
-    },{\r
-        title: 'Row 2',\r
-        rowHeight: .6\r
-    },{\r
-        title: 'Row 3',\r
-        rowHeight: .15\r
-    }]\r
-});\r
-\r
-// Mix of height and rowHeight -- all rowHeight values must add\r
-// up to 1. The first row will take up exactly 120px, and the last two\r
-// rows will fill the remaining container height.\r
-var p = new Ext.Panel({\r
-    title: 'Row Layout - Mixed',\r
-    layout:'ux.row',\r
-    items: [{\r
-        title: 'Row 1',\r
-        height: 120,\r
-        // standard panel widths are still supported too:\r
-        width: '50%' // or 200\r
-    },{\r
-        title: 'Row 2',\r
-        rowHeight: .8,\r
-        width: 300\r
-    },{\r
-        title: 'Row 3',\r
-        rowHeight: .2\r
-    }]\r
-});\r
-</code></pre>\r
- */\r
-Ext.ux.layout.RowLayout = Ext.extend(Ext.layout.ContainerLayout, {\r
-    // private\r
-    monitorResize:true,\r
-\r
-    // private\r
-    isValidParent : function(c, target){\r
-        return c.getEl().dom.parentNode == this.innerCt.dom;\r
-    },\r
-\r
-    // private\r
-    onLayout : function(ct, target){\r
-        var rs = ct.items.items, len = rs.length, r, i;\r
-\r
-        if(!this.innerCt){\r
-            target.addClass('ux-row-layout-ct');\r
-            this.innerCt = target.createChild({cls:'x-row-inner'});\r
-        }\r
-        this.renderAll(ct, this.innerCt);\r
-\r
-        var size = target.getViewSize();\r
-\r
-        if(size.width < 1 && size.height < 1){ // display none?\r
-            return;\r
-        }\r
-\r
-        var h = size.height - target.getPadding('tb'),\r
-            ph = h;\r
-\r
-        this.innerCt.setSize({height:h});\r
-        \r
-        // some rows can be percentages while others are fixed\r
-        // so we need to make 2 passes\r
-        \r
-        for(i = 0; i < len; i++){\r
-            r = rs[i];\r
-            if(!r.rowHeight){\r
-                ph -= (r.getSize().height + r.getEl().getMargins('tb'));\r
-            }\r
-        }\r
-\r
-        ph = ph < 0 ? 0 : ph;\r
-\r
-        for(i = 0; i < len; i++){\r
-            r = rs[i];\r
-            if(r.rowHeight){\r
-                r.setSize({height: Math.floor(r.rowHeight*ph) - r.getEl().getMargins('tb')});\r
-            }\r
-        }\r
-    }\r
-    \r
-    /**\r
-     * @property activeItem\r
-     * @hide\r
-     */\r
-});\r
-Ext.Container.LAYOUTS['ux.row'] = Ext.ux.layout.RowLayout;\r
-\r
-/*\r
- * RowLayout demo panel\r
- */\r
-var rowLayout = {\r
-       id: 'row-panel',\r
-       bodyStyle: 'padding:5px',\r
-       layout: 'ux.row',\r
-    title: 'Row Layout',\r
-    items: [{\r
-        title: 'Height = 25%, Width = 50%',\r
-        rowHeight: .25,\r
-        width: '50%'\r
-    },{\r
-        title: 'Height = 100px, Width = 300px',\r
-        height: 100,\r
-        width: 300\r
-    },{\r
-       title: 'Height = 75%, Width = fit',\r
-       rowHeight: .75\r
-    }]\r
-};\r
-\r
+/*!
+ * Ext JS Library 3.0.0
+ * Copyright(c) 2006-2009 Ext JS, LLC
+ * licensing@extjs.com
+ * http://www.extjs.com/license
+ */
+/*
+ * CenterLayout demo panel
+ */
+var centerLayout = {
+       id: 'center-panel',
+    layout: 'ux.center',
+    items: {
+        title: 'Centered Panel: 75% of container width and fit height',
+        layout: 'ux.center',
+        autoScroll: true,
+        width: '75%',
+        bodyStyle: 'padding:20px 0;',
+        items: [{
+               title: 'Inner Centered Panel',
+               html: 'Fixed 300px wide and auto height. The container panel will also autoscroll if narrower than 300px.',
+               width: 300,
+               frame: true,
+               autoHeight: true,
+               bodyStyle: 'padding:10px 20px;'
+        }]
+    }
+};
+
+/*
+ * RowLayout demo panel
+ */
+var rowLayout = {
+       id: 'row-panel',
+       bodyStyle: 'padding:5px',
+       layout: 'ux.row',
+    title: 'Row Layout',
+    items: [{
+        title: 'Height = 25%, Width = 50%',
+        rowHeight: 0.25,
+        width: '50%'
+    },{
+        title: 'Height = 100px, Width = 300px',
+        height: 100,
+        width: 300
+    },{
+       title: 'Height = 75%, Width = fit',
+       rowHeight: 0.75
+    }]
+};
\ No newline at end of file