Upgrade to ExtJS 3.0.3 - Released 10/11/2009
[extjs.git] / docs / source / CycleButton.html
index 777d7a1..7abc37f 100644 (file)
@@ -1,11 +1,17 @@
-<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.CycleButton"></div>/**\r
+<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.CycleButton"></div>/**\r
  * @class Ext.CycleButton\r
  * @extends Ext.SplitButton\r
  * A specialized SplitButton that contains a menu of {@link Ext.menu.CheckItem} elements.  The button automatically\r
@@ -82,8 +88,8 @@ Ext.CycleButton = Ext.extend(Ext.SplitButton, {
      * @param {Boolean} suppressEvent True to prevent the button's change event from firing (defaults to false)\r
      */\r
     setActiveItem : function(item, suppressEvent){\r
-        if(typeof item != 'object'){\r
-            item = this.menu.items.get(item);\r
+        if(!Ext.isObject(item)){\r
+            item = this.menu.getComponent(item);\r
         }\r
         if(item){\r
             if(!this.rendered){\r
@@ -140,18 +146,19 @@ Ext.CycleButton = Ext.extend(Ext.SplitButton, {
 \r
         this.menu = {cls:'x-cycle-menu', items:[]};\r
         var checked;\r
-        for(var i = 0, len = this.itemCount; i < len; i++){\r
-            var item = this.items[i];\r
-            item.group = item.group || this.id;\r
-            item.itemIndex = i;\r
-            item.checkHandler = this.checkHandler;\r
-            item.scope = this;\r
-            item.checked = item.checked || false;\r
+        Ext.each(this.items, function(item, i){\r
+            Ext.apply(item, {\r
+                group: item.group || this.id,\r
+                itemIndex: i,\r
+                checkHandler: this.checkHandler,\r
+                scope: this,\r
+                checked: item.checked || false\r
+            });\r
             this.menu.items.push(item);\r
             if(item.checked){\r
                 checked = item;\r
             }\r
-        }\r
+        }, this);\r
         this.setActiveItem(checked, true);\r
         Ext.CycleButton.superclass.initComponent.call(this);\r
 \r
@@ -171,13 +178,18 @@ Ext.CycleButton = Ext.extend(Ext.SplitButton, {
      * the active item will be set to the first item in the menu.\r
      */\r
     toggleSelected : function(){\r
-        this.menu.render();\r
+        var m = this.menu;\r
+        m.render();\r
+        // layout if we haven't before so the items are active\r
+        if(!m.hasLayout){\r
+            m.doLayout();\r
+        }\r
         \r
         var nextIdx, checkItem;\r
         for (var i = 1; i < this.itemCount; i++) {\r
             nextIdx = (this.activeItem.itemIndex + i) % this.itemCount;\r
             // check the potential item\r
-            checkItem = this.menu.items.itemAt(nextIdx);\r
+            checkItem = m.items.itemAt(nextIdx);\r
             // if its not disabled then check it.\r
             if (!checkItem.disabled) {\r
                 checkItem.setChecked(true);\r
@@ -186,6 +198,6 @@ Ext.CycleButton = Ext.extend(Ext.SplitButton, {
         }\r
     }\r
 });\r
-Ext.reg('cycle', Ext.CycleButton);</pre>    \r
-</body>\r
+Ext.reg('cycle', Ext.CycleButton);</pre>
+</body>
 </html>
\ No newline at end of file