Make Account Center only usable when logged in
[blerg.git] / www / jssrc / blerg / Controls.js
index eb3275c..cc8ae8d 100644 (file)
@@ -10,7 +10,8 @@ enyo.kind({
     handlers: {
         onLogin: "login",
         onLogout: "logout",
-        onPostVisibility: "postVisibilityUpdate"
+        onPostVisibility: "postVisibilityUpdate",
+        onShowForgotPasswordLink: "showForgotPasswordLink"
     },
     components: [
         {name: "loggedOutControls", components: [
@@ -23,7 +24,10 @@ enyo.kind({
                         {name: "password", kind: "onyx.Input", placeholder: "Password", type: "password", attributes: {tabindex: 2}}
                     ]},
                 ]},
-                {kind: "onyx.Button", content: "Login", onclick: "loginClicked", attributes: {tabindex: 3}}
+                {kind: "onyx.Button", content: "Login", onclick: "loginClicked", attributes: {tabindex: 3}},
+                {name: "forgotPassword", showing: false, style: "margin-top: 10px; text-align: left", components: [
+                    {kind: "blerg.Link", content: "Forgot your password?", onNavigate: "popupForgotPasswordDialog"}
+                ]}
             ]}
         ]},
         {name: "loggedInControls", showing: false, components: [
@@ -34,7 +38,7 @@ enyo.kind({
                 {kind: "blerg.Link", content: "Logout", onNavigate: "logoutClicked"},
                 {tag: null, content: "."},
                 {tag: "br"},
-                {kind: "blerg.Link", content: "Change Password", onNavigate: "changePasswordClicked"},
+                {kind: "blerg.Link", content: "Account Center", href: '/#/account'},
                 {tag: null, content: "."}
             ]},
             {classes: "blerg-controls-toolbar", components: [
@@ -43,6 +47,7 @@ enyo.kind({
                 {name: "spewButton", kind: "onyx.Button", classes: "spew-button", content: "Spew It!", onclick: "spewToggle"}
             ]},
         ]},
+        {name: "forgotPasswordDialog", kind: "blerg.ForgotPasswordDialog"},
         {name: "api", kind: "blerg.API",
          onStatus: "gotStatus"},
         {kind: "Signals", 
@@ -89,6 +94,7 @@ enyo.kind({
     },
     login: function(inSender, inEvent) {
         this.$.password.setValue('');
+        this.$.forgotPassword.hide();
         // TODO: Replace with regular blur() call in future enyo
         this.$.password.node.blur();
         this.setLoggedIn(true);
@@ -146,5 +152,12 @@ enyo.kind({
         } else if (inEvent.type == 'mentioned') {
             this.gotStatus(this, {mentioned: false});
         }
+    },
+    showForgotPasswordLink: function(inSender, inevent) {
+        this.$.forgotPassword.show();
+    },
+    popupForgotPasswordDialog: function() {
+        this.$.forgotPasswordDialog.setUsername(this.$.username.getValue());
+        this.$.forgotPasswordDialog.show();
     }
 });