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 // Resize the sidebar to accomodate to the page size
function resizeSidebarContents() { function resizeSidebarContents() {
var wrapper = $("#wrapper");
var tree = $("#sidebar-wrapper .tree"); var tree = $("#sidebar-wrapper .tree");
var toggled = true;
var navbar = $(".navbar-secondary");
// Set vertical scrollbar on navigation tree
if (tree.length && tree.length == 1) { if (tree.length && tree.length == 1) {
tree.css( tree.css(
"height", "height",
($(window).height() - tree.position().top - 50) + "px" ($(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 () { (function () {

View file

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

View file

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