Upgrade to ExtJS 4.0.0 - Released 04/26/2011
[extjs.git] / examples / window / layout.js
index 7c1d661..6edc70a 100644 (file)
@@ -1,61 +1,58 @@
-/*!
- * Ext JS Library 3.3.1
- * Copyright(c) 2006-2010 Sencha Inc.
- * licensing@sencha.com
- * http://www.sencha.com/license
- */
+Ext.require([
+    'Ext.tab.*',
+    'Ext.window.*',
+    'Ext.tip.*',
+    'Ext.layout.container.Border'
+]);
 Ext.onReady(function(){
-    
-    Ext.state.Manager.setProvider(
-            new Ext.state.SessionProvider({state: Ext.appState}));
-
-    var button = Ext.get('show-btn');
+    var win,
+        button = Ext.get('show-btn');
 
     button.on('click', function(){
 
-        // tabs for the center
-        var tabs = new Ext.TabPanel({
-            region: 'center',
-            margins:'3 3 3 0', 
-            activeTab: 0,
-            defaults:{autoScroll:true},
-
-            items:[{
-                title: 'Bogus Tab',
-                html: Ext.example.bogusMarkup
-            },{
-                title: 'Another Tab',
-                html: Ext.example.bogusMarkup
-            },{
-                title: 'Closable Tab',
-                html: Ext.example.bogusMarkup,
-                closable:true
-            }]
-        });
-
-        // Panel for the west
-        var nav = new Ext.Panel({
-            title: 'Navigation',
-            region: 'west',
-            split: true,
-            width: 200,
-            collapsible: true,
-            margins:'3 0 3 3',
-            cmargins:'3 3 3 3'
-        });
-
-        var win = new Ext.Window({
-            title: 'Layout Window',
-            closable:true,
-            width:600,
-            height:350,
-            //border:false,
-            plain:true,
-            layout: 'border',
-
-            items: [nav, tabs]
-        });
-
-        win.show(this);
+        if (!win) {
+            win = Ext.create('widget.window', {
+                title: 'Layout Window',
+                closable: true,
+                closeAction: 'hide',
+                //animateTarget: this,
+                width: 600,
+                height: 350,
+                layout: 'border',
+                bodyStyle: 'padding: 5px;',
+                items: [{
+                    region: 'west',
+                    title: 'Navigation',
+                    width: 200,
+                    split: true,
+                    collapsible: true,
+                    floatable: false
+                }, {
+                    region: 'center',
+                    xtype: 'tabpanel',
+                    items: [{
+                        title: 'Bogus Tab',
+                        html: 'Hello world 1'
+                    }, {
+                        title: 'Another Tab',
+                        html: 'Hello world 2'
+                    }, {
+                        title: 'Closable Tab',
+                        html: 'Hello world 3',
+                        closable: true
+                    }]
+                }]
+            });
+        }
+        button.dom.disabled = true;
+        if (win.isVisible()) {
+            win.hide(this, function() {
+                button.dom.disabled = false;
+            });
+        } else {
+            win.show(this, function() {
+                button.dom.disabled = false;
+            });
+        }
     });
 });
\ No newline at end of file