Node.js based forum software built for the modern web
closes #3505
barisusaklif2d6f931af4b
diff --git a/public/src/ajaxify.js b/public/src/ajaxify.jsindex bf30ac0521..8716a4dc52 100644--- a/public/src/ajaxify.js+++ b/public/src/ajaxify.js@@ -56,6 +56,7 @@ $(document).ready(function() {url = ajaxify.start(url, quiet);+ $('body').removeClass(ajaxify.data.bodyClass);$('#footer, #content').removeClass('hide').addClass('ajaxifying');ajaxify.loadData(url, function(err, data) {@@ -141,6 +142,7 @@ $(document).ready(function() {templates.parse(tpl_url, data, function(template) {translator.translate(template, function(translatedTemplate) {+ $('body').addClass(data.bodyClass);$('#content').html(translatedTemplate);ajaxify.end(url, tpl_url);diff --git a/src/middleware/header.js b/src/middleware/header.jsindex 52d96f0d79..6cedf1241a 100644--- a/src/middleware/header.js+++ b/src/middleware/header.js@@ -60,7 +60,8 @@ module.exports = function(app, middleware) {allowRegistration: registrationType === 'normal' || registrationType === 'admin-approval',searchEnabled: plugins.hasListeners('filter:search.query'),config: res.locals.config,- relative_path: nconf.get('relative_path')+ relative_path: nconf.get('relative_path'),+ bodyClass: data.bodyClass};templateValues.configJSON = JSON.stringify(res.locals.config);diff --git a/src/middleware/render.js b/src/middleware/render.jsindex ba0c06552e..4a80d4b9c8 100644--- a/src/middleware/render.js+++ b/src/middleware/render.js@@ -29,6 +29,8 @@ module.exports = function(middleware) {options.relative_path = nconf.get('relative_path');options.template = {name: template};options.template[template] = true;+ options.bodyClass = buildBodyClass(req);+res.locals.template = template;if (res.locals.isAPI) {@@ -80,4 +82,14 @@ module.exports = function(middleware) {next();};+ function buildBodyClass(req) {+ var clean = req.path.replace(/^\/api/, '').replace(/^\//, '');+ var parts = clean.split('/').slice(0, 3);+ parts.forEach(function(p, index) {+ parts[index] = index ? parts[index - 1] + '-' + p : 'page-' + (p || 'home');+ });++ return parts.join(' ');+ }+};\ No newline at end of file