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"
19 {classes: "blerg-header", components: [
20 {name: "title", kind: "blerg.Title"},
21 {name: "controls", kind: "blerg.Controls"},
22 {style: "clear: both;"},
23 {name: "post", kind: "blerg.Post", showing: false},
24 {name: "help", kind: "blerg.Help"}
26 {name: "main", kind: "blerg.Main"},
27 {name: "signupDialog", kind: "blerg.SignupDialog"},
28 {name: "passwdDialog", kind: "blerg.PasswdDialog"},
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');
89 logout: function(inSender, inEvent) {
90 clearInterval(this.feedStatusUpdateInterval);
91 this.waterfall('onLogout');
93 postVisibilityUpdate: function(inSender, inEvent) {
94 this.$.post.waterfall('onPostVisibility', inEvent);
95 this.$.controls.waterfall('onPostVisibility', inEvent);
97 sendReload: function() {
98 this.$.main.waterfall('onReload');
100 showChangePassword: function() {
101 this.$.passwdDialog.show();