Upgrade to ExtJS 3.0.0 - Released 07/06/2009
[extjs.git] / docs / source / actions.html
diff --git a/docs/source/actions.html b/docs/source/actions.html
new file mode 100644 (file)
index 0000000..ad679e1
--- /dev/null
@@ -0,0 +1,69 @@
+<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">Ext.onReady(function(){
+    // The action
+    var action = new Ext.Action({
+        text: 'Action 1',
+        handler: function(){
+            Ext.example.msg('Click','You clicked on "Action 1".');
+        },
+        iconCls: 'blist'
+    });
+
+
+    var panel = new Ext.Panel({
+        title: 'Actions',
+        width:600,
+        height:300,
+        bodyStyle: 'padding:10px;',     // lazy inline style
+
+        tbar: [
+            action, {                   // <-- Add the action directly to a toolbar
+                text: 'Action Menu',
+                menu: [action]          // <-- Add the action directly to a menu
+            }
+        ],
+
+        items: [
+           new Ext.Button(action)       // <-- Add the action as a button
+        ],
+
+        renderTo: Ext.getBody()
+    });
+
+    var tb = panel.getTopToolbar();
+    // Buttons added to the toolbar of the Panel above
+    // to test/demo doing group operations with an action
+    tb.add('->', {
+        text: 'Disable',
+        handler: function(){
+            action.setDisabled(!action.isDisabled());
+            this.setText(action.isDisabled() ? 'Enable' : 'Disable');
+        }
+    }, {
+        text: 'Change Text',
+        handler: function(){
+            Ext.Msg.prompt('Enter Text', 'Enter new text for Action 1:', function(btn, text){
+                if(btn == 'ok' && text){
+                    action.setText(text);
+                    action.setHandler(function(){
+                        Ext.example.msg('Click','You clicked on "'+text+'".');
+                    });
+                }
+            });
+        }
+    }, {
+        text: 'Change Icon',
+        handler: function(){
+            action.setIconClass(action.getIconClass() == 'blist' ? 'bmenu' : 'blist');
+        }
+    });
+    tb.doLayout();
+});</pre>    \r
+</body>\r
+</html>
\ No newline at end of file