X-Git-Url: http://git.bytex64.net/?a=blobdiff_plain;f=www%2Fjssrc%2Fblerg%2FControls.js;h=abd43ea424d2be7a80a494f5845c77352609660a;hb=848df2d1d186a30c4f1dc0401e6911d2230b3c63;hp=480e5520ffe8fd4090acd37c760d8eba0edc4fc9;hpb=3e5f69d01b9488475413d4ecce8161ab7a889ca2;p=blerg.git diff --git a/www/jssrc/blerg/Controls.js b/www/jssrc/blerg/Controls.js index 480e552..abd43ea 100644 --- a/www/jssrc/blerg/Controls.js +++ b/www/jssrc/blerg/Controls.js @@ -14,7 +14,7 @@ enyo.kind({ }, components: [ {name: "loggedOutControls", components: [ - {tag: "form", onsubmit: "loginClicked", classes: "login", components: [ + {tag: "form", onkeyup: "loginKeyUp", classes: "login", components: [ {kind: "onyx.Groupbox", components: [ {kind: "onyx.InputDecorator", components: [ {name: "username", kind: "onyx.Input", placeholder: "Username", attributes: {tabindex: 1}} @@ -27,27 +27,26 @@ enyo.kind({ ]} ]}, {name: "loggedInControls", showing: false, components: [ - {name: "greeting", components: [ + {name: "greeting", classes: "blerg-controls-greeting", components: [ {tag: null, content: "Hello, "}, {name: "userlink", tag: "a"}, {tag: null, content: ". "}, {kind: "blerg.Link", content: "Logout", onNavigate: "logoutClicked"}, + {tag: null, content: "."}, + {tag: "br"}, + {kind: "blerg.Link", content: "Account Center", href: '/#/account'}, {tag: null, content: "."} ]}, - {components: [ - {name: "rssButton", kind: "blerg.Link", showing: false, components: [ - {kind: "Image", src: "/images/rss.png", width: 16, height: 16}, - {tag: null, content: " RSS"} - ]} - ]}, {classes: "blerg-controls-toolbar", components: [ - {kind: "onyx.Button", content: "Feed Your Vanity", onclick: "chatterClicked"}, + {name: "mentionButton", kind: "onyx.Button", content: "Feed Your Vanity", onclick: "chatterClicked"}, {name: "feedButton", kind: "onyx.Button", classes: "feed-button", content: "Stalk Your Victims", onclick: "feedClicked"}, {name: "spewButton", kind: "onyx.Button", classes: "spew-button", content: "Spew It!", onclick: "spewToggle"} ]}, ]}, {name: "api", kind: "blerg.API", - onFeedInfo: "gotFeedInfo"} + onStatus: "gotStatus"}, + {kind: "Signals", + onClearNotification: "clearNotification"} ], showRSS: function(url) { this.$.rssButton.show(); @@ -74,26 +73,41 @@ enyo.kind({ inEvent.preventDefault(); return true; }, + loginKeyUp: function(inSender, inEvent) { + if (inEvent.keyCode == 13) { + if (this.$.username.hasFocus()) { + this.$.password.focus(); + } else { + this.loginClicked(this, inEvent); + } + return true; + } + }, logoutClicked: function() { this.bubble('onTryLogout'); return true; }, login: function(inSender, inEvent) { this.$.password.setValue(''); + // TODO: Replace with regular blur() call in future enyo + this.$.password.node.blur(); this.setLoggedIn(true); this.$.userlink.setAttribute('href', '/#' + inEvent.username); this.$.userlink.setContent('@' + inEvent.username); this.username = inEvent.username; - this.$.api.getFeedInfo(); + this.updateStatus(); this.feedStatusUpdateInterval = setInterval(function() { - this.$.api.getFeedInfo(); + this.updateStatus(); }.bind(this), 900000); }, logout: function(inSender, inEvent) { this.setLoggedIn(false); clearInterval(this.feedStatusUpdateInterval); }, + changePasswordClicked: function() { + this.bubble('onShowChangePassword'); + }, spewToggle: function(inSender, inEvent) { this.postShowing = !this.postShowing; this.bubble('onPostVisibility', {showing: this.postShowing}); @@ -102,12 +116,20 @@ enyo.kind({ this.postShowing = inEvent.showing; this.$.spewButton.addRemoveClass('active', inEvent.showing); }, - gotFeedInfo: function(inSender, inEvent) { - this.$.feedButton.addRemoveClass('new', inEvent.new > 0); - if (inEvent.new > 0) { - this.$.feedButton.setContent('Stalk Your Victims (' + inEvent.new + ')'); - } else { - this.$.feedButton.setContent('Stalk Your Victims'); + updateStatus: function() { + this.$.api.getStatus(); + }, + gotStatus: function(inSender, inEvent) { + if ('mentioned' in inEvent) { + this.$.mentionButton.addRemoveClass('new', inEvent.mentioned); + } + if ('feed_new' in inEvent) { + this.$.feedButton.addRemoveClass('new', inEvent.feed_new > 0); + if (inEvent.feed_new > 0) { + this.$.feedButton.setContent('Stalk Your Victims (' + inEvent.feed_new + ')'); + } else { + this.$.feedButton.setContent('Stalk Your Victims'); + } } }, chatterClicked: function() { @@ -117,5 +139,12 @@ enyo.kind({ feedClicked: function() { window.location.href = '/#/feed'; this.bubble('onNavigate'); + }, + clearNotification: function(inSender, inEvent) { + if (inEvent.type == 'feed') { + this.gotStatus(this, {feed_new: 0}); + } else if (inEvent.type == 'mentioned') { + this.gotStatus(this, {mentioned: false}); + } } });