examples/dialog/test-2.js
[roojs1] / examples / dialog / test-2.js
1 var uploadCropbox = {
2     dialog : false,
3     callback : false,
4
5     show : function(data, cb)
6     {
7         if (!this.dialog) {
8             this.create();
9         }
10
11         this.callback = cb;
12         this.data = data;
13         this.dialog.show();
14     },
15
16     create : function()
17     {
18         var _this = this;
19         this.dialog = Roo.factory({
20             xns : Roo,
21             xtype : 'LayoutDialog',
22             width : 800,
23             height : 600,
24             center : {
25                 xns : Roo,
26                 xtype : 'LayoutRegion'
27             },
28             items : [
29                 {
30                     xtype: 'ContentPanel',
31                     xns: Roo,
32                     region : "center",
33                     items : [
34                         {
35                             xtype : 'UploadCropbox',
36                             xns : Roo.dialog,
37                             minWidth : 60,
38                             minHeight: 40,
39                             listeners : {
40                                 arrange : function (_self, formData)
41                                 {
42                                     console.log("ARRANGE");
43                                     console.log(formData);
44                                 },
45                                 crop : function (_self, data)
46                                 {
47                                     console.log("CROP");
48                                     console.log(data);
49                                 },
50                                 resize : function (_self)
51                                 {
52                                     console.log("RESIZE");
53                                 },
54                                 rotate : function (_self)
55                                 {
56                                     console.log("ROTATE");
57                                 },
58                                 render : function (_self)
59                                 {
60                                     console.log("RENDER");
61                                     console.log(_self);
62                                     _this.cropbox = _self;
63                                 }
64                             }
65                         }
66                     ]
67                 }
68             ],
69         });
70     }
71 }
72
73 var test = {
74
75     dialog : false,
76     callback : false,
77
78     show : function(data, cb)
79     {
80         if (!this.dialog) {
81             this.create();
82         }
83
84         this.callback = cb;
85         this.data = data;
86         this.dialog.show();
87     },
88
89     create : function()
90     {
91         var _this = this;
92         this.dialog = Roo.factory({
93             xns : Roo,
94             xtype : 'LayoutDialog',
95             width : 600,
96             height : 450,
97             center : {
98                 xns : Roo,
99                 xtype : 'LayoutRegion'
100             },
101             items : [
102                 {
103                     xns : Roo,
104                     xtype: 'GridPanel',
105                     region : "center",
106                     grid : {
107                         xns : Roo.grid,
108                         xtype : 'Grid',
109                         cm : [
110                             {
111                                 xns : Roo.grid,
112                                 xtype : 'ColumnModel',
113                                 header : 'test'
114                             }
115                         ],
116                         ds : {
117                             xns: Roo.data,
118                             xtype: 'Store'
119                         },
120                         toolbar : {
121                             xns: Roo,
122                             xtype: 'Toolbar',
123                             items : [
124                                 { 
125                                     xtype : 'Button',
126                                     text : 'Add',
127                                     listeners : {
128                                         click : function () {
129                                             uploadCropbox.show();
130                                             console.log(uploadCropbox);
131                                         }
132                                     }
133                                 }
134                             ]
135                         }
136                     }
137                 }
138             ],
139         });
140     }
141 }
142
143 Roo.onReady(function() {
144     
145     Roo.get('show-dialog-btn').on('click',function () {
146         test.show({});
147         console.log(test);
148     });
149 });