examples/dialog/hello.js
authorAlan Knowles <alan@akkbhome.com>
Sun, 12 Sep 2010 07:12:17 +0000 (15:12 +0800)
committerAlan Knowles <alan@akkbhome.com>
Sun, 12 Sep 2010 07:12:17 +0000 (15:12 +0800)
examples/dialog/hello.js

index 8ff312a..90b63f4 100644 (file)
  */
 
 Roo.BLANK_IMAGE_URL  = "../../images/default/s.gif";
\r
+
+
+
+HelloWorld = {
+
+    dialog : false,
+    callback:  false,
+
+    show : function(data, cb)
+    {
+        // standard code example..
+        if (!this.dialog) {
+            this.create();
+        }
+
+        this.callback = cb;
+        this.data = data;
+        this.dialog.show(data._el ? data._el : false);
+        if (this.form) {
+           this.form.reset();
+           this.form.setValues(data);
+           this.form.fireEvent('actioncomplete', this.form,  { type: 'setdata', data: data });
+        }
+
+    },
+
+    create : function()
+    {
+        var _this = this;
+        this.dialog = Roo.factory({
+            xns : Roo,
+            xtype : 'BasicDialog',
+            autoTabs:true,
+            width:500,
+            height:300,
+            shadow:true,
+            minWidth:300,
+            minHeight:250,
+            proxyDrag: true,
+            buttons : [
+                {
+                    xtype : 'Button',
+                    xns : Roo,
+                    text : 'Submit',
+                    listeners : {
+                        click : function () {
+                            _this.dialog.hide()
+                        }   
+                    }
+                }
+                buttons : [
+                {
+                    xtype : 'Button',
+                    xns : Roo,
+                    text : 'Close',
+                    listeners : {
+                        click : function () {
+                            _this.dialog.hide()
+                        }   
+                    }
+                }
+            ],
+            listeners : {
+                keydown : function(dlg, e) {
+                    var k = e.getKey(); 
+                    if(k == 27){ _this.dialog.hide(); }  
+                }
+            }
+            
+        });
+            
+    }
+}                
+
+\r
 // create the HelloWorld application (single instance)\r
 var HelloWorld = function(){\r
     // everything in this space is private and only accessible in the HelloWorld block\r