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/routes/static_route.js

40 lines
986 B
JavaScript

/**
The routes used for rendering static content
@class StaticRoute
@extends Discourse.Route
@namespace Discourse
@module Discourse
**/
Discourse.StaticController.PAGES.forEach(function(page) {
Discourse[page.capitalize() + "Route"] = Discourse.Route.extend({
renderTemplate: function() {
this.render('static');
},
beforeModel: function(transition) {
var configKey = Discourse.StaticController.CONFIGS[page];
if (configKey && Discourse.SiteSettings[configKey].length > 0) {
transition.abort();
Discourse.URL.redirectTo(Discourse.SiteSettings[configKey]);
}
},
activate: function() {
this._super();
// Scroll to an element if exists
Discourse.URL.scrollToId(document.location.hash);
},
model: function() {
return Discourse.StaticPage.find(page);
},
setupController: function(controller, model) {
this.controllerFor('static').set('model', model);
}
});
});