-/*!
- * Ext JS Library 3.0.0
- * Copyright(c) 2006-2009 Ext JS, LLC
- * licensing@extjs.com
- * http://www.extjs.com/license
- */
-/**\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: '<p>Panel content!</p>'\r
- },{\r
- title: 'Panel 2',\r
- html: '<p>Panel content!</p>'\r
- },{\r
- title: 'Panel 3',\r
- html: '<p>Panel content!</p>'\r
- }]\r
-});\r
-</code></pre>\r
- */\r
-Ext.layout.AccordionLayout = Ext.extend(Ext.layout.FitLayout, {\r
- /**\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
- /**\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
- /**\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
- /**\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
- /**\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
- /**\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
- /**\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
- /**\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
- /**\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;
\ No newline at end of file