examples/dialog/hello.js
[roojs1] / examples / dialog / hello.js
1 /*
2  * Based on:
3  * Ext JS Library 1.1.1
4  * Copyright(c) 2006-2007, Ext JS, LLC.
5  *
6  * Originally Released Under LGPL - original licence link has changed is not relivant.
7  *
8  * Fork - LGPL
9  * <script type="text/javascript">
10  */
11
12 Roo.BLANK_IMAGE_URL  = "../../images/default/s.gif";
13
14
15
16 HelloWorld = {
17
18     dialog : false,
19     callback:  false,
20
21     show : function(data, cb)
22     {
23         // standard code example..
24         if (!this.dialog) {
25             this.create();
26         }
27
28         this.callback = cb;
29         this.data = data;
30         this.dialog.show(data._el ? data._el : false);
31         if (this.form) {
32            this.form.reset();
33            this.form.setValues(data);
34            this.form.fireEvent('actioncomplete', this.form,  { type: 'setdata', data: data });
35         }
36
37     },
38
39     create : function()
40     {
41         var _this = this;
42         this.dialog = Roo.factory({
43             xns : Roo,
44             xtype : 'BasicDialog',
45             autoTabs:true,
46             width:500,
47             height:300,
48             shadow:true,
49             minWidth:300,
50             minHeight:250,
51             proxyDrag: true,
52             buttons : [
53                 {
54                     xtype : 'Button',
55                     xns : Roo,
56                     text : 'Submit',
57                     listeners : {
58                         click : function () {
59                             _this.dialog.hide()
60                         }   
61                     }
62                 },
63                 {
64                     xtype : 'Button',
65                     xns : Roo,
66                     text : 'Close',
67                     listeners : {
68                         click : function () {
69                             _this.dialog.hide()
70                         }   
71                     }
72                 }
73             ],
74             listeners : {
75                 keydown : function(dlg, e) {
76                     var k = e.getKey(); 
77                     if(k == 27){ _this.dialog.hide(); }  
78                 }
79             }
80             
81         });
82             
83     }
84 };                
85  \r
86 \r
87 // using onDocumentReady instead of window.onload initializes the application\r
88 // when the DOM is ready, without waiting for images and other resources to load\r
89 Roo.onReady(function() {
90     var showBtn = Roo.get('show-dialog-btn');
91     showBtn.on('click',function () {
92         HelloWorld.show({ _el, this});
93     });
94 });