1 // Listen for onsubmit events
2 enyo.dispatcher.listen(document, "submit");
8 pathHandlers: [ blerg.User, blerg.Tag, blerg.Feed, blerg.ExternalURLPost, blerg.Welcome ],
10 onStartSignup: "showSignupDialog",
11 onTryLogin: "tryLogin",
12 onTryLogout: "tryLogout",
13 onSetTitle: "setTitle",
14 onPostVisibility: "postVisibilityUpdate",
15 onReload: "sendReload",
16 onShowChangePassword: "showChangePassword",
17 onClearFeedStatus: "clearFeedStatus"
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: "passwdDialog", kind: "blerg.PasswdDialog"},
30 {name: "api", kind: "blerg.API",
31 onLoginSuccessful: "loginSuccessful",
32 onLoginFailed: "loginFailed",
33 onLogoutSuccessful: "logout"}
35 rendered: function() {
36 this.inherited(arguments);
38 this.lastHash = location.hash;
41 setInterval(this.hashCheck.bind(this), 250);
43 document.body.addEventListener('keyup', function(event) {
44 if (event.shiftKey && event.keyCode == 32) {
45 this.waterfall('onPostVisibility', {showing: true});
46 event.stopPropagation();
50 hashCheck: function() {
51 if (location.hash != this.lastHash) {
52 this.lastHash = location.hash;
56 urlSwitch: function() {
60 for (var i = 0; i < this.pathHandlers.length; i++) {
61 var handler = this.pathHandlers[i];
62 objdef = handler.locationDetect(window.location);
67 objdef = {classes: "blerg-error", content: "No handler found"}
69 this.$.main.updateView(objdef);
71 showSignupDialog: function() {
72 this.$.signupDialog.show();
74 setTitle: function(inSender, inEvent) {
75 this.$.title.waterfall('onSetTitle', inEvent);
77 tryLogin: function(inSender, inEvent) {
78 this.$.api.login(inEvent.username, inEvent.password);
80 tryLogout: function(inSender, inEvent) {
83 loginSuccessful: function(inSender, inEvent) {
84 this.waterfall('onLogin', inEvent);
86 loginFailed: function(inSender, inEvent) {
87 alert('Login failed');
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 showChangePassword: function() {
102 this.$.passwdDialog.show();
104 clearFeedStatus: function() {
105 this.$.controls.waterfall('onClearFeedStatus');