+enyo.kind({
+ name: "blerg.Blerg",
+ kind: "Control",
+ lastHash: null,
+ handlers: {
+ onStartSignup: "showSignupDialog",
+ onTryLogin: "tryLogin",
+ onSetTitle: "setTitle"
+ },
+ components: [
+ {classes: "blerg-header", components: [
+ {kind: "blerg.Title"},
+ {kind: "blerg.Controls"},
+ {style: "clear: both"},
+ {name: "post", kind: "blerg.Post", showing: false},
+ {name: "help", kind: "blerg.Help"}
+ ]},
+ {name: "main", kind: "blerg.Main"},
+ {name: "signupDialog", kind: "blerg.SignupDialog"},
+ {name: "passwdDialog", kind: "blerg.PasswdDialog"}
+ ],
+ urlmap: [
+ ['search', /^\?post\/([^/]+)\/(.+)/, "blerg.ExternalURLPost"],
+ ['hash', /^#\/(ref|tag)\/([A-Za-z0-9_-]+)(?:\/p(\d+))?$/, "blerg.Tag"],
+ ['hash', /^#\/feed(?:\/p(\d+))?$/, "blerg.Feed"],
+ ['hash', /^#([A-Za-z0-9_-]+)(?:\/(p)?(\d+))?$/, "blerg.User"]
+ ],
+ pathHandlers: [ blerg.Welcome ],
+ rendered: function() {
+ this.inherited(arguments);
+
+ this.lastHash = location.hash;
+ this.urlSwitch();
+
+ //setInterval(this.hashCheck.bind(this), 250);
+
+ document.body.addEventListener('keyup', function(event) {
+ if (event.shiftKey && event.keyCode == 32) {
+ this.$.post.show();
+ event.stopPropagation();
+ }
+ }, false);
+ },
+ hashCheck: function() {
+ if (location.hash != this.lastHash) {
+ this.lastHash = location.hash;
+ this.urlSwitch();
+ }
+ },
+ urlSwitch: function() {
+ var m;
+ var objdef = null;
+
+ for (var i = 0; i < this.pathHandlers.length; i++) {
+ var handler = this.pathHandlers[i];
+ objdef = handler.locationDetect(window.location);
+ if (objdef)
+ break;
+ }
+ if (!objdef)
+ objdef = {classes: "blerg-error", content: "No handler found"}
+
+ this.$.main.updateView(objdef);
+ },
+ showSignupDialog: function() {
+ this.$.signupDialog.show();
+ },
+ setTitle: function(inSender, inEvent) {
+ if (inEvent.section != undefined)
+ this.$.title.setSection(inEvent.section);
+
+ if (inEvent.subscribed != undefined)
+ this.$.title.setSubscribed(inEvent.subscribed);
+
+ if (inEvent.showControls)
+ this.$.title.showControls()
+ else
+ this.$.title.hideControls();
+ },
+ tryLogin: function(inSender, inEvent) {
+ }
+});