2 name: "blerg.Controls",
4 classes: "blerg-controls",
13 onPostVisibility: "postVisibilityUpdate",
14 onShowForgotPasswordLink: "showForgotPasswordLink"
17 {name: "loggedOutControls", components: [
18 {tag: "form", onkeyup: "loginKeyUp", classes: "login", components: [
19 {kind: "onyx.Groupbox", components: [
20 {kind: "onyx.InputDecorator", components: [
21 {name: "username", kind: "onyx.Input", placeholder: "Username", attributes: {tabindex: 1}}
23 {kind: "onyx.InputDecorator", components: [
24 {name: "password", kind: "onyx.Input", placeholder: "Password", type: "password", attributes: {tabindex: 2}}
27 {kind: "onyx.Button", content: "Login", onclick: "loginClicked", attributes: {tabindex: 3}},
28 {name: "forgotPassword", showing: false, style: "margin-top: 10px; text-align: left", components: [
29 {kind: "blerg.Link", content: "Forgot your password?", onNavigate: "popupForgotPasswordDialog"}
33 {name: "loggedInControls", showing: false, components: [
34 {name: "greeting", classes: "blerg-controls-greeting", components: [
35 {tag: null, content: "Hello, "},
36 {name: "userlink", tag: "a"},
37 {tag: null, content: ". "},
38 {kind: "blerg.Link", content: "Logout", onNavigate: "logoutClicked"},
39 {tag: null, content: "."},
41 {kind: "blerg.Link", content: "Account Center", href: '/#/account'},
42 {tag: null, content: "."}
44 {classes: "blerg-controls-toolbar", components: [
45 {name: "mentionButton", kind: "onyx.Button", content: "Feed Your Vanity", onclick: "chatterClicked"},
46 {name: "feedButton", kind: "onyx.Button", classes: "feed-button", content: "Stalk Your Victims", onclick: "feedClicked"},
47 {name: "spewButton", kind: "onyx.Button", classes: "spew-button", content: "Spew It!", onclick: "spewToggle"}
50 {name: "forgotPasswordDialog", kind: "blerg.ForgotPasswordDialog"},
51 {name: "api", kind: "blerg.API",
52 onStatus: "gotStatus"},
54 onClearNotification: "clearNotification"}
56 showRSS: function(url) {
57 this.$.rssButton.show();
59 this.$.rssButton.setAttribute('href', url);
62 this.$.rssButton.hide();
64 loggedInChanged: function() {
66 this.$.loggedOutControls.hide();
67 this.$.loggedInControls.show();
69 this.$.loggedOutControls.show();
70 this.$.loggedInControls.hide();
73 loginClicked: function(inSender, inEvent) {
74 this.bubble('onTryLogin', {
75 username: this.$.username.getValue(),
76 password: this.$.password.getValue()
78 inEvent.preventDefault();
81 loginKeyUp: function(inSender, inEvent) {
82 if (inEvent.keyCode == 13) {
83 if (this.$.username.hasFocus()) {
84 this.$.password.focus();
86 this.loginClicked(this, inEvent);
91 logoutClicked: function() {
92 this.bubble('onTryLogout');
95 login: function(inSender, inEvent) {
96 this.$.password.setValue('');
97 this.$.forgotPassword.hide();
98 // TODO: Replace with regular blur() call in future enyo
99 this.$.password.node.blur();
100 this.setLoggedIn(true);
101 this.$.userlink.setAttribute('href', '/#' + inEvent.username);
102 this.$.userlink.setContent('@' + inEvent.username);
103 this.username = inEvent.username;
106 this.feedStatusUpdateInterval = setInterval(function() {
108 }.bind(this), 900000);
110 logout: function(inSender, inEvent) {
111 this.setLoggedIn(false);
112 clearInterval(this.feedStatusUpdateInterval);
114 changePasswordClicked: function() {
115 this.bubble('onShowChangePassword');
117 spewToggle: function(inSender, inEvent) {
118 this.postShowing = !this.postShowing;
119 this.bubble('onPostVisibility', {showing: this.postShowing});
121 postVisibilityUpdate: function(inSender, inEvent) {
122 this.postShowing = inEvent.showing;
123 this.$.spewButton.addRemoveClass('active', inEvent.showing);
125 updateStatus: function() {
126 this.$.api.getStatus();
128 gotStatus: function(inSender, inEvent) {
129 if ('mentioned' in inEvent) {
130 this.$.mentionButton.addRemoveClass('new', inEvent.mentioned);
132 if ('feed_new' in inEvent) {
133 this.$.feedButton.addRemoveClass('new', inEvent.feed_new > 0);
134 if (inEvent.feed_new > 0) {
135 this.$.feedButton.setContent('Stalk Your Victims (' + inEvent.feed_new + ')');
137 this.$.feedButton.setContent('Stalk Your Victims');
141 chatterClicked: function() {
142 window.location.href = '/#/ref/' + this.username;
143 this.bubble('onNavigate');
145 feedClicked: function() {
146 window.location.href = '/#/feed';
147 this.bubble('onNavigate');
149 clearNotification: function(inSender, inEvent) {
150 if (inEvent.type == 'feed') {
151 this.gotStatus(this, {feed_new: 0});
152 } else if (inEvent.type == 'mentioned') {
153 this.gotStatus(this, {mentioned: false});
156 showForgotPasswordLink: function(inSender, inevent) {
157 this.$.forgotPassword.show();
159 popupForgotPasswordDialog: function() {
160 this.$.forgotPasswordDialog.setUsername(this.$.username.getValue());
161 this.$.forgotPasswordDialog.show();