This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/controllers/notification.js.es6
2014-06-12 10:17:41 +10:00

34 lines
993 B
JavaScript

export default Discourse.ObjectController.extend({
scope: function() {
return "notifications." + Discourse.Site.currentProp("notificationLookup")[this.get("notification_type")];
}.property(),
username: function() {
return this.get("data.display_username");
}.property(),
safe: function(prop){
var val = this.get(prop);
if(val) {
val = Handlebars.Utils.escapeExpression(val);
}
return val;
},
link: function() {
var badgeId = this.safe('data.badge_id');
if (badgeId) {
var badgeName = this.safe('data.badge_name');
return '<a href="/badges/' + badgeId + '/' + badgeName.replace(/[^A-Za-z0-9_]+/g, '-').toLowerCase() + '">' + badgeName + '</a>';
}
if (this.blank("data.topic_title")) {
return "";
}
var url = Discourse.Utilities.postUrl(this.safe("slug"), this.safe("topic_id"), this.safe("post_number"));
return '<a href="' + url + '">' + this.safe("data.topic_title") + '</a>';
}.property()
});