Changelog update for 1.8
[blerg.git] / www / jssrc / blerg / SignupDialog.js
1 enyo.kind({
2     name: "blerg.SignupDialog",
3     kind: "onyx.Popup",
4     classes: "blerg-dialog",
5     autoDismiss: true,
6     centered: true,
7     floating: true,
8     modal: true,
9     components: [
10         {tag: "h2", content: "Sign Up"},
11         {name: "spinner", kind: "OldSchoolSpinner", showing: false, style: "position: absolute; top: 8px; right: 8px;"},
12         {kind: "onyx.Groupbox", components: [
13             {kind: "onyx.InputDecorator", components: [
14                 {name: "username", kind: "onyx.Input", placeholder: "Username"}
15             ]},
16             {kind: "onyx.InputDecorator", components: [
17                 {name: "password", kind: "onyx.Input", placeholder: "Password", type: "password"}
18             ]}
19         ]},
20         {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"},
21         {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*"},
22         {name: "signupButton", kind: "onyx.Button", content: "Signup", onclick: "signupClick", classes: "onyx-affirmative"},
23         {kind: "onyx.Button", content: "Cancel", onclick: "cancelClick", classes: "onyx-negative"},
24         {name: "api", kind: "blerg.API",
25          onSignupSuccess: "signupSuccess",
26          onSignupFailure: "signupFailure"}
27     ],
28     signupClick: function() {
29         this.$.signupButton.setDisabled(true);
30         this.$.spinner.show();
31         this.$.spinner.start();
32         this.$.api.signup(this.$.username.getValue(), this.$.password.getValue());
33     },
34     cancelClick: function() {
35         this.$.signupError.hide();
36         this.$.message.show();
37         this.$.username.setValue('');
38         this.$.password.setValue('');
39         this.hide();
40     },
41     signupSuccess: function(inSender, inEvent) {
42         this.$.signupButton.setDisabled(false);
43         this.$.spinner.hide();
44         this.$.spinner.stop();
45         this.bubble('onTryLogin', {
46             username: this.$.username.getValue(),
47             password: this.$.password.getValue()
48         });
49         window.location.href = '/#' + inEvent.username;
50         this.cancelClick();
51     },
52     signupFailure: function(inSender, inEvent) {
53         this.$.signupButton.setDisabled(false);
54         this.$.spinner.hide();
55         this.$.spinner.stop();
56         this.$.message.hide();
57         this.$.signupError.show();
58     }
59 });