8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-26 22:52:26 +00:00
re2o/static/js/main.js
Yoann Pietri 6d2ad5b00e Refactor navbar and general frontend.
The menus of the navbar is reorganized
The footer is changed into a navbar
The right sidebar is placed to the left
The left sidebar is deleted
Header navbar and leftsidebar are now fixed
Physical grouing is split into 4 views
2021-01-24 16:37:09 +01:00

42 lines
No EOL
1.2 KiB
JavaScript

function adjustHeader(){
/* This function is here to adjust the header if the header navbar
goes into two lines. This can't happen if the width is sm or less,
and we shouldn't adjust in this case. */
if ($(window).width() >= 768) {
$('body').css('padding-top', $("#navbar-header").height());
$('.sidenav-left').css('top', $("#navbar-header").height());
} else {
$('body').css('padding-top', '');
$('.sidenav-left').css('top', '');
}
}
function listenSubmenu() {
/* Add listeners on sm screen or less for submenus. */
if ($(window).width() < 767) {
$('.dropdown-menu a').click(function (e) {
if ($(this).next('.submenu').length) {
e.preventDefault();
$(this).next('.submenu').toggle();
}
$('.dropdown').on('hide.bs.dropdown', function () {
$(this).find('.submenu').hide();
})
});
}
}
/* We need to apply those functions at init and when the screen is resized. */
$(window).resize(function () {
adjustHeader();
listenSubmenu();
});
adjustHeader();
listenSubmenu();
$(document).on('click', '.dropdown-menu', function (e) {
e.stopPropagation();
});