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

44 lines
1.1 KiB
JavaScript
Raw Normal View History

import { htmlSafe } from "@ember/template";
2023-11-07 12:07:33 -05:00
import discourseComputed from "discourse-common/utils/decorators";
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
2019-04-06 21:14:27 -04:00
export default class CarbonadsAd extends AdComponent {
serve_id = null;
placement = null;
init() {
this.set("serve_id", this.siteSettings.carbonads_serve_id);
this.set("placement", this.siteSettings.carbonads_placement);
super.init();
}
2019-04-06 21:14:27 -04:00
@discourseComputed("serve_id", "placement")
url(serveId, placement) {
return htmlSafe(
`//cdn.carbonads.com/carbon.js?serve=${serveId}&placement=${placement}`
);
}
2019-04-12 08:10:55 -04:00
@discourseComputed
showCarbonAds() {
if (!this.currentUser) {
return true;
}
return this.currentUser.show_carbon_ads;
}
2019-04-06 21:14:27 -04:00
@discourseComputed(
"placement",
"serve_id",
"showCarbonAds",
"showToGroups",
"showOnCurrentPage"
)
showAd(placement, serveId, showCarbonAds, showToGroups, showOnCurrentPage) {
return (
placement && serveId && showCarbonAds && showToGroups && showOnCurrentPage
);
}
}