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",
14 onClearFeedStatus: "clearFeedStatus"
17 {classes: "blerg-header", components: [
18 {name: "title", kind: "blerg.Title"},
19 {name: "controls", kind: "blerg.Controls"},
20 {style: "clear: both;"},
21 {name: "post", kind: "blerg.Post", showing: false},
22 {name: "help", kind: "blerg.Help"}
24 {name: "main", kind: "blerg.Main"},
25 {name: "signupDialog", kind: "blerg.SignupDialog"},
26 {name: "passwdDialog", kind: "blerg.PasswdDialog"},
27 {name: "api", kind: "blerg.API",
28 onLoginSuccessful: "loginSuccessful",
29 onLoginFailed: "loginFailed",
30 onLogoutSuccessful: "logout"}
32 rendered: function() {
33 this.inherited(arguments);
35 this.lastHash = location.hash;
38 setInterval(this.hashCheck.bind(this), 250);
40 document.body.addEventListener('keyup', function(event) {
41 if (event.shiftKey && event.keyCode == 32) {
42 this.waterfall('onPostVisibility', {showing: true});
43 event.stopPropagation();
47 hashCheck: function() {
48 if (location.hash != this.lastHash) {
49 this.lastHash = location.hash;
53 urlSwitch: function() {
57 for (var i = 0; i < this.pathHandlers.length; i++) {
58 var handler = this.pathHandlers[i];
59 objdef = handler.locationDetect(window.location);
64 objdef = {classes: "blerg-error", content: "No handler found"}
66 this.$.main.updateView(objdef);
68 showSignupDialog: function() {
69 this.$.signupDialog.show();
71 setTitle: function(inSender, inEvent) {
72 this.$.title.waterfall('onSetTitle', inEvent);
74 tryLogin: function(inSender, inEvent) {
75 this.$.api.login(inEvent.username, inEvent.password);
77 tryLogout: function(inSender, inEvent) {
80 loginSuccessful: function(inSender, inEvent) {
81 this.waterfall('onLogin', inEvent);
83 loginFailed: function(inSender, inEvent) {
84 alert('Login failed');
87 logout: function(inSender, inEvent) {
88 clearInterval(this.feedStatusUpdateInterval);
89 this.waterfall('onLogout');
91 postVisibilityUpdate: function(inSender, inEvent) {
92 this.$.post.waterfall('onPostVisibility', inEvent);
93 this.$.controls.waterfall('onPostVisibility', inEvent);
95 sendReload: function() {
96 this.$.main.waterfall('onReload');
98 showChangePassword: function() {
99 this.$.passwdDialog.show();
101 clearFeedStatus: function() {
102 this.$.controls.waterfall('onClearFeedStatus');