discourse-adplugin/assets/javascripts/initializers/initialize-ad-plugin.js.es6

36 lines
976 B
Plaintext
Raw Normal View History

2018-10-22 14:49:32 -04:00
import { withPluginApi } from "discourse/lib/plugin-api";
import Site from "discourse/models/site";
2015-08-03 21:25:00 -04:00
export default {
2018-10-22 14:49:32 -04:00
name: "initialize-ad-plugin",
initialize(container) {
2020-09-04 07:24:14 -04:00
withPluginApi("0.1", (api) => {
api.decorateWidget("post:after", (dec) => {
if (dec.canConnectComponent) {
2019-05-10 14:22:18 -04:00
if (!dec.attrs.cloaked) {
return dec.connect({
component: "post-bottom-ad",
2020-09-04 07:24:14 -04:00
context: "model",
2019-05-10 14:22:18 -04:00
});
}
} else {
// Old way for backwards compatibility
2018-06-07 19:17:19 -04:00
return dec.connect({
2019-05-10 14:22:18 -04:00
templateName: "connectors/post-bottom/discourse-adplugin",
2020-09-04 07:24:14 -04:00
context: "model",
2018-06-07 19:17:19 -04:00
});
}
2016-02-22 12:11:29 -05:00
});
});
2019-05-10 14:22:18 -04:00
const messageBus = container.lookup("message-bus:main");
if (!messageBus) {
return;
}
2020-09-04 07:24:14 -04:00
messageBus.subscribe("/site/house-creatives", function (houseAdsSettings) {
Site.currentProp("house_creatives", houseAdsSettings);
});
2020-09-04 07:24:14 -04:00
},
2015-08-03 21:25:00 -04:00
};