Whoops, forgot to add the Tag kind
authorChip Black <bytex64@bytex64.net>
Tue, 24 Apr 2012 03:04:59 +0000 (20:04 -0700)
committerChip Black <bytex64@bytex64.net>
Tue, 24 Apr 2012 03:04:59 +0000 (20:04 -0700)
www/jssrc/blerg/Tag.js [new file with mode: 0644]

diff --git a/www/jssrc/blerg/Tag.js b/www/jssrc/blerg/Tag.js
new file mode 100644 (file)
index 0000000..d885481
--- /dev/null
@@ -0,0 +1,50 @@
+enyo.kind({
+    name: "blerg.Tag",
+    kind: "blerg.Pager",
+    listKind: "blerg.TagRecord",
+    published: {
+        type: null,
+        tag: ""
+    },
+    components: [
+        {name: "records"},
+        {name: "api", kind: "blerg.API",
+         onItemsLoaded: "itemsLoaded"}
+    ],
+    statics: {
+        locationDetect: function(l) {
+            var m = l.hash.match(/^#\/(ref|tag)\/([A-Za-z0-9_-]+)$/);
+            if (m) {
+                return {
+                    kind: "blerg.Tag",
+                    type: m[1],
+                    tag: m[2]
+                };
+            }
+        }
+    },
+    create: function() {
+        this.inherited(arguments);
+        this.tagChanged();
+    },
+    tagChanged: function() {
+        switch(this.type) {
+        case 'tag':
+            this.bubble('onSetTitle', {section: '#' + this.tag});
+            break;
+        case 'ref':
+            this.bubble('onSetTitle', {section: 'about @' + this.tag});
+            break;
+        }
+        this.$.records.destroyComponents();
+        this.lastRecord = null;
+        this.loadMore();
+    },
+    loadItems: function(from, to) {
+        this.inherited(arguments);
+        this.$.api.loadTagRecords(this.type, this.tag);
+    },
+    itemsLoaded: function(inSender, inEvent) {
+        this.addItems(inEvent.entries);
+    }
+});