Updates to carbonads-ad

This commit is contained in:
Neil Lalonde 2019-04-17 11:16:20 -04:00
parent 881a8e5d4c
commit 8ef02aa351
1 changed files with 10 additions and 10 deletions

View File

@ -1,3 +1,4 @@
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad_component";
import { import {
default as computed, default as computed,
observes observes
@ -7,21 +8,20 @@ const currentUser = Discourse.User.current(),
serve_id = Discourse.SiteSettings.carbonads_serve_id, serve_id = Discourse.SiteSettings.carbonads_serve_id,
placement = Discourse.SiteSettings.carbonads_placement; placement = Discourse.SiteSettings.carbonads_placement;
export default Ember.Component.extend({ export default AdComponent.extend({
init: function() { init() {
this.set("serve_id", serve_id); this.set("serve_id", serve_id);
this.set("placement", placement); this.set("placement", placement);
this._super(); this._super();
}, },
@computed("serve_id", "placement") @computed("serve_id", "placement")
url: function() { url(serveId, placement) {
return (`//cdn.carbonads.com/carbon.js?serve=${this.get("serve_id")}&placement=${this.get("placement")}`).htmlSafe(); return `//cdn.carbonads.com/carbon.js?serve=${serveId}&placement=${placement}`.htmlSafe();
}, },
@computed()
@computed("trust_level") showToTrustLevel() {
checkTrustLevels: function() {
return !( return !(
currentUser && currentUser &&
currentUser.get("trust_level") > currentUser.get("trust_level") >
@ -29,8 +29,8 @@ export default Ember.Component.extend({
); );
}, },
@computed("checkTrustLevels") @computed("showToTrustLevel", "showToGroups")
showAd: function(checkTrustLevels) { showAd(showToTrustLevel, showToGroups) {
return placement && serve_id && checkTrustLevels; return placement && serve_id && showToTrustLevel && showToGroups;
} }
}); });