1 // Listen for onsubmit events
2 enyo.dispatcher.listen(document, "submit");
8 pathHandlers: [ blerg.User, blerg.Tag, blerg.Feed, blerg.ExternalURLPost, blerg.Welcome, blerg.AccountCenter, blerg.Recovery, blerg.EmailVerify ],
10 onStartSignup: "showSignupDialog",
11 onTryLogin: "tryLogin",
12 onTryLogout: "tryLogout",
13 onSetTitle: "setTitle",
14 onPostVisibility: "postVisibilityUpdate",
15 onReload: "sendReload",
16 onShowChangePassword: "showChangePassword",
17 onAuthFailure: "authFailure"
20 {classes: "blerg-header", components: [
21 {name: "title", kind: "blerg.Title"},
22 {name: "controls", kind: "blerg.Controls"},
23 {style: "clear: both;"},
24 {name: "post", kind: "blerg.Post", showing: false},
25 {name: "help", kind: "blerg.Help"}
27 {name: "main", kind: "blerg.Main"},
28 {name: "signupDialog", kind: "blerg.SignupDialog"},
29 {name: "api", kind: "blerg.API",
30 onLoginSuccessful: "loginSuccessful",
31 onLoginFailed: "loginFailed",
32 onLogoutSuccessful: "logout"}
34 rendered: function() {
35 this.inherited(arguments);
37 this.lastHash = location.hash;
40 setInterval(this.hashCheck.bind(this), 250);
42 document.body.addEventListener('keyup', function(event) {
43 if (event.shiftKey && event.keyCode == 32) {
44 this.waterfall('onPostVisibility', {showing: true});
45 event.stopPropagation();
49 hashCheck: function() {
50 if (location.hash != this.lastHash) {
51 this.lastHash = location.hash;
55 urlSwitch: function() {
59 for (var i = 0; i < this.pathHandlers.length; i++) {
60 var handler = this.pathHandlers[i];
61 objdef = handler.locationDetect(window.location);
66 objdef = {classes: "blerg-error", content: "No handler found"}
68 this.$.main.updateView(objdef);
70 showSignupDialog: function() {
71 this.$.signupDialog.show();
73 setTitle: function(inSender, inEvent) {
74 this.$.title.waterfall('onSetTitle', inEvent);
76 tryLogin: function(inSender, inEvent) {
77 this.$.api.login(inEvent.username, inEvent.password);
79 tryLogout: function(inSender, inEvent) {
82 loginSuccessful: function(inSender, inEvent) {
83 this.waterfall('onLogin', inEvent);
85 loginFailed: function(inSender, inEvent) {
86 alert('Login failed');
87 this.waterfall('onShowForgotPasswordLink');
90 logout: function(inSender, inEvent) {
91 clearInterval(this.feedStatusUpdateInterval);
92 this.waterfall('onLogout');
94 postVisibilityUpdate: function(inSender, inEvent) {
95 this.$.post.waterfall('onPostVisibility', inEvent);
96 this.$.controls.waterfall('onPostVisibility', inEvent);
98 sendReload: function() {
99 this.$.main.waterfall('onReload');
101 authFailure: function(inSender, inEvent) {