5 pathHandlers: [ blerg.User, blerg.Tag, blerg.Feed, blerg.ExternalURLPost, blerg.Welcome ],
7 onStartSignup: "showSignupDialog",
8 onTryLogin: "tryLogin",
9 onTryLogout: "tryLogout",
10 onSetTitle: "setTitle",
11 onPostVisibility: "postVisibilityUpdate",
12 onReload: "sendReload"
15 {classes: "blerg-header", components: [
16 {name: "title", kind: "blerg.Title"},
17 {name: "controls", kind: "blerg.Controls"},
18 {style: "clear: both;"},
19 {name: "post", kind: "blerg.Post", showing: false},
20 {name: "help", kind: "blerg.Help"}
22 {name: "main", kind: "blerg.Main"},
23 {name: "signupDialog", kind: "blerg.SignupDialog"},
24 {name: "passwdDialog", kind: "blerg.PasswdDialog"},
25 {name: "api", kind: "blerg.API",
26 onLoginSuccessful: "loginSuccessful",
27 onLoginFailed: "loginFailed",
28 onLogoutSuccessful: "logout"}
30 rendered: function() {
31 this.inherited(arguments);
33 this.lastHash = location.hash;
36 setInterval(this.hashCheck.bind(this), 250);
38 document.body.addEventListener('keyup', function(event) {
39 if (event.shiftKey && event.keyCode == 32) {
40 this.waterfall('onPostVisibility', {showing: true});
41 event.stopPropagation();
45 hashCheck: function() {
46 if (location.hash != this.lastHash) {
47 this.lastHash = location.hash;
51 urlSwitch: function() {
55 for (var i = 0; i < this.pathHandlers.length; i++) {
56 var handler = this.pathHandlers[i];
57 objdef = handler.locationDetect(window.location);
62 objdef = {classes: "blerg-error", content: "No handler found"}
64 this.$.main.updateView(objdef);
66 showSignupDialog: function() {
67 this.$.signupDialog.show();
69 setTitle: function(inSender, inEvent) {
70 this.$.title.waterfall('onSetTitle', inEvent);
72 tryLogin: function(inSender, inEvent) {
73 this.$.api.login(inEvent.username, inEvent.password);
75 tryLogout: function(inSender, inEvent) {
78 loginSuccessful: function(inSender, inEvent) {
79 this.waterfall('onLogin', inEvent);
81 loginFailed: function(inSender, inEvent) {
82 alert('Login failed');
85 logout: function(inSender, inEvent) {
86 clearInterval(this.feedStatusUpdateInterval);
87 this.waterfall('onLogout');
89 postVisibilityUpdate: function(inSender, inEvent) {
90 this.$.post.waterfall('onPostVisibility', inEvent);
91 this.$.controls.waterfall('onPostVisibility', inEvent);
93 sendReload: function() {
94 this.$.main.waterfall('onReload');