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",
13 onShowChangePassword: "showChangePassword",
16 {classes: "blerg-header", components: [
17 {name: "title", kind: "blerg.Title"},
18 {name: "controls", kind: "blerg.Controls"},
19 {style: "clear: both;"},
20 {name: "post", kind: "blerg.Post", showing: false},
21 {name: "help", kind: "blerg.Help"}
23 {name: "main", kind: "blerg.Main"},
24 {name: "signupDialog", kind: "blerg.SignupDialog"},
25 {name: "passwdDialog", kind: "blerg.PasswdDialog"},
26 {name: "api", kind: "blerg.API",
27 onLoginSuccessful: "loginSuccessful",
28 onLoginFailed: "loginFailed",
29 onLogoutSuccessful: "logout"}
31 rendered: function() {
32 this.inherited(arguments);
34 this.lastHash = location.hash;
37 setInterval(this.hashCheck.bind(this), 250);
39 document.body.addEventListener('keyup', function(event) {
40 if (event.shiftKey && event.keyCode == 32) {
41 this.waterfall('onPostVisibility', {showing: true});
42 event.stopPropagation();
46 hashCheck: function() {
47 if (location.hash != this.lastHash) {
48 this.lastHash = location.hash;
52 urlSwitch: function() {
56 for (var i = 0; i < this.pathHandlers.length; i++) {
57 var handler = this.pathHandlers[i];
58 objdef = handler.locationDetect(window.location);
63 objdef = {classes: "blerg-error", content: "No handler found"}
65 this.$.main.updateView(objdef);
67 showSignupDialog: function() {
68 this.$.signupDialog.show();
70 setTitle: function(inSender, inEvent) {
71 this.$.title.waterfall('onSetTitle', inEvent);
73 tryLogin: function(inSender, inEvent) {
74 this.$.api.login(inEvent.username, inEvent.password);
76 tryLogout: function(inSender, inEvent) {
79 loginSuccessful: function(inSender, inEvent) {
80 this.waterfall('onLogin', inEvent);
82 loginFailed: function(inSender, inEvent) {
83 alert('Login failed');
86 logout: function(inSender, inEvent) {
87 clearInterval(this.feedStatusUpdateInterval);
88 this.waterfall('onLogout');
90 postVisibilityUpdate: function(inSender, inEvent) {
91 this.$.post.waterfall('onPostVisibility', inEvent);
92 this.$.controls.waterfall('onPostVisibility', inEvent);
94 sendReload: function() {
95 this.$.main.waterfall('onReload');
97 showChangePassword: function() {
98 this.$.passwdDialog.show();