Remove auto-toggling of navigation sidebar depending on width

This commit is contained in:
Luka Murn 2018-05-27 15:44:15 +02:00
parent 8b527d8a5b
commit b86edf20a5
3 changed files with 11 additions and 17 deletions

View file

@ -227,27 +227,15 @@ function setupSidebarTree() {
// Resize the sidebar to accomodate to the page size
function resizeSidebarContents() {
var wrapper = $("#wrapper");
var tree = $("#sidebar-wrapper .tree");
var toggled = true;
var navbar = $(".navbar-secondary");
// Set vertical scrollbar on navigation tree
if (tree.length && tree.length == 1) {
tree.css(
"height",
($(window).height() - tree.position().top - 50) + "px"
);
}
// Automatic toggling of sidebar for smaller devices
if (toggled === null) {
if ($(window).width() < <%= Constants::SCREEN_WIDTH_LARGE %>) {
wrapper.addClass("toggled");
navbar.addClass("navbar-without-sidebar");
} else {
wrapper.removeClass("toggled");
navbar.removeClass("navbar-without-sidebar");
}
}
}
(function () {

View file

@ -12,6 +12,7 @@
$('.navbar-secondary').css(
{ 'margin-left': '-280px', 'padding-left': '294px' }
);
$('#sideBarButton').attr('data-shown', '');
}
function hide() {
@ -25,23 +26,28 @@
'margin-left': '0',
'padding-left': '14px'
});
$('#sideBarButton').removeAttr('data-shown');
}
function toggle() {
var btn = $('#sideBarButton');
if (btn.is('[data-shown]')) {
btn.removeAttr('data-shown');
hide();
} else {
btn.attr('data-shown', '');
show();
}
}
function isShown() {
var btn = $('#sideBarButton');
return btn.is('[data-shown]');
}
return Object.freeze({
show: show,
hide: hide,
toggle: toggle
toggle: toggle,
isShown: isShown
})
})();
})(window);

View file

@ -96,7 +96,7 @@ class Constants
# Screen width which is still suitable for sidebar to be shown, otherwise
# hidden
SCREEN_WIDTH_LARGE = 928
SCREEN_WIDTH_LARGE = 768
#=============================================================================
# Styling