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 {tag: null, content: "["},
22 {kind: "Image", src: "/images/rss.png", attributes: {width: 16, height: 16}},
23 {tag: null, 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.$.loadMoreButton.hide();
72 this.$.api.loadUserRecords(this.username, from, to);
74 itemsLoaded: function(inSender, inEvent) {
75 this.$.userNotFoundMessage.hide();
77 this.$.loadMoreButton.hide();
79 this.$.loadMoreButton.show();
82 for (var i = 0; i < inEvent.entries.length; i++) {
83 inEvent.entries[i].author = this.username;
86 this.addItems(inEvent.entries);
87 if (this.lastRecord == 0 || inEvent.entries.length == 0)
88 this.$.loadMoreButton.hide();
90 addItems: function(items) {
91 this.$.emptyAccountMessage.setShowing(items.length == 0);
92 this.inherited(arguments);
94 userNotFound: function() {
96 this.$.emptyAccountMessage.hide();
97 this.$.userNotFoundMessage.show();
99 apiError: function() {
101 alert('Unknown API Error');
103 getStalkStatus: function() {
104 if (!blerg.API.loggedIn) {
105 this.$.stalkLink.hide();
106 this.$.unstalkLink.hide();
109 this.$.api.getSubscriptionStatus(this.username);
111 gotStalkStatus: function(inSender, inEvent) {
112 if (inEvent.subscribed) {
113 this.$.stalkLink.hide();
114 this.$.unstalkLink.show();
116 this.$.stalkLink.show();
117 this.$.unstalkLink.hide();
120 startStalking: function() {
121 this.$.api.subscribe(this.username);
123 stopStalking: function() {
124 this.$.api.unsubscribe(this.username);