4 listKind: "blerg.Record",
6 onLogin: "getStalkStatus",
7 onLogout: "getStalkStatus",
8 onReload: "usernameChanged"
16 {classes: "blerg-user-controls", components: [
17 {name: "chatterLink", kind: "blerg.Link", content: "[chatter]"},
18 {name: "stalkLink", kind: "blerg.Link", content: "[stalk]", showing: false, onNavigate: "startStalking"},
19 {name: "unstalkLink", kind: "blerg.Link", content: "[stop stalking]", showing: false, onNavigate: "stopStalking"},
20 {name: "rssLink", kind: "blerg.Link", components: [
21 {noDom: true, content: "["},
22 {kind: "Image", src: "/images/rss.png", attributes: {width: 16, height: 16}},
23 {noDom: true, content: "RSS]"}
27 {name: "spinner", kind: "OldSchoolSpinner", showing: false},
28 {name: "emptyAccountMessage", showing: false, content: "Hey, there's nothing here!"},
29 {name: "userNotFoundMessage", classes: "blerg-error", showing: false, content: "User not found"},
30 {name: "loadMoreButton", kind: "onyx.Button", onclick: "loadMore", content: "Load More"},
31 {name: "api", kind: "blerg.API",
32 onItemsLoaded: "itemsLoaded",
33 onUserNotFound: "userNotFound",
34 onAPIError: "apiError",
35 onSubscriptionStatus: "gotStalkStatus"}
38 locationDetect: function(l) {
39 var m = l.hash.match(/^#([A-Za-z0-9_-]+)(?:\/(\d+))?$/);
44 permalink: m[2] != undefined,
45 record: parseInt(m[2])
51 this.inherited(arguments);
52 this.usernameChanged();
54 usernameChanged: function() {
55 this.bubble('onSetTitle', {section: '@' + this.username});
56 this.$.records.destroyComponents();
57 this.lastRecord = null;
58 this.$.loadMoreButton.hide();
59 this.$.chatterLink.setHref('/#/ref/' + this.username);
60 this.$.rssLink.setHref('/rss/' + this.username);
61 this.getStalkStatus();
64 this.loadItems(this.record, this.record);
69 loadItems: function(from, to) {
70 this.inherited(arguments);
71 this.$.api.loadUserRecords(this.username, from, to);
73 itemsLoaded: function(inSender, inEvent) {
74 this.$.userNotFoundMessage.hide();
76 this.$.loadMoreButton.hide();
78 this.$.loadMoreButton.show();
81 for (var i = 0; i < inEvent.entries.length; i++) {
82 inEvent.entries[i].author = this.username;
85 this.addItems(inEvent.entries);
86 if (this.lastRecord == 0 || inEvent.entries.length == 0)
87 this.$.loadMoreButton.hide();
89 addItems: function(items) {
90 this.$.emptyAccountMessage.setShowing(items.length == 0);
91 this.inherited(arguments);
93 userNotFound: function() {
95 this.$.emptyAccountMessage.hide();
96 this.$.userNotFoundMessage.show();
98 apiError: function() {
100 alert('Unknown API Error');
102 getStalkStatus: function() {
103 if (!blerg.API.loggedIn) {
104 this.$.stalkLink.hide();
105 this.$.unstalkLink.hide();
108 this.$.api.getSubscriptionStatus(this.username);
110 gotStalkStatus: function(inSender, inEvent) {
111 if (inEvent.subscribed) {
112 this.$.stalkLink.hide();
113 this.$.unstalkLink.show();
115 this.$.stalkLink.show();
116 this.$.unstalkLink.hide();
119 startStalking: function() {
120 this.$.api.subscribe(this.username);
122 stopStalking: function() {
123 this.$.api.unsubscribe(this.username);