0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-10 12:22:54 +01:00
discourse-custom-wizard/assets/javascripts/wizard/lib/initialize/wizard.js.es6

58 Zeilen
1,7 KiB
Text

2022-03-16 12:33:34 +01:00
export default {
name: "custom-wizard",
initialize(app) {
2022-06-15 08:59:09 +02:00
const isTesting = requirejs("discourse-common/config/environment")
.isTesting;
2022-03-16 12:33:34 +01:00
const isWizard = window.location.pathname.indexOf("/w/") > -1;
if (!isWizard && !isTesting()) {
return;
}
const container = app.__container__;
2022-06-15 08:59:09 +02:00
const setDefaultOwner = requirejs("discourse-common/lib/get-owner")
.setDefaultOwner;
2022-03-16 12:33:34 +01:00
setDefaultOwner(container);
if (!isTesting()) {
const PreloadStore = requirejs("discourse/lib/preload-store").default;
let preloaded;
2022-06-15 08:59:09 +02:00
const preloadedDataElement = document.getElementById(
"data-preloaded-wizard"
);
2022-03-16 12:33:34 +01:00
if (preloadedDataElement) {
preloaded = JSON.parse(preloadedDataElement.dataset.preloadedWizard);
}
Object.keys(preloaded).forEach(function (key) {
PreloadStore.store(key, JSON.parse(preloaded[key]));
});
app.SiteSettings = PreloadStore.get("siteSettings");
}
2022-06-15 08:59:09 +02:00
const setEnvironment = requirejs("discourse-common/config/environment")
.setEnvironment;
2022-03-16 12:33:34 +01:00
const setupData = document.getElementById("data-discourse-setup").dataset;
setEnvironment(setupData.environment);
const Session = requirejs("discourse/models/session").default;
const session = Session.current();
session.set("highlightJsPath", setupData.highlightJsPath);
session.set("markdownItUrl", setupData.markdownItUrl);
2022-03-16 12:33:34 +01:00
[
2022-06-15 08:59:09 +02:00
"register-files",
"inject-objects",
"create-contexts",
"patch-components",
].forEach((fileName) => {
const initializer = requirejs(
`discourse/plugins/discourse-custom-wizard/wizard/lib/initialize/${fileName}`
).default;
2022-03-16 12:33:34 +01:00
initializer.run(app, container);
});
2022-06-15 08:59:09 +02:00
},
2022-03-16 12:33:34 +01:00
};