4 listKind: "blerg.Record",
6 onLogin: "getStalkStatus",
7 onLogout: "getStalkStatus"
15 {classes: "blerg-user-controls", components: [
16 {name: "chatterLink", kind: "blerg.Link", content: "[chatter]"},
17 {name: "stalkLink", kind: "blerg.Link", content: "[stalk]", showing: false, onNavigate: "startStalking"},
18 {name: "unstalkLink", kind: "blerg.Link", content: "[stop stalking]", showing: false, onNavigate: "stopStalking"},
19 {name: "rssLink", kind: "blerg.Link", components: [
20 {noDom: true, content: "["},
21 {kind: "Image", src: "/images/rss.png", attributes: {width: 16, height: 16}},
22 {noDom: true, content: "RSS]"}
26 {name: "loadMoreButton", kind: "onyx.Button", onclick: "loadMore", content: "Load More"},
27 {name: "api", kind: "blerg.API",
28 onItemsLoaded: "itemsLoaded",
29 onSubscriptionStatus: "gotStalkStatus"}
32 locationDetect: function(l) {
33 var m = l.hash.match(/^#([A-Za-z0-9_-]+)(?:\/(\d+))?$/);
38 permalink: m[2] != undefined,
39 record: parseInt(m[2])
45 this.inherited(arguments);
46 this.usernameChanged();
48 usernameChanged: function() {
49 this.bubble('onSetTitle', {section: '@' + this.username});
50 this.$.records.destroyComponents();
51 this.lastRecord = null;
52 this.$.loadMoreButton.hide();
53 this.$.chatterLink.setHref('/#/ref/' + this.username);
54 this.$.rssLink.setHref('/rss/' + this.username);
55 this.getStalkStatus();
58 this.loadItems(this.record, this.record);
63 loadItems: function(from, to) {
64 this.inherited(arguments);
65 this.$.api.loadUserRecords(this.username, from, to);
67 itemsLoaded: function(inSender, inEvent) {
69 this.$.loadMoreButton.hide();
71 this.$.loadMoreButton.show();
74 for (var i = 0; i < inEvent.entries.length; i++) {
75 inEvent.entries[i].author = this.username;
78 this.addItems(inEvent.entries);
79 if (this.lastRecord == 0)
80 this.$.loadMoreButton.hide();
82 getStalkStatus: function() {
83 if (!blerg.API.loggedIn) {
84 this.$.stalkLink.hide();
85 this.$.unstalkLink.hide();
88 this.$.api.getSubscriptionStatus(this.username);
90 gotStalkStatus: function(inSender, inEvent) {
91 if (inEvent.subscribed) {
92 this.$.stalkLink.hide();
93 this.$.unstalkLink.show();
95 this.$.stalkLink.show();
96 this.$.unstalkLink.hide();
99 startStalking: function() {
100 this.$.api.subscribe(this.username);
102 stopStalking: function() {
103 this.$.api.unsubscribe(this.username);