Upgrade to ExtJS 3.1.1 - Released 02/08/2010
[extjs.git] / src / widgets / layout / AccordionLayout.js
index c552285..9998c93 100644 (file)
@@ -1,6 +1,6 @@
 /*!
- * Ext JS Library 3.1.0
- * Copyright(c) 2006-2009 Ext JS, LLC
+ * Ext JS Library 3.1.1
+ * Copyright(c) 2006-2010 Ext JS, LLC
  * licensing@extjs.com
  * http://www.extjs.com/license
  */
@@ -92,6 +92,8 @@ Ext.layout.AccordionLayout = Ext.extend(Ext.layout.FitLayout, {
      */\r
     activeOnTop : false,\r
 \r
+    type: 'accordion',\r
+\r
     renderItem : function(c){\r
         if(this.animate === false){\r
             c.animCollapse = false;\r
@@ -118,7 +120,7 @@ Ext.layout.AccordionLayout = Ext.extend(Ext.layout.FitLayout, {
         c.header.addClass('x-accordion-hd');\r
         c.on('beforeexpand', this.beforeExpand, this);\r
     },\r
-    \r
+\r
     onRemove: function(c){\r
         Ext.layout.AccordionLayout.superclass.onRemove.call(this, c);\r
         if(c.rendered){\r
@@ -147,19 +149,24 @@ Ext.layout.AccordionLayout = Ext.extend(Ext.layout.FitLayout, {
         if(this.activeOnTop){\r
             p.el.dom.parentNode.insertBefore(p.el.dom, p.el.dom.parentNode.firstChild);\r
         }\r
+        // Items have been hidden an possibly rearranged, we need to get the container size again.\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
+            var hh = 0, i, ct = this.getRenderedItems(this.container), len = ct.length, p;\r
+            // Add up all the header heights\r
+            for (i = 0; i < len; i++) {\r
+                if((p = ct[i]) != item){\r
                     hh += p.header.getHeight();\r
-                }    \r
-            });\r
+                }\r
+            };\r
+            // Subtract the header heights from the container size\r
             size.height -= hh;\r
+            // Call setSize on the container to set the correct height.  For Panels, deferedHeight\r
+            // will simply store this size for when the expansion is done.\r
             item.setSize(size);\r
         }\r
     },\r
@@ -171,7 +178,7 @@ Ext.layout.AccordionLayout = Ext.extend(Ext.layout.FitLayout, {
     setActiveItem : function(item){\r
         this.setActive(item, true);\r
     },\r
-    \r
+\r
     // private\r
     setActive : function(item, expand){\r
         var ai = this.activeItem;\r