X-Git-Url: http://git.bytex64.net/?a=blobdiff_plain;f=www%2Fjssrc%2Fblerg%2FSignupDialog.js;h=14602f65d7aab3fad99144f9b6bb80142d6255d5;hb=3e5f69d01b9488475413d4ecce8161ab7a889ca2;hp=c62108b88eb7d9dfb6fb7d3fa5d06f3a7a8df68a;hpb=21db04ef3e4f66d7b5c4c9be2be36703b18cbcaa;p=blerg.git diff --git a/www/jssrc/blerg/SignupDialog.js b/www/jssrc/blerg/SignupDialog.js index c62108b..14602f6 100644 --- a/www/jssrc/blerg/SignupDialog.js +++ b/www/jssrc/blerg/SignupDialog.js @@ -1,28 +1,59 @@ enyo.kind({ - name: "blerg.SignupDialog", - 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: "username", kind: "onyx.Input", placeholder: "Username"} - ]}, - {kind: "onyx.InputDecorator", components: [ - {name: "password", kind: "onyx.Input", placeholder: "Password", type: "password"} - ]} - ]}, - {kind: "onyx.Button", content: "Signup", onclick: "signupClick", classes: "onyx-affirmative"}, - {kind: "onyx.Button", content: "Cancel", onclick: "cancelClick", classes: "onyx-negative"} - ], - signupClick: function() { - // Do stuff - }, - cancelClick: function() { - this.hide(); - } + name: "blerg.SignupDialog", + kind: "onyx.Popup", + classes: "blerg-dialog", + autoDismiss: true, + centered: true, + floating: true, + modal: true, + components: [ + {tag: "h2", content: "Sign Up"}, + {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: "password", kind: "onyx.Input", placeholder: "Password", type: "password"} + ]} + ]}, + {name: "message", tag: "p", content: "No, really, that's all I need. I don't want to send you email. It's too much work to program in email updates. :-P"}, + {name: "signupError", tag: "p", showing: false, classes: "blerg-error", content: "I couldn't sign you up. That username is already in use, or something went wrong on the backend. *shrug*"}, + {name: "signupButton", kind: "onyx.Button", content: "Signup", onclick: "signupClick", classes: "onyx-affirmative"}, + {kind: "onyx.Button", content: "Cancel", onclick: "cancelClick", classes: "onyx-negative"}, + {name: "api", kind: "blerg.API", + onSignupSuccess: "signupSuccess", + onSignupFailure: "signupFailure"} + ], + signupClick: function() { + this.$.signupButton.setDisabled(true); + this.$.spinner.show(); + this.$.spinner.start(); + this.$.api.signup(this.$.username.getValue(), this.$.password.getValue()); + }, + cancelClick: function() { + this.$.signupError.hide(); + this.$.message.show(); + this.$.username.setValue(''); + this.$.password.setValue(''); + this.hide(); + }, + signupSuccess: function(inSender, inEvent) { + this.$.signupButton.setDisabled(false); + this.$.spinner.hide(); + this.$.spinner.stop(); + this.bubble('onTryLogin', { + username: this.$.username.getValue(), + password: this.$.password.getValue() + }); + window.location.href = '/#' + inEvent.username; + this.cancelClick(); + }, + signupFailure: function(inSender, inEvent) { + this.$.signupButton.setDisabled(false); + this.$.spinner.hide(); + this.$.spinner.stop(); + this.$.message.hide(); + this.$.signupError.show(); + } });