looking for wrong seperator
[Pman.Core] / Pman.PasswordChange.js
1 //<script type="text/javascript">
2  
3  
4  
5 Pman.PasswordChange = {
6     
7     
8      
9     dialog : false,
10     form : false,
11     create: function()
12     {
13         if (this.dialog) {
14             return;
15         }
16         var _this = this;
17         
18         
19         this.dialog = new Ext.LayoutDialog(Ext.get(document.body).createChild({tag:'div'}),  { 
20             autoCreated: true,
21             title: "Change Password",
22             modal: true,
23             width:  500,
24             height: 160,
25             shadow:true,
26             resizable: false,
27             closable: false,
28             draggable: false,
29             center: {
30                 autoScroll:false,
31                 titlebar: false,
32                // tabPosition: 'top',
33                 hideTabs: true,
34                 closeOnTab: true,
35                 alwaysShowTabs: false
36             }
37             
38             
39         });
40         var dgcloser = function(data) {
41             Pman.Preview.tmpEnable();
42             
43             _this.dialog.hide();
44             if (_this.callback) {
45                 _this.callback.call(this, data ? data : false);
46             }
47         };
48         
49         this.dialog.addKeyListener(27, dgcloser,this);
50         this.dialog.addButton("Cancel",dgcloser,this);
51         this.dialog.addButton("Save", this.save, this);
52         
53         
54         this.layout = this.dialog.getLayout();
55         this.layout.beginUpdate();
56         
57         
58         this.form = new Ext.form.Form({
59             labelWidth: 220 ,
60             
61             listeners : {
62                 actionfailed : function(f, act) {
63                     //console.log(act);
64                     _this.dialog.el.unmask();
65                     // error msg???
66                     
67                     if (act.failureType == 'client') {
68                         Ext.MessageBox.alert("Error", "Please Correct all the errors");
69                         return;
70                         
71                     }
72                     
73                     if (act.type == 'submit') {
74                         
75                         Ext.MessageBox.alert("Error", typeof(act.result.errorMsg) == 'string' ?
76                             act.result.errorMsg : 
77                             "Saving failed = fix errors and try again");
78                         return;
79                     }
80                     
81                     // what about load failing..
82                     Ext.MessageBox.alert("Error", "Error loading details"); 
83                               
84                 },
85                 actioncomplete: function(f, act) {
86                     _this.dialog.el.unmask();
87                     
88                     if (act.type == 'submit') { // only submitted here if we are 
89                         dgcloser(act.data);
90                         return; 
91                     }
92                     // unmask?? 
93                 }
94             }
95         
96             
97             
98              
99         });
100         //?? will this work...
101         this.form.addxtype.apply(this.form,[
102             {
103                 name : 'passwd1',
104                 fieldLabel : "New Password ",
105                 value : '',
106                 allowBlank : false, // must be filled in as we rely on it for login details..
107                 inputType: 'password',
108                 xtype : 'SecurePass',
109                 width : 220,
110                 imageRoot : rootURL + '/Pman/templates/images'
111             },
112             {
113                 
114                 name : 'passwd2',
115                 fieldLabel : "New Password (type again to confirm)",
116                 value : '',
117                 allowBlank : false, // must be filled in as we rely on it for login details..
118                 inputType: 'password',
119                 xtype : 'TextField',
120                 width : 220
121             },
122              
123             {
124                 name : 'passwordReset',
125                 value : '',
126                 xtype : 'Hidden'
127                 
128             }
129         ]);
130         
131         
132          
133         
134         var ef = this.dialog.getLayout().getEl().createChild({tag: 'div'});
135         ef.dom.style.margin = 10;
136          
137         this.form.render(ef.dom);
138
139         var vp = this.dialog.getLayout().add('center', new Ext.ContentPanel(ef, {
140             autoCreate : true,
141             //title: 'Org Details',
142             //toolbar: this.tb,
143             width: 250,
144             maxWidth: 250,
145             fitToFrame:true
146         }));
147          
148          
149         
150         this.layout.endUpdate();
151     },
152     _id : 0,
153     show : function(data, callback)
154     {
155         this.callback= callback;
156         this.data = data;
157         this.create();
158         this.form.reset();
159          
160         // edit...
161         this.form.setValues(data);
162         
163         Pman.Preview.tmpDisable();
164         
165         this.dialog.show();
166         this.form.findField('passwd1').focus();
167         
168     },
169     save : function()
170     {
171         var p1 = this.form.findField('passwd1').getValue();
172         var p2 = this.form.findField('passwd2').getValue();
173         if (!p1.length || !p2.length) {
174             Ext.MessageBox.alert("Error", "Enter Passwords in both boxes");
175         }
176         if (p1 != p2) {
177             Ext.MessageBox.alert("Error", "Passwords do not match");
178         }
179         
180         this.form.doAction('submit', {
181             url: baseURL + '/Login.html',
182             method: 'POST',
183             params: {
184                 changePassword: true,
185                 ts : Math.random()
186             } 
187         });
188     }
189      
190       
191     
192     
193 }