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/lib/static-route-builder.js.es6

43 lines
935 B
JavaScript

const configs = {
"faq": "faq_url",
"tos": "tos_url",
"privacy": "privacy_policy_url"
};
export default (page) => {
return Discourse.Route.extend({
renderTemplate() {
this.render("static");
},
beforeModel(transition) {
const configKey = configs[page];
if (configKey && Discourse.SiteSettings[configKey].length > 0) {
transition.abort();
Discourse.URL.redirectTo(Discourse.SiteSettings[configKey]);
}
},
activate() {
this._super();
// Scroll to an element if exists
Discourse.URL.scrollToId(document.location.hash);
},
model() {
return Discourse.StaticPage.find(page);
},
setupController(controller, model) {
this.controllerFor("static").set("model", model);
},
actions: {
didTransition() {
this.controllerFor("application").set("showFooter", true);
return true;
}
}
});
};