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

49 lines
1.1 KiB
JavaScript
Raw Normal View History

import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
import discourseComputed from "discourse-common/utils/decorators";
2019-04-06 21:14:27 -04:00
export default AdComponent.extend({
serve_id: null,
placement: null,
init() {
this.set("serve_id", this.siteSettings.carbonads_serve_id);
this.set("placement", this.siteSettings.carbonads_placement);
2019-04-06 21:14:27 -04:00
this._super();
},
@discourseComputed("serve_id", "placement")
url(serveId, placement) {
return `//cdn.carbonads.com/carbon.js?serve=${serveId}&placement=${placement}`.htmlSafe();
2019-04-12 08:10:55 -04:00
},
@discourseComputed("currentUser.trust_level")
showToTrustLevel(trustLevel) {
2019-04-06 21:14:27 -04:00
return !(
trustLevel && trustLevel > this.siteSettings.carbonads_through_trust_level
2019-04-06 21:14:27 -04:00
);
2019-04-12 08:10:55 -04:00
},
2019-04-06 21:14:27 -04:00
@discourseComputed(
"placement",
"serve_id",
"showToTrustLevel",
"showToGroups",
"showOnCurrentPage"
)
showAd(
placement,
serveId,
showToTrustLevel,
showToGroups,
showOnCurrentPage
) {
return (
placement &&
serveId &&
showToTrustLevel &&
showToGroups &&
showOnCurrentPage
);
2020-09-04 07:24:14 -04:00
},
2019-04-06 21:14:27 -04:00
});