roojs-all.js
[roojs1] / examples / bootstrap / modal.js
index 713e62e..54bfaa5 100644 (file)
@@ -7,32 +7,87 @@
 
 Roo.example = Roo.example || {};
 
-Roo.example.modal = new Roo.XComponent({
-    part     :  ["layout","modal"],
-    order    : '001-modal',
-    region   : '',
-    parent   : '#bootstrap',
-    name     : "unnamed module",
-    disabled : false, 
-    permname : '', 
-    _tree : function()
-    {
-        this.parent = {
-            el : new Roo.bootstrap.Body()
-        }
-        this.parent.el.layout = false;
-        this.parent.el.render(document.body);
-        
+Roo.example.modal= function() {}
+Roo.apply(Roo.example.modal, {
+ dialog : false,
+ callback:  false,
+
+ show : function(data, cb)
+ {
+  if (!this.dialog) {
+   this.create();
+  }
+
+  this.callback = cb;
+  this.data = data;
+  this.dialog.show(this.data._el);
+  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;
-        var MODULE = this;
-        var baseURL = '/web.eventmanager/admin.php';
-        
-        return {
-            id : 'test-modal',
+            
+        this.dialog = Roo.factory({
             xtype: 'Modal',
             xns: Roo.bootstrap,
-            title : 'test'
-            
-        };
+            title : "Login",
+            buttons : Roo.bootstrap.Modal.OKCANCEL,
+            listeners : {
+                btnclick : function (name, e) {
+                    if(name == 'cancel'){
+                        _this.loginModal.hide();
+                    }
+                    
+                    Roo.log(name);
+                },
+                render : function (_self) {
+                    _this.loginModal = _self;
+                }
+            },
+            items : [
+                
+                {
+                    xtype: 'Container',
+                    xns: Roo.bootstrap,
+                    well : 'md',
+                    style : 'margin-top:20px',
+                    items : [
+                        {
+                            xtype: 'Form',
+                            xns: Roo.bootstrap,
+                            listeners : {
+                                actioncomplete : function (_self, action) {
+                                    if (action.type =='submit') {
+                                        _this.loginModal.hide();
+                                    }
+                                }
+                            },
+                            items : [
+                                {
+                                    xtype: 'Input',
+                                    xns: Roo.bootstrap,
+                                    fieldLabel : 'Email',
+                                    inputType : 'email',
+                                    vtype : 'email'
+                                },
+                                {
+                                    xtype: 'Input',
+                                    xns: Roo.bootstrap,
+                                    fieldLabel : 'Password',
+                                    inputType : 'password'
+                                }
+                            ]
+                        }
+                    ]
+                }
+            ]
+        });
     }
 });
\ No newline at end of file