examples/dialog/test-2.js
authorleon <leon@roojs.com>
Wed, 22 Jun 2022 03:19:16 +0000 (11:19 +0800)
committerleon <leon@roojs.com>
Wed, 22 Jun 2022 03:19:16 +0000 (11:19 +0800)
examples/dialog/test-2.js

index 88e5e11..4b1f493 100644 (file)
@@ -1,3 +1,75 @@
+var uploadCropbox = {
+    dialog : false,
+    callback : false,
+
+    show : function(data, cb)
+    {
+        if (!this.dialog) {
+            this.create();
+        }
+
+        this.callback = cb;
+        this.data = data;
+        this.dialog.show();
+    },
+
+    create : function()
+    {
+        var _this = this;
+        this.dialog = Roo.factory({
+            xns : Roo,
+            xtype : 'LayoutDialog',
+            width : 800,
+            height : 600,
+            center : {
+                xns : Roo,
+                xtype : 'LayoutRegion'
+            },
+            items : [
+                {
+                    xtype: 'ContentPanel',
+                    xns: Roo,
+                    region : "center",
+                    items : [
+                        {
+                            xtype : 'UploadCropbox',
+                            xns : Roo.dialog,
+                            minWidth : 60,
+                            minHeight: 40,
+                            listeners : {
+                                arrange : function (_self, formData)
+                                {
+                                    console.log("ARRANGE");
+                                    console.log(formData);
+                                },
+                                crop : function (_self, data)
+                                {
+                                    console.log("CROP");
+                                    console.log(data);
+                                },
+                                resize : function (_self)
+                                {
+                                    console.log("RESIZE");
+                                },
+                                rotate : function (_self)
+                                {
+                                    console.log("ROTATE");
+                                },
+                                render : function (_self)
+                                {
+                                    console.log("RENDER");
+                                    console.log(_self);
+                                    _this.cropbox = _self;
+                                }
+                            }
+                        }
+                    ]
+                }
+            ],
+        });
+    }
+}
+
 var test = {
 
     dialog : false,
@@ -31,76 +103,39 @@ var test = {
                     xns : Roo,
                     xtype: 'GridPanel',
                     region : "center",
-                    title : "Grid Panel Title",
                     grid : {
                         xns : Roo.grid,
                         xtype : 'Grid',
                         cm : [
                             {
                                 xns : Roo.grid,
-                                xtype : 'ColumnModel'
+                                xtype : 'ColumnModel',
+                                header : 'test'
                             }
-                        ]
+                        ],
+                        ds : {
+                            xns: Roo.data,
+                            xtype: 'Store'
+                        },
+                        toolbar : {
+                            xns: Roo,
+                            xtype: 'Toolbar',
+                            items : [
+                                { 
+                                    xtype : 'Button',
+                                    text : 'Add',
+                                    listeners : {
+                                        click : function () {
+                                            uploadCropbox.show();
+                                            console.log(uploadCropbox);
+                                        }
+                                    }
+                                }
+                            ]
+                        }
                     }
                 }
             ],
-            // items: [
-            //     {
-            //         xtype : 'UploadCropbox',
-            //         xns : Roo.dialog,
-            //         minWidth : 60,
-            //         minHeight: 40,
-            //         listeners : {
-            //             arrange : function (_self, formData)
-            //             {
-            //                 console.log("ARRANGE");
-            //                 console.log(formData);
-            //             },
-            //             crop : function (_self, data)
-            //             {
-            //                 console.log("CROP");
-            //                 console.log(data);
-            //             },
-            //             resize : function (_self)
-            //             {
-            //                 console.log("RESIZE");
-            //             },
-            //             rotate : function (_self)
-            //             {
-            //                 console.log("ROTATE");
-            //             },
-            //             render : function (_self)
-            //             {
-            //                 console.log("RENDER");
-            //                 console.log(_self);
-            //                 _this.cropbox = _self;
-            //             }
-        
-            //         }
-            //     }
-            // ],
-            buttons : [
-                {
-                    xtype : 'Button',
-                    xns : Roo,
-                    text : 'Submit',
-                    listeners : {
-                        click : function () {
-                            _this.dialog.hide()
-                        }   
-                    }
-                },
-                {
-                    xtype : 'Button',
-                    xns : Roo,
-                    text : 'Close',
-                    listeners : {
-                        click : function () {
-                            _this.dialog.hide()
-                        }   
-                    }
-                }
-            ]
         });
     }
 }