Upgrade to ExtJS 3.1.1 - Released 02/08/2010
[extjs.git] / docs / source / CardLayout.html
index 83460b5..280d1a5 100644 (file)
@@ -1,17 +1,12 @@
-<html>
-<head>
-  <title>The source code</title>
-    <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
-    <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
-</head>
-<body  onload="prettyPrint();">
-    <pre class="prettyprint lang-js">/*!
- * Ext JS Library 3.0.3
- * Copyright(c) 2006-2009 Ext JS, LLC
- * licensing@extjs.com
- * http://www.extjs.com/license
- */
-<div id="cls-Ext.layout.CardLayout"></div>/**\r
+<html>\r
+<head>\r
+  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />    \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.CardLayout"></div>/**\r
  * @class Ext.layout.CardLayout\r
  * @extends Ext.layout.FitLayout\r
  * <p>This layout manages multiple child Components, each fitted to the Container, where only a single child Component can be\r
@@ -85,7 +80,7 @@ Ext.layout.CardLayout = Ext.extend(Ext.layout.FitLayout, {
      * true might improve performance.\r
      */\r
     deferredRender : false,\r
-    \r
+\r
     <div id="cfg-Ext.layout.CardLayout-layoutOnCardChange"></div>/**\r
      * @cfg {Boolean} layoutOnCardChange\r
      * True to force a layout of the active item when the active card is changed. Defaults to false.\r
@@ -97,10 +92,11 @@ Ext.layout.CardLayout = Ext.extend(Ext.layout.FitLayout, {
      */\r
     // private\r
     renderHidden : true,\r
-    \r
+\r
+    type: 'card',\r
+\r
     constructor: function(config){\r
         Ext.layout.CardLayout.superclass.constructor.call(this, config);\r
-        this.forceLayout = (this.deferredRender === false);\r
     },\r
 \r
     <div id="method-Ext.layout.CardLayout-setActiveItem"></div>/**\r
@@ -108,18 +104,37 @@ Ext.layout.CardLayout = Ext.extend(Ext.layout.FitLayout, {
      * @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(this.activeItem){\r
-                this.activeItem.hide();\r
+        var ai = this.activeItem,\r
+            ct = this.container;\r
+        item = ct.getComponent(item);\r
+\r
+        // Is this a valid, different card?\r
+        if(item && ai != item){\r
+\r
+            // Changing cards, hide the current one\r
+            if(ai){\r
+                ai.hide();\r
+                if (ai.hidden !== true) {\r
+                    return false;\r
+                }\r
+                ai.fireEvent('deactivate', ai);\r
             }\r
-            var layout = item.doLayout && (this.layoutOnCardChange || !item.rendered);\r
+            // Change activeItem reference\r
             this.activeItem = item;\r
+\r
+            // The container is about to get a recursive layout, remove any deferLayout reference\r
+            // because it will trigger a redundant layout.\r
+            delete item.deferLayout;\r
+\r
+            // Show the new component\r
             item.show();\r
+\r
             this.layout();\r
-            if(layout){\r
+\r
+            if(item.doLayout){\r
                 item.doLayout();\r
             }\r
+            item.fireEvent('activate', item);\r
         }\r
     },\r
 \r
@@ -132,6 +147,6 @@ Ext.layout.CardLayout = Ext.extend(Ext.layout.FitLayout, {
         }\r
     }\r
 });\r
-Ext.Container.LAYOUTS['card'] = Ext.layout.CardLayout;</pre>
-</body>
+Ext.Container.LAYOUTS['card'] = Ext.layout.CardLayout;</pre>    \r
+</body>\r
 </html>
\ No newline at end of file