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

35 lines
936 B
Plaintext
Raw Normal View History

2018-10-22 14:49:32 -04:00
import { withPluginApi } from "discourse/lib/plugin-api";
2015-08-03 21:25:00 -04:00
export default {
2018-10-22 14:49:32 -04:00
name: "initialize-ad-plugin",
initialize(container) {
2018-10-22 14:49:32 -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",
context: "model"
});
}
} 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",
2018-10-22 14:49:32 -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;
}
2019-05-10 14:22:18 -04:00
messageBus.subscribe("/site/house-creatives", function(houseAdsSettings) {
Discourse.Site.currentProp("house_creatives", houseAdsSettings);
});
2015-08-03 21:25:00 -04:00
}
};