]> git.proxmox.com Git - proxmox-widget-toolkit.git/commitdiff
window/PasswordEdit.js: cleanup
authorDietmar Maurer <dietmar@proxmox.com>
Thu, 30 Mar 2017 04:50:27 +0000 (06:50 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 30 Mar 2017 04:50:27 +0000 (06:50 +0200)
window/PasswordEdit.js

index f6c14fa3e5c02786530fc1161c016ad5460de5f3..246c78610c878101593a64fb4d6e3de15ebd193e 100644 (file)
@@ -2,55 +2,53 @@ Ext.define('Proxmox.window.PasswordEdit', {
     extend: 'Proxmox.window.Edit',
     alias: 'proxmoxWindowPasswordEdit',
 
-    initComponent : function() {
-       var me = this;
+    subject: gettext('Password'),
 
-       if (!me.userid) {
-           throw "no userid specified";
-       }
+    url: '/api2/extjs/access/password',
 
-       var verifypw;
-       var pwfield;
+    fieldDefaults: {
+       labelWidth: 120
+    },
 
-       var validate_pw = function() {
-           if (verifypw.getValue() !== pwfield.getValue()) {
-               return gettext("Passwords does not match");
+    items: [
+       {
+           xtype: 'textfield',
+           inputType: 'password',
+           fieldLabel: gettext('Password'),
+           minLength: 5,
+           name: 'password',
+           listeners: {
+                change: function(field){
+                   field.next().validate();
+                },
+                blur: function(field){
+                   field.next().validate();
+                }
            }
-           return true;
-       };
-
-       verifypw = Ext.createWidget('textfield', { 
+       },
+       {
+           xtype: 'textfield',
            inputType: 'password',
-           fieldLabel: gettext('Confirm password'), 
+           fieldLabel: gettext('Confirm password'),
            name: 'verifypassword',
-           submitValue: false,
-           validator: validate_pw
-       });
+           vtype: 'password',
+           initialPassField: 'password',
+           submitValue: false
+       },
+       {
+           xtype: 'hiddenfield',
+           name: 'userid'
+       }
+    ],
 
-       pwfield = Ext.createWidget('textfield', { 
-           inputType: 'password',
-           fieldLabel: gettext('Password'), 
-           minLength: 5,
-           name: 'password',
-           validator: validate_pw
-       });
+    initComponent : function() {
+       var me = this;
 
-       Ext.apply(me, {
-           subject: gettext('Password'),
-           url: '/api2/extjs/access/password',
-           fieldDefaults: {
-               labelWidth: 120
-           },
-           items: [
-               pwfield, verifypw,
-               {
-                   xtype: 'hiddenfield',
-                   name: 'userid',
-                   value: me.userid
-               }
-           ]
-       });
+       if (!me.userid) {
+           throw "no userid specified";
+       }
 
        me.callParent();
+       me.down('[name=userid]').setValue(me.userid);
     }
 });