roojs-all.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 var 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 : 'LayoutDialog',
45             autoTabs:true,
46             width:500,
47             height:300,
48             shadow:true,
49             minWidth:300,
50             minHeight:250,
51             proxyDrag: true,
52             listeners : {
53                 show : function() {
54                     var p = this.layout.getRegion('center').getPanel(0);
55                     p.setContent("Hello World");
56                     
57                 },
58                 keydown : function(dlg, e) {
59                     var k = e.getKey(); 
60                     if(k == 27){ _this.dialog.hide(); }  
61                 }
62             },
63             center : {
64                 xtype: 'LayoutRegion',
65                 xns: Roo
66             },
67             items : [
68                 {
69                     xtype: 'ContentPanel',
70                     xns: Roo,
71                     region : "center"
72                     
73                 }
74             ],
75             buttons : [
76                 {
77                     xtype : 'Button',
78                     xns : Roo,
79                     text : 'Submit',
80                     listeners : {
81                         click : function () {
82                             _this.dialog.hide()
83                         }   
84                     }
85                 },
86                 {
87                     xtype : 'Button',
88                     xns : Roo,
89                     text : 'Close',
90                     listeners : {
91                         click : function () {
92                             _this.dialog.hide()
93                         }   
94                     }
95                 }
96             ]
97             
98         });
99             
100     }
101 };                
102  \r
103 \r
104 // using onDocumentReady instead of window.onload initializes the application\r
105 // when the DOM is ready, without waiting for images and other resources to load\r
106 Roo.onReady(function() {
107     
108     Roo.get('show-dialog-btn').on('click',function () {
109         HelloWorld.show({ _el : this});
110     });
111 });