X-Git-Url: http://git.bytex64.net/?a=blobdiff_plain;f=www%2Fjssrc%2Fblerg%2FPasswdDialog.js;h=449ef378335a0155a2ae0840008d178d0f5b38f3;hb=626be60457401042854cab447a01ed4120b78886;hp=4eed325579f62feb9b720f86754dc14ee7872ab9;hpb=21db04ef3e4f66d7b5c4c9be2be36703b18cbcaa;p=blerg.git diff --git a/www/jssrc/blerg/PasswdDialog.js b/www/jssrc/blerg/PasswdDialog.js index 4eed325..449ef37 100644 --- a/www/jssrc/blerg/PasswdDialog.js +++ b/www/jssrc/blerg/PasswdDialog.js @@ -1,28 +1,72 @@ enyo.kind({ - name: "blerg.PasswdDialog", - kind: "onyx.Popup", - classes: "blerg-dialog", - autoDismiss: true, - centered: true, - floating: true, - modal: true, - components: [ - {tag: "h2", content: "Sign Up"}, - {kind: "onyx.Groupbox", components: [ - {kind: "onyx.InputDecorator", components: [ - {name: "password1", kind: "onyx.Input", placeholder: "Username", type: "password"} - ]}, - {kind: "onyx.InputDecorator", components: [ - {name: "password2", kind: "onyx.Input", placeholder: "Password", type: "password"} - ]} - ]}, - {kind: "onyx.Button", content: "Change", onclick: "changeClick", classes: "onyx.affirmative"}, - {kind: "onyx.Button", content: "Cancel", onclick: "cancelClick", classes: "onyx-negative"} - ], - changeClick: function() { - // Do stuff - }, - cancelClick: function() { - this.hide(); - } + name: "blerg.PasswdDialog", + kind: "onyx.Popup", + classes: "blerg-dialog", + autoDismiss: true, + centered: true, + floating: true, + modal: true, + components: [ + {tag: "h2", content: "Change Password"}, + {name: "spinner", kind: "OldSchoolSpinner", showing: false, style: "position: absolute; top: 8px; right: 8px;"}, + {kind: "onyx.Groupbox", components: [ + {kind: "onyx.InputDecorator", components: [ + {name: "oldpassword", kind: "onyx.Input", placeholder: "Old Password", type: "password"} + ]} + ]}, + {kind: "onyx.Groupbox", components: [ + {kind: "onyx.InputDecorator", components: [ + {name: "password1", kind: "onyx.Input", placeholder: "New Password", type: "password"} + ]}, + {kind: "onyx.InputDecorator", components: [ + {name: "password2", kind: "onyx.Input", placeholder: "New Password (again)", type: "password"} + ]} + ]}, + {name: "changePasswordError", tag: "p", showing: false, classes: "blerg-error", content: "I couldn't change your password. Are you sure you have the right old password?"}, + {name: "passwordMatchError", tag: "p", showing: false, classes: "blerg-error", content: "Your new passwords don't match."}, + {name: "changeButton", kind: "onyx.Button", content: "Change", onclick: "changeClick", classes: "onyx.affirmative"}, + {kind: "onyx.Button", content: "Cancel", onclick: "cancelClick", classes: "onyx-negative"}, + {name: "api", kind: "blerg.API", + onPasswordChangeSuccessful: "passwordChangeSuccessful", + onPasswordChangeFailed: "passwordChangeFailed"} + ], + hideErrors: function() { + this.$.changePasswordError.hide(); + this.$.passwordMatchError.hide(); + }, + changeClick: function() { + this.hideErrors(); + if (this.$.oldpassword.getValue() == '') { + this.$.changePasswordError.show(); + return; + } + if (this.$.password1.getValue() != this.$.password2.getValue()) { + this.$.passwordMatchError.show(); + return; + } + this.$.changeButton.setDisabled(true); + this.$.spinner.show(); + this.$.spinner.start(); + this.$.api.changePassword(this.$.oldpassword.getValue(), this.$.password1.getValue()); + }, + cancelClick: function() { + this.hide(); + }, + passwordChangeSuccessful: function(inSender, inEvent) { + this.$.oldpassword.setValue(''); + this.$.password1.setValue(''); + this.$.password2.setValue(''); + this.$.changeButton.setDisabled(false); + this.$.spinner.hide(); + this.$.spinner.stop(); + this.cancelClick(); + alert("Password Changed Successfully"); + }, + passwordChangeFailed: function(inSender, inEvent) { + this.$.changeButton.setDisabled(false); + this.$.spinner.hide(); + this.$.spinner.stop(); + this.hideErrors(); + this.$.changePasswordError.show(); + } });