discourse-adplugin/assets/javascripts/discourse/components/carbonads-ad.js.es6

34 lines
934 B
Plaintext
Raw Normal View History

2019-04-06 21:14:27 -04:00
import {
default as computed,
observes
} from "ember-addons/ember-computed-decorators";
2019-04-12 08:08:25 -04:00
const currentUser = Discourse.User.current(),
2019-04-06 21:14:27 -04:00
serve_id = Discourse.SiteSettings.carbonads_serve_id,
placement = Discourse.SiteSettings.carbonads_placement;
export default Ember.Component.extend({
init: function() {
this.set("serve_id", serve_id);
this.set("placement", placement);
this._super();
},
url: function() {
return (`//cdn.carbonads.com/carbon.js?serve=${this.get("serve_id")}&placement=${this.get("placement")}`).htmlSafe();
}.property("serve_id", "placement"),
checkTrustLevels: function() {
return !(
currentUser &&
currentUser.get("trust_level") >
Discourse.SiteSettings.carbonads_through_trust_level
);
}.property("trust_level"),
@computed("checkTrustLevels")
showAd: function(checkTrustLevels) {
return placement && serve_id && checkTrustLevels;
}
});