/www/jssrc/blerg/ForgotPasswordDialog.js
enyo.kind({
name: "blerg.ForgotPasswordDialog",
kind: "onyx.Popup",
classes: "blerg-dialog",
autoDismiss: true,
centered: true,
floating: true,
modal: true,
components: [
{tag: "h2", content: "Forgot Password"},
{name: "spinner", kind: "OldSchoolSpinner", showing: false, style: "position: absolute; top: 8px; right: 8px;"},
{kind: "onyx.Groupbox", components: [
{kind: "onyx.InputDecorator", components: [
{name: "username", kind: "onyx.Input", placeholder: "Username"}
]},
{kind: "onyx.InputDecorator", components: [
{name: "email", kind: "onyx.Input", placeholder: "Email Address"}
]}
]},
{name: "recoverError", tag: "p", showing: false, classes: 'blerg-error', content: "Please enter both username and email."},
{name: "recoverButton", kind: "onyx.Button", content: "Send Recovery Email", onclick: "recoverClick", classes: "onyx-affirmative"},
{kind: "onyx.Button", content: "Cancel", onclick: "cancelClick", classes: "onyx-negative"}
],
recoverClick: function() {
var username = this.$.username.getValue();
var email = this.$.email.getValue();
if (!(username != '' && email != '')) {
this.$.recoverError.show();
return;
}
this.$.recoverButton.setDisabled(true);
this.$.spinner.show();
this.$.spinner.start();
var req = new enyo.Ajax({
url: '/aux/recovery/mail',
method: 'POST',
postBody: {
username: username,
email: email
}
});
req.response(this, function(inSender, inResponse) {
this.$.spinner.stop();
this.$.spinner.hide();
this.$.recoverButton.setDisabled(false);
if (inResponse.status == 'success') {
alert("Recovery email sent");
this.cancelClick();
}
});
req.error(this, function(inSender, inResponse) {
this.$.spinner.stop();
this.$.spinner.hide();
this.$.recoverButton.setDisabled(false);
alert("Failed due to backend error");
});
req.go();
},
cancelClick: function() {
this.$.username.setValue('');
this.$.email.setValue('');
this.hide();
},
setUsername: function(v) {
this.$.username.setValue(v);
}
});