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: "emptyAccountMessage", showing: false, content: "Hey, there's nothing here!"},
28 {name: "userNotFoundMessage", classes: "blerg-error", showing: false, content: "User not found"},
29 {name: "loadMoreButton", kind: "onyx.Button", onclick: "loadMore", content: "Load More"},
30 {name: "api", kind: "blerg.API",
31 onItemsLoaded: "itemsLoaded",
32 onUserNotFound: "userNotFound",
33 onAPIError: "apiError",
34 onSubscriptionStatus: "gotStalkStatus"}
37 locationDetect: function(l) {
38 var m = l.hash.match(/^#([A-Za-z0-9_-]+)(?:\/(\d+))?$/);
43 permalink: m[2] != undefined,
44 record: parseInt(m[2])
50 this.inherited(arguments);
51 this.usernameChanged();
53 usernameChanged: function() {
54 this.bubble('onSetTitle', {section: '@' + this.username});
55 this.$.records.destroyComponents();
56 this.lastRecord = null;
57 this.$.loadMoreButton.hide();
58 this.$.chatterLink.setHref('/#/ref/' + this.username);
59 this.$.rssLink.setHref('/rss/' + this.username);
60 this.getStalkStatus();
63 this.loadItems(this.record, this.record);
68 loadItems: function(from, to) {
69 this.inherited(arguments);
70 this.$.api.loadUserRecords(this.username, from, to);
72 itemsLoaded: function(inSender, inEvent) {
73 this.$.userNotFoundMessage.hide();
75 this.$.loadMoreButton.hide();
77 this.$.loadMoreButton.show();
80 for (var i = 0; i < inEvent.entries.length; i++) {
81 inEvent.entries[i].author = this.username;
84 this.addItems(inEvent.entries);
85 if (this.lastRecord == 0 || inEvent.entries.length == 0)
86 this.$.loadMoreButton.hide();
88 addItems: function(items) {
89 this.$.emptyAccountMessage.setShowing(items.length == 0);
90 this.inherited(arguments);
92 userNotFound: function() {
94 this.$.emptyAccountMessage.hide();
95 this.$.userNotFoundMessage.show();
97 apiError: function() {
99 alert('Unknown API Error');
101 getStalkStatus: function() {
102 if (!blerg.API.loggedIn) {
103 this.$.stalkLink.hide();
104 this.$.unstalkLink.hide();
107 this.$.api.getSubscriptionStatus(this.username);
109 gotStalkStatus: function(inSender, inEvent) {
110 if (inEvent.subscribed) {
111 this.$.stalkLink.hide();
112 this.$.unstalkLink.show();
114 this.$.stalkLink.show();
115 this.$.unstalkLink.hide();
118 startStalking: function() {
119 this.$.api.subscribe(this.username);
121 stopStalking: function() {
122 this.$.api.unsubscribe(this.username);