mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 03:55:55 +01:00
closes #3505
This commit is contained in:
@@ -56,6 +56,7 @@ $(document).ready(function() {
|
|||||||
|
|
||||||
url = ajaxify.start(url, quiet);
|
url = ajaxify.start(url, quiet);
|
||||||
|
|
||||||
|
$('body').removeClass(ajaxify.data.bodyClass);
|
||||||
$('#footer, #content').removeClass('hide').addClass('ajaxifying');
|
$('#footer, #content').removeClass('hide').addClass('ajaxifying');
|
||||||
|
|
||||||
ajaxify.loadData(url, function(err, data) {
|
ajaxify.loadData(url, function(err, data) {
|
||||||
@@ -141,6 +142,7 @@ $(document).ready(function() {
|
|||||||
|
|
||||||
templates.parse(tpl_url, data, function(template) {
|
templates.parse(tpl_url, data, function(template) {
|
||||||
translator.translate(template, function(translatedTemplate) {
|
translator.translate(template, function(translatedTemplate) {
|
||||||
|
$('body').addClass(data.bodyClass);
|
||||||
$('#content').html(translatedTemplate);
|
$('#content').html(translatedTemplate);
|
||||||
|
|
||||||
ajaxify.end(url, tpl_url);
|
ajaxify.end(url, tpl_url);
|
||||||
|
|||||||
@@ -60,7 +60,8 @@ module.exports = function(app, middleware) {
|
|||||||
allowRegistration: registrationType === 'normal' || registrationType === 'admin-approval',
|
allowRegistration: registrationType === 'normal' || registrationType === 'admin-approval',
|
||||||
searchEnabled: plugins.hasListeners('filter:search.query'),
|
searchEnabled: plugins.hasListeners('filter:search.query'),
|
||||||
config: res.locals.config,
|
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);
|
templateValues.configJSON = JSON.stringify(res.locals.config);
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ module.exports = function(middleware) {
|
|||||||
options.relative_path = nconf.get('relative_path');
|
options.relative_path = nconf.get('relative_path');
|
||||||
options.template = {name: template};
|
options.template = {name: template};
|
||||||
options.template[template] = true;
|
options.template[template] = true;
|
||||||
|
options.bodyClass = buildBodyClass(req);
|
||||||
|
|
||||||
res.locals.template = template;
|
res.locals.template = template;
|
||||||
|
|
||||||
if (res.locals.isAPI) {
|
if (res.locals.isAPI) {
|
||||||
@@ -80,4 +82,14 @@ module.exports = function(middleware) {
|
|||||||
next();
|
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(' ');
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user