This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/public/assets/scripts/discourse-boot.js
Jarek Radosz fcb4e5a1a1
DEV: Make wizard an ember addon (#17027)
Co-authored-by: David Taylor <david@taylorhq.com>
2022-06-17 14:50:21 +02:00

33 lines
1.0 KiB
JavaScript

(function () {
if (window.unsupportedBrowser) {
throw "Unsupported browser detected";
}
// TODO: Remove this and have resolver find the templates
const prefix = "discourse/templates/";
const adminPrefix = "admin/templates/";
const wizardPrefix = "wizard/templates/";
let len = prefix.length;
Object.keys(requirejs.entries).forEach(function (key) {
if (key.startsWith(prefix)) {
Ember.TEMPLATES[key.slice(len)] = require(key).default;
} else if (key.startsWith(adminPrefix) || key.startsWith(wizardPrefix)) {
Ember.TEMPLATES[key] = require(key).default;
}
});
window.__widget_helpers = require("discourse-widget-hbs/helpers").default;
// TODO: Eliminate this global
window.virtualDom = require("virtual-dom");
let element = document.querySelector(
`meta[name="discourse/config/environment"]`
);
const config = JSON.parse(
decodeURIComponent(element.getAttribute("content"))
);
const event = new CustomEvent("discourse-booted", { detail: config });
document.dispatchEvent(event);
})();