/www/jssrc/blerg/Tag.js
enyo.kind({
name: "blerg.Tag",
kind: "blerg.Pager",
listKind: "blerg.TagRecord",
published: {
type: null,
tag: ""
},
components: [
{classes: "blerg-user-controls", components: [
{name: "rssLink", kind: "blerg.Link", components: [
{tag: null, content: "["},
{kind: "Image", src: "/images/rss.png", attributes: {width: 16, height: 16}},
{tag: null, content: "RSS]"}
]}
]},
{name: "records"},
{name: "spinner", kind: "OldSchoolSpinner", showing: false},
{name: "api", kind: "blerg.API",
onItemsLoaded: "itemsLoaded",
onClearStatus: "clearStatus"}
],
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.$.rssLink.setHref('/rss/' + this.type + '/' + this.tag);
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);
if (this.type == 'ref' && blerg.API.loggedIn && blerg.API.username == this.tag) {
this.$.api.clearStatus('mentioned');
}
},
clearStatus: function(inSender, inEvent) {
if (inEvent.type == 'mentioned' && inEvent.status == 'success') {
enyo.Signals.send('onClearNotification', {type: inEvent.type});
}
}
});