X-Git-Url: http://git.bytex64.net/?a=blobdiff_plain;f=www%2Fjssrc%2Fblerg%2FControls.js;h=eb3275c5d3732095dace10c0d5399b316b9664bb;hb=6d8bbc2417758f3613bf77766fc6ee3d570d8277;hp=529df1e1f64326462621e0d7aeff230de0c90829;hpb=6eee0074c07ce85359975621ff832943d320493a;p=blerg.git diff --git a/www/jssrc/blerg/Controls.js b/www/jssrc/blerg/Controls.js index 529df1e..eb3275c 100644 --- a/www/jssrc/blerg/Controls.js +++ b/www/jssrc/blerg/Controls.js @@ -10,12 +10,11 @@ enyo.kind({ handlers: { onLogin: "login", onLogout: "logout", - onPostVisibility: "postVisibilityUpdate", - onClearFeedStatus: "clearFeedStatus" + onPostVisibility: "postVisibilityUpdate" }, 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}} @@ -28,7 +27,7 @@ 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: ". "}, @@ -39,13 +38,15 @@ enyo.kind({ {tag: null, content: "."} ]}, {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(); @@ -72,20 +73,32 @@ 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.updateFeedInfo(); + this.updateStatus(); this.feedStatusUpdateInterval = setInterval(function() { - this.updateFeedInfo(); + this.updateStatus(); }.bind(this), 900000); }, logout: function(inSender, inEvent) { @@ -103,15 +116,20 @@ enyo.kind({ this.postShowing = inEvent.showing; this.$.spewButton.addRemoveClass('active', inEvent.showing); }, - updateFeedInfo: function() { - this.$.api.getFeedInfo(); + updateStatus: function() { + this.$.api.getStatus(); }, - 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'); + 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() { @@ -122,7 +140,11 @@ enyo.kind({ window.location.href = '/#/feed'; this.bubble('onNavigate'); }, - clearFeedStatus: function() { - this.gotFeedInfo(this, {new: 0}); + clearNotification: function(inSender, inEvent) { + if (inEvent.type == 'feed') { + this.gotStatus(this, {feed_new: 0}); + } else if (inEvent.type == 'mentioned') { + this.gotStatus(this, {mentioned: false}); + } } });