examples/bootstrap/Dialog.Login.bjs
[roojs1] / examples / bootstrap / Dialog.Login.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5 Roo.namespace('Dialog');
6
7 Dialog.Login = {
8
9  dialog : false,
10  callback:  false,
11
12  show : function(data, cb)
13  {
14   if (!this.dialog) {
15    this.create();
16   }
17
18   this.callback = cb;
19   this.data = data;
20   this.dialog.show(this.data._el);
21   if (this.form) {
22    this.form.reset();
23    this.form.setValues(data);
24    this.form.fireEvent('actioncomplete', this.form,  { type: 'setdata', data: data });
25   }
26
27  },
28
29  create : function()
30  {
31   var _this = this;
32   this.dialog = Roo.factory({
33     '|xns' : 'Roo.bootstrap',
34     title : "Login",
35     xtype : 'Modal',
36     buttonPosition : 'center',
37     buttons : Roo.bootstrap.Modal.OKCANCEL,
38     xns : Roo.bootstrap,
39     listeners : {
40      btnclick : function (e)
41       {
42           if(e == 'cancel'){
43               _this.dialog.hide();
44               return;
45           }
46           
47           _this.form.doAction('submit');
48       },
49      render : function (_self) {
50       
51           Roo.get('login-err').dom.innerHTML = "";
52           
53       },
54      show : function (_self)
55       {
56           Roo.get('login-err').dom.innerHTML = "";
57       }
58     },
59     items : [
60      {
61       '|xns' : 'Roo.bootstrap',
62       xtype : 'Row',
63       xns : Roo.bootstrap,
64       style : 'margin-top:20px;',
65       items : [
66        {
67         '|xns' : 'Roo.bootstrap',
68         xtype : 'Container',
69         cls : 'col-md-12',
70         xns : Roo.bootstrap,
71         items : [
72          {
73           '|xns' : 'Roo.bootstrap',
74           url : baseURL + '/Login',
75           labelAlign : 'left',
76           xtype : 'Form',
77           method : 'POST',
78           xns : Roo.bootstrap,
79           listeners : {
80            render : function (_self) {
81                 _this.form = _self;
82             },
83            actionfailed : function (_self, action) {
84                 Roo.log('action failed?!');
85                 Roo.log(action);
86                 
87                 if (typeof(action) != 'undefined' && action.failureType == 'server') {    
88             
89                     Roo.get('login-err').dom.innerHTML = action.result.errorMsg;
90                     return;
91                 }
92                 
93                 Roo.get('login-err').dom.innerHTML = "Fill in all the required fields";
94             },
95            actioncomplete : function (_self, action) {
96                 
97                 if (action.type =='submit') {
98                     Roo.log(action);
99                     _this.dialog.hide();
100                 
101                     if (_this.callback) {
102                         _this.callback.call(_this, action.result);
103                      }
104                      
105                      _this.form.reset();
106                      
107                      return;
108                 }
109             }
110           },
111           items : [
112            {
113             '|xns' : 'Roo.bootstrap',
114             xtype : 'Container',
115             cls : 'col-sm-12',
116             xns : Roo.bootstrap,
117             items : [
118              {
119               '|xns' : 'Roo.bootstrap',
120               inputType : 'email',
121               xtype : 'Input',
122               vtype : 'email',
123               placeholder : 'Email Address',
124               allowBlank : false,
125               xns : Roo.bootstrap,
126               name : 'email',
127               listeners : {
128                specialkey : function (_self, e)
129                 {
130                     if(e.getKey() == 13){
131                         _this.form.doAction('submit');
132                     }
133                     
134                 }
135               }
136              },
137              {
138               '|xns' : 'Roo.bootstrap',
139               inputType : 'password',
140               xtype : 'Input',
141               placeholder : 'Password',
142               allowBlank : false,
143               xns : Roo.bootstrap,
144               name : 'password',
145               listeners : {
146                specialkey : function (_self, e)
147                 {
148                     if(e.getKey() == 13){
149                         _this.form.doAction('submit');
150                     }
151                 }
152               }
153              }
154             ]
155
156            }
157           ]
158
159          }
160         ]
161
162        }
163       ]
164
165      },
166      {
167       '|xns' : 'Roo.bootstrap',
168       xtype : 'Row',
169       xns : Roo.bootstrap,
170       style : 'margin-top:20px;',
171       items : [
172        {
173         '|xns' : 'Roo.bootstrap',
174         xtype : 'Container',
175         cls : 'col-md-12',
176         xns : Roo.bootstrap,
177         items : [
178          {
179           '|xns' : 'Roo.bootstrap',
180           tag : 'a',
181           xtype : 'Button',
182           html : 'Forgot password?',
183           removeClass : true,
184           xns : Roo.bootstrap,
185           weight : 'link',
186           href : '#',
187           listeners : {
188            click : function () {
189                 _this.dialog.hide();
190                 
191                 Hydra.Dialog.ForgotPassword.show({}, function(){
192                     Roo.bootstrap.MessageBox.alert('Notice', 'The password has been sent to your email');
193                 });
194             }
195           }
196          }
197         ]
198
199        }
200       ]
201
202      },
203      {
204       '|xns' : 'Roo.bootstrap',
205       xtype : 'Row',
206       xns : Roo.bootstrap,
207       items : [
208        {
209         '|xns' : 'Roo.bootstrap',
210         xtype : 'Container',
211         cls : 'col-md-12',
212         xns : Roo.bootstrap,
213         items : [
214          {
215           '|xns' : 'Roo.bootstrap',
216           xtype : 'Container',
217           style : 'margin-top:20px;',
218           cls : 'bg-danger',
219           html : '<div id=\"login-err\" class=\"dialog-err\" style=\"color:red\"></div>',
220           xns : Roo.bootstrap
221          }
222         ]
223
224        }
225       ]
226
227      }
228     ]
229
230    }  );
231  }
232 };