v1.18.x
barisusakli 9 years ago
parent e60c1d8736
commit f2d6f931af

@ -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);

@ -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);

@ -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(' ');
}
};
Loading…
Cancel
Save