Fix page loading scheme; fix User switching
this.currentView = this.createComponent(objdef);
this.currentView.render();
} else {
- for (var i in objdef)
- this.currentView.setProperty(i, objdef[i])
+ // We don't want to invoke any change handlers until
+ // these are all set, so we do that ourselves
+ for (var i in objdef) {
+ if (i == 'kind') continue;
+ this.currentView[i] = objdef[i];
+ }
+ for (var i in objdef) {
+ if (i == 'kind') continue;
+ this.currentView[i + 'Changed'] && this.currentView[i + 'Changed']();
+ }
}
}
});
published: {
username: "",
permalink: false,
- firstRecord: null,
+ record: null,
},
statics: {
locationDetect: function(l) {
- var m = l.hash.match(/^#([A-Za-z0-9_-]+)(?:\/(p)?(\d+))?$/);
+ var m = l.hash.match(/^#([A-Za-z0-9_-]+)(?:\/(\d+))?$/);
if (m) {
return {
kind: "blerg.User",
username: m[1],
- permalink: m[2] != 'p',
- firstRecord: parseInt(m[3])
+ permalink: m[2] != undefined,
+ record: parseInt(m[2])
};
}
}
this.bubble('onSetTitle', {section: '@' + this.username});
this.$.records.destroyComponents();
this.lastRecord = null;
- this.loadMore();
+ this.$.loadMoreButton.hide();
+ if (this.permalink) {
+ this.loadItems(this.record, this.record);
+ } else {
+ this.loadMore();
+ }
},
loadItems: function(from, to) {
this.inherited(arguments);
url: url
});
req.response(function(inSender, inResponse) {
+ if (this.permalink) {
+ this.$.loadMoreButton.hide();
+ } else {
+ this.$.loadMoreButton.show();
+ }
+
for (var i = 0; i < inResponse.length; i++) {
inResponse[i].author = this.username;
}
+
this.addItems(inResponse);
}.bind(this));
req.go();
blerg.Util = {};
+// Dirty, terrible shim for rewritten links below
+blerg.Util.qlink = function() {
+ try {
+ location.href = event.target.href;
+ } catch(e) { }
+ enyo.$.blerg.bubble('onNavigate');
+ return false;
+}
+
blerg.Util.blergFormat = function(text) {
var lines = text.split(/\r?\n/);
if (lines[lines.length - 1] == '')
l = l.replace(/([^\w\\]|^)\*(\w[^*]*)\*(\W|$)/g, '$1<i>$2</i>$3');
// Turn refs and tags into links
- l = l.replace(/(\s|^)#([A-Za-z0-9_-]+)/g, '$1<a href="#/tag/$2" class="ref" onclick="return qlink()">#$2</a>');
- l = l.replace(/(\s|^)@([A-Za-z0-9_-]+)(\/\d+)?/g, '$1<a href="#$2$3" class="ref" onclick="return qlink()">@$2</a>');
+ l = l.replace(/(\s|^)#([A-Za-z0-9_-]+)/g, '$1<a href="#/tag/$2" class="ref" onclick="return blerg.Util.qlink()">#$2</a>');
+ l = l.replace(/(\s|^)@([A-Za-z0-9_-]+)(\/\d+)?/g, '$1<a href="#$2$3" class="ref" onclick="return blerg.Util.qlink()">@$2</a>');
// Create lists when lines begin with *
if (l[0] == '*') {