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: "spinner", kind: "OldSchoolSpinner", showing: false},
27 {name: "loadMoreButton", kind: "onyx.Button", onclick: "loadMore", content: "Load More"},
28 {name: "api", kind: "blerg.API",
29 onItemsLoaded: "itemsLoaded",
30 onSubscriptionStatus: "gotStalkStatus"}
33 locationDetect: function(l) {
34 var m = l.hash.match(/^#([A-Za-z0-9_-]+)(?:\/(\d+))?$/);
39 permalink: m[2] != undefined,
40 record: parseInt(m[2])
46 this.inherited(arguments);
47 this.usernameChanged();
49 usernameChanged: function() {
50 this.bubble('onSetTitle', {section: '@' + this.username});
51 this.$.records.destroyComponents();
52 this.lastRecord = null;
53 this.$.loadMoreButton.hide();
54 this.$.chatterLink.setHref('/#/ref/' + this.username);
55 this.$.rssLink.setHref('/rss/' + this.username);
56 this.getStalkStatus();
59 this.loadItems(this.record, this.record);
64 loadItems: function(from, to) {
65 this.inherited(arguments);
66 this.$.api.loadUserRecords(this.username, from, to);
68 itemsLoaded: function(inSender, inEvent) {
70 this.$.loadMoreButton.hide();
72 this.$.loadMoreButton.show();
75 for (var i = 0; i < inEvent.entries.length; i++) {
76 inEvent.entries[i].author = this.username;
79 this.addItems(inEvent.entries);
80 if (this.lastRecord == 0)
81 this.$.loadMoreButton.hide();
83 getStalkStatus: function() {
84 if (!blerg.API.loggedIn) {
85 this.$.stalkLink.hide();
86 this.$.unstalkLink.hide();
89 this.$.api.getSubscriptionStatus(this.username);
91 gotStalkStatus: function(inSender, inEvent) {
92 if (inEvent.subscribed) {
93 this.$.stalkLink.hide();
94 this.$.unstalkLink.show();
96 this.$.stalkLink.show();
97 this.$.unstalkLink.hide();
100 startStalking: function() {
101 this.$.api.subscribe(this.username);
103 stopStalking: function() {
104 this.$.api.unsubscribe(this.username);