Merge branch 'enyo-rewrite'
[blerg.git] / www / jssrc / blerg / Tag.js
1 enyo.kind({
2     name: "blerg.Tag",
3     kind: "blerg.Pager",
4     listKind: "blerg.TagRecord",
5     published: {
6         type: null,
7         tag: ""
8     },
9     components: [
10         {name: "records"},
11         {name: "spinner", kind: "OldSchoolSpinner", showing: false},
12         {name: "api", kind: "blerg.API",
13          onItemsLoaded: "itemsLoaded"}
14     ],
15     statics: {
16         locationDetect: function(l) {
17             var m = l.hash.match(/^#\/(ref|tag)\/([A-Za-z0-9_-]+)$/);
18             if (m) {
19                 return {
20                     kind: "blerg.Tag",
21                     type: m[1],
22                     tag: m[2]
23                 };
24             }
25         }
26     },
27     create: function() {
28         this.inherited(arguments);
29         this.tagChanged();
30     },
31     tagChanged: function() {
32         switch(this.type) {
33         case 'tag':
34             this.bubble('onSetTitle', {section: '#' + this.tag});
35             break;
36         case 'ref':
37             this.bubble('onSetTitle', {section: 'about @' + this.tag});
38             break;
39         }
40         this.$.records.destroyComponents();
41         this.lastRecord = null;
42         this.loadMore();
43     },
44     loadItems: function(from, to) {
45         this.inherited(arguments);
46         this.$.api.loadTagRecords(this.type, this.tag);
47     },
48     itemsLoaded: function(inSender, inEvent) {
49         this.addItems(inEvent.entries);
50     }
51 });