feat: added client-size hook to enable configuration of navbar hiding, closes #541

main
Julian Lam 3 years ago
parent e06a537634
commit 758743220d

@ -45,42 +45,49 @@ $(document).ready(function () {
if (!$.fn.autoHidingNavbar) { if (!$.fn.autoHidingNavbar) {
return; return;
} }
var env = utils.findBootstrapEnvironment();
// if env didn't change don't destroy and recreate
if (env === lastBSEnv) {
return;
}
lastBSEnv = env;
var navbarEl = $('.navbar-fixed-top');
navbarEl.autoHidingNavbar('destroy').removeData('plugin_autoHidingNavbar');
navbarEl.css('top', '');
if (env === 'xs' || env === 'sm') {
navbarEl.autoHidingNavbar({
showOnBottom: false,
});
}
function fixTopCss(topValue) { require(['hooks'], (hooks) => {
if (ajaxify.data.template.topic) { var env = utils.findBootstrapEnvironment();
$('.topic .topic-header').css({ top: topValue }); // if env didn't change don't destroy and recreate
} else { if (env === lastBSEnv) {
var topicListHeader = $('.topic-list-header'); return;
if (topicListHeader.length) {
topicListHeader.css({ top: topValue });
}
} }
} lastBSEnv = env;
var navbarEl = $('.navbar-fixed-top');
navbarEl.autoHidingNavbar('destroy').removeData('plugin_autoHidingNavbar');
navbarEl.css('top', '');
hooks.fire('filter:persona.configureNavbarHiding', {
resizeEnvs: ['xs', 'sm'],
}).then(({ resizeEnvs }) => {
if (resizeEnvs.includes(env)) {
navbarEl.autoHidingNavbar({
showOnBottom: false,
});
}
navbarEl.off('show.autoHidingNavbar') function fixTopCss(topValue) {
.on('show.autoHidingNavbar', function () { if (ajaxify.data.template.topic) {
fixTopCss(''); $('.topic .topic-header').css({ top: topValue });
}); } else {
var topicListHeader = $('.topic-list-header');
if (topicListHeader.length) {
topicListHeader.css({ top: topValue });
}
}
}
navbarEl.off('show.autoHidingNavbar')
.on('show.autoHidingNavbar', function () {
fixTopCss('');
});
navbarEl.off('hide.autoHidingNavbar') navbarEl.off('hide.autoHidingNavbar')
.on('hide.autoHidingNavbar', function () { .on('hide.autoHidingNavbar', function () {
fixTopCss('0px'); fixTopCss('0px');
});
}); });
});
} }
function setupNProgress() { function setupNProgress() {

Loading…
Cancel
Save