X-Git-Url: http://git.bytex64.net/?a=blobdiff_plain;f=www%2Fjssrc%2Fblerg%2FBlerg.js;h=827dc06e1e8fbc97786db73d2417c8f6f34511b4;hb=6eee0074c07ce85359975621ff832943d320493a;hp=a077b52d8e9fc46ab6f5cf1642d7c4959aef0c93;hpb=8f3918fbe3d812782d70af32b0d122bcd16a4c65;p=blerg.git diff --git a/www/jssrc/blerg/Blerg.js b/www/jssrc/blerg/Blerg.js index a077b52..827dc06 100644 --- a/www/jssrc/blerg/Blerg.js +++ b/www/jssrc/blerg/Blerg.js @@ -1,102 +1,104 @@ enyo.kind({ - name: "blerg.Blerg", - kind: "Control", - lastHash: null, - handlers: { - onStartSignup: "showSignupDialog", - onTryLogin: "tryLogin", - onTryLogout: "tryLogout", - onSetTitle: "setTitle", - onPostVisibility: "postVisibilityUpdate" - }, - components: [ - {classes: "blerg-header", components: [ - {name: "title", kind: "blerg.Title"}, - {name: "controls", kind: "blerg.Controls"}, - {style: "clear: both"}, - {name: "post", kind: "blerg.Post", showing: false}, - {name: "help", kind: "blerg.Help"} - ]}, - {name: "main", kind: "blerg.Main"}, - {name: "signupDialog", kind: "blerg.SignupDialog"}, - {name: "passwdDialog", kind: "blerg.PasswdDialog"}, - {name: "api", kind: "blerg.API", - onLoginSuccessful: "loginSuccessful", - onLoginFailed: "loginFailed", - onLogoutSuccessful: "logout"} - ], - urlmap: [ - ['search', /^\?post\/([^/]+)\/(.+)/, "blerg.ExternalURLPost"], - ['hash', /^#\/(ref|tag)\/([A-Za-z0-9_-]+)(?:\/p(\d+))?$/, "blerg.Tag"], - ['hash', /^#\/feed(?:\/p(\d+))?$/, "blerg.Feed"], - ['hash', /^#([A-Za-z0-9_-]+)(?:\/(p)?(\d+))?$/, "blerg.User"] - ], - pathHandlers: [ blerg.Welcome ], - rendered: function() { - this.inherited(arguments); + name: "blerg.Blerg", + kind: "Control", + lastHash: null, + pathHandlers: [ blerg.User, blerg.Tag, blerg.Feed, blerg.ExternalURLPost, blerg.Welcome ], + handlers: { + onStartSignup: "showSignupDialog", + onTryLogin: "tryLogin", + onTryLogout: "tryLogout", + onSetTitle: "setTitle", + onPostVisibility: "postVisibilityUpdate", + onReload: "sendReload", + onShowChangePassword: "showChangePassword", + onClearFeedStatus: "clearFeedStatus" + }, + components: [ + {classes: "blerg-header", components: [ + {name: "title", kind: "blerg.Title"}, + {name: "controls", kind: "blerg.Controls"}, + {style: "clear: both;"}, + {name: "post", kind: "blerg.Post", showing: false}, + {name: "help", kind: "blerg.Help"} + ]}, + {name: "main", kind: "blerg.Main"}, + {name: "signupDialog", kind: "blerg.SignupDialog"}, + {name: "passwdDialog", kind: "blerg.PasswdDialog"}, + {name: "api", kind: "blerg.API", + onLoginSuccessful: "loginSuccessful", + onLoginFailed: "loginFailed", + onLogoutSuccessful: "logout"} + ], + rendered: function() { + this.inherited(arguments); - this.lastHash = location.hash; - this.urlSwitch(); + this.lastHash = location.hash; + this.urlSwitch(); - setInterval(this.hashCheck.bind(this), 250); + setInterval(this.hashCheck.bind(this), 250); - document.body.addEventListener('keyup', function(event) { - if (event.shiftKey && event.keyCode == 32) { - this.$.post.show(); - event.stopPropagation(); - } - }, false); - }, - hashCheck: function() { - if (location.hash != this.lastHash) { - this.lastHash = location.hash; - this.urlSwitch(); - } - }, - urlSwitch: function() { - var m; - var objdef = null; + document.body.addEventListener('keyup', function(event) { + if (event.shiftKey && event.keyCode == 32) { + this.waterfall('onPostVisibility', {showing: true}); + event.stopPropagation(); + } + }.bind(this), false); + }, + hashCheck: function() { + if (location.hash != this.lastHash) { + this.lastHash = location.hash; + this.urlSwitch(); + } + }, + urlSwitch: function() { + var m; + var objdef = null; - for (var i = 0; i < this.pathHandlers.length; i++) { - var handler = this.pathHandlers[i]; - objdef = handler.locationDetect(window.location); - if (objdef) - break; - } - if (!objdef) - objdef = {classes: "blerg-error", content: "No handler found"} + for (var i = 0; i < this.pathHandlers.length; i++) { + var handler = this.pathHandlers[i]; + objdef = handler.locationDetect(window.location); + if (objdef) + break; + } + if (!objdef) + objdef = {classes: "blerg-error", content: "No handler found"} - this.$.main.updateView(objdef); - }, - showSignupDialog: function() { - this.$.signupDialog.show(); - }, - setTitle: function(inSender, inEvent) { - this.$.title.waterfall('onSetTitle', inEvent); - }, - tryLogin: function(inSender, inEvent) { - this.$.api.login(inEvent.username, inEvent.password); - }, - tryLogout: function(inSender, inEvent) { - this.$.api.logout(); - }, - loginSuccessful: function(inSender, inEvent) { - this.$.api.requestFeedStatus(); - this.feedStatusUpdateInterval = setInterval(function() { - this.$.api.requestFeedStatus(); - }.bind(this), 900000); - this.waterfall('onLogin', inEvent); - }, - loginFailed: function(inSender, inEvent) { - alert('Login failed'); - this.logout(); - }, - logout: function(inSender, inEvent) { - clearInterval(this.feedStatusUpdateInterval); - this.waterfall('onLogout'); - }, - postVisibilityUpdate: function(inSender, inEvent) { - this.$.post.waterfall('onPostVisibility', inEvent); - this.$.controls.waterfall('onPostVisibility', inEvent); - } + this.$.main.updateView(objdef); + }, + showSignupDialog: function() { + this.$.signupDialog.show(); + }, + setTitle: function(inSender, inEvent) { + this.$.title.waterfall('onSetTitle', inEvent); + }, + tryLogin: function(inSender, inEvent) { + this.$.api.login(inEvent.username, inEvent.password); + }, + tryLogout: function(inSender, inEvent) { + this.$.api.logout(); + }, + loginSuccessful: function(inSender, inEvent) { + this.waterfall('onLogin', inEvent); + }, + loginFailed: function(inSender, inEvent) { + alert('Login failed'); + this.logout(); + }, + logout: function(inSender, inEvent) { + clearInterval(this.feedStatusUpdateInterval); + this.waterfall('onLogout'); + }, + postVisibilityUpdate: function(inSender, inEvent) { + this.$.post.waterfall('onPostVisibility', inEvent); + this.$.controls.waterfall('onPostVisibility', inEvent); + }, + sendReload: function() { + this.$.main.waterfall('onReload'); + }, + showChangePassword: function() { + this.$.passwdDialog.show(); + }, + clearFeedStatus: function() { + this.$.controls.waterfall('onClearFeedStatus'); + } });