Upgrade to ExtJS 3.0.0 - Released 07/06/2009
[extjs.git] / docs / source / AccordionLayout.html
diff --git a/docs/source/AccordionLayout.html b/docs/source/AccordionLayout.html
new file mode 100644 (file)
index 0000000..5c147da
--- /dev/null
@@ -0,0 +1,180 @@
+<html>\r
+<head>\r
+  <title>The source code</title>\r
+    <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />\r
+    <script type="text/javascript" src="../resources/prettify/prettify.js"></script>\r
+</head>\r
+<body  onload="prettyPrint();">\r
+    <pre class="prettyprint lang-js"><div id="cls-Ext.layout.AccordionLayout"></div>/**\r
+ * @class Ext.layout.AccordionLayout\r
+ * @extends Ext.layout.FitLayout\r
+ * <p>This is a layout that contains multiple panels in an expandable accordion style such that only\r
+ * <b>one panel can be open at any given time</b>.  Each panel has built-in support for expanding and collapsing.\r
+ * <p>This class is intended to be extended or created via the <tt><b>{@link Ext.Container#layout layout}</b></tt>\r
+ * configuration property.  See <tt><b>{@link Ext.Container#layout}</b></tt> for additional details.</p>\r
+ * <p>Example usage:</p>\r
+ * <pre><code>\r
+var accordion = new Ext.Panel({\r
+    title: 'Accordion Layout',\r
+    layout:'accordion',\r
+    defaults: {\r
+        // applied to each contained panel\r
+        bodyStyle: 'padding:15px'\r
+    },\r
+    layoutConfig: {\r
+        // layout-specific configs go here\r
+        titleCollapse: false,\r
+        animate: true,\r
+        activeOnTop: true\r
+    },\r
+    items: [{\r
+        title: 'Panel 1',\r
+        html: '&lt;p&gt;Panel content!&lt;/p&gt;'\r
+    },{\r
+        title: 'Panel 2',\r
+        html: '&lt;p&gt;Panel content!&lt;/p&gt;'\r
+    },{\r
+        title: 'Panel 3',\r
+        html: '&lt;p&gt;Panel content!&lt;/p&gt;'\r
+    }]\r
+});\r
+</code></pre>\r
+ */\r
+Ext.layout.AccordionLayout = Ext.extend(Ext.layout.FitLayout, {\r
+    <div id="cfg-Ext.layout.AccordionLayout-fill"></div>/**\r
+     * @cfg {Boolean} fill\r
+     * True to adjust the active item's height to fill the available space in the container, false to use the\r
+     * item's current height, or auto height if not explicitly set (defaults to true).\r
+     */\r
+    fill : true,\r
+    <div id="cfg-Ext.layout.AccordionLayout-autoWidth"></div>/**\r
+     * @cfg {Boolean} autoWidth\r
+     * True to set each contained item's width to 'auto', false to use the item's current width (defaults to true).\r
+     * Note that some components, in particular the {@link Ext.grid.GridPanel grid}, will not function properly within\r
+     * layouts if they have auto width, so in such cases this config should be set to false.\r
+     */\r
+    autoWidth : true,\r
+    <div id="cfg-Ext.layout.AccordionLayout-titleCollapse"></div>/**\r
+     * @cfg {Boolean} titleCollapse\r
+     * True to allow expand/collapse of each contained panel by clicking anywhere on the title bar, false to allow\r
+     * expand/collapse only when the toggle tool button is clicked (defaults to true).  When set to false,\r
+     * {@link #hideCollapseTool} should be false also.\r
+     */\r
+    titleCollapse : true,\r
+    <div id="cfg-Ext.layout.AccordionLayout-hideCollapseTool"></div>/**\r
+     * @cfg {Boolean} hideCollapseTool\r
+     * True to hide the contained panels' collapse/expand toggle buttons, false to display them (defaults to false).\r
+     * When set to true, {@link #titleCollapse} should be true also.\r
+     */\r
+    hideCollapseTool : false,\r
+    <div id="cfg-Ext.layout.AccordionLayout-collapseFirst"></div>/**\r
+     * @cfg {Boolean} collapseFirst\r
+     * True to make sure the collapse/expand toggle button always renders first (to the left of) any other tools\r
+     * in the contained panels' title bars, false to render it last (defaults to false).\r
+     */\r
+    collapseFirst : false,\r
+    <div id="cfg-Ext.layout.AccordionLayout-animate"></div>/**\r
+     * @cfg {Boolean} animate\r
+     * True to slide the contained panels open and closed during expand/collapse using animation, false to open and\r
+     * close directly with no animation (defaults to false).  Note: to defer to the specific config setting of each\r
+     * contained panel for this property, set this to undefined at the layout level.\r
+     */\r
+    animate : false,\r
+    <div id="cfg-Ext.layout.AccordionLayout-sequence"></div>/**\r
+     * @cfg {Boolean} sequence\r
+     * <b>Experimental</b>. If animate is set to true, this will result in each animation running in sequence.\r
+     */\r
+    sequence : false,\r
+    <div id="cfg-Ext.layout.AccordionLayout-activeOnTop"></div>/**\r
+     * @cfg {Boolean} activeOnTop\r
+     * True to swap the position of each panel as it is expanded so that it becomes the first item in the container,\r
+     * false to keep the panels in the rendered order. <b>This is NOT compatible with "animate:true"</b> (defaults to false).\r
+     */\r
+    activeOnTop : false,\r
+\r
+    renderItem : function(c){\r
+        if(this.animate === false){\r
+            c.animCollapse = false;\r
+        }\r
+        c.collapsible = true;\r
+        if(this.autoWidth){\r
+            c.autoWidth = true;\r
+        }\r
+        if(this.titleCollapse){\r
+            c.titleCollapse = true;\r
+        }\r
+        if(this.hideCollapseTool){\r
+            c.hideCollapseTool = true;\r
+        }\r
+        if(this.collapseFirst !== undefined){\r
+            c.collapseFirst = this.collapseFirst;\r
+        }\r
+        if(!this.activeItem && !c.collapsed){\r
+            this.activeItem = c;\r
+        }else if(this.activeItem && this.activeItem != c){\r
+            c.collapsed = true;\r
+        }\r
+        Ext.layout.AccordionLayout.superclass.renderItem.apply(this, arguments);\r
+        c.header.addClass('x-accordion-hd');\r
+        c.on('beforeexpand', this.beforeExpand, this);\r
+    },\r
+\r
+    // private\r
+    beforeExpand : function(p, anim){\r
+        var ai = this.activeItem;\r
+        if(ai){\r
+            if(this.sequence){\r
+                delete this.activeItem;\r
+                if (!ai.collapsed){\r
+                    ai.collapse({callback:function(){\r
+                        p.expand(anim || true);\r
+                    }, scope: this});\r
+                    return false;\r
+                }\r
+            }else{\r
+                ai.collapse(this.animate);\r
+            }\r
+        }\r
+        this.activeItem = p;\r
+        if(this.activeOnTop){\r
+            p.el.dom.parentNode.insertBefore(p.el.dom, p.el.dom.parentNode.firstChild);\r
+        }\r
+        this.layout();\r
+    },\r
+\r
+    // private\r
+    setItemSize : function(item, size){\r
+        if(this.fill && item){\r
+            var hh = 0;\r
+            this.container.items.each(function(p){\r
+                if(p != item){\r
+                    hh += p.header.getHeight();\r
+                }    \r
+            });\r
+            size.height -= hh;\r
+            item.setSize(size);\r
+        }\r
+    },\r
+\r
+    <div id="method-Ext.layout.AccordionLayout-setActiveItem"></div>/**\r
+     * Sets the active (expanded) item in the layout.\r
+     * @param {String/Number} item The string component id or numeric index of the item to activate\r
+     */\r
+    setActiveItem : function(item){\r
+        item = this.container.getComponent(item);\r
+        if(this.activeItem != item){\r
+            if(item.rendered && item.collapsed){\r
+                item.expand();\r
+            }else{\r
+                this.activeItem = item;\r
+            }\r
+        }\r
+\r
+    }\r
+});\r
+Ext.Container.LAYOUTS.accordion = Ext.layout.AccordionLayout;\r
+\r
+//backwards compat\r
+Ext.layout.Accordion = Ext.layout.AccordionLayout;</pre>    \r
+</body>\r
+</html>
\ No newline at end of file