Skip to content

Commit

Permalink
code smells
Browse files Browse the repository at this point in the history
  • Loading branch information
adpare committed Oct 3, 2023
1 parent 4b2b261 commit 5551c69
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion attack-theme/static/scripts/mobileview-datasources.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// This code is for creating a collapsable sidebar for the mobile view
var mediaQuery = window.matchMedia('(max-width: 47.9875rem)')
let mediaQuery = window.matchMedia('(max-width: 47.9875rem)')

function mobileSidenav(e) {
if (e.matches) {
Expand Down
11 changes: 7 additions & 4 deletions attack-theme/static/scripts/sidebar-load-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ if (mod_name.includes('contact')){
mod_entry = "/" + "resources/sidebar-resources"
}
$("#sidebars").load(mod_entry, function() {
var navElements = document.querySelectorAll('.sidenav-head > a');
var winlocation;
let navElements = document.querySelectorAll('.sidenav-head > a');
let winlocation;
navElements.forEach(function(element){
if(!window.location.href.endsWith("/")){
winlocation = window.location.href + "/";
Expand All @@ -21,7 +21,7 @@ $("#sidebars").load(mod_entry, function() {
}});

//This code is for creating a collapsable sidebar for the mobile view
var mediaQuery = window.matchMedia('(max-width: 47.9875rem)')
let mediaQuery = window.matchMedia('(max-width: 47.9875rem)')
function mobileSidenav(e) {
if (e.matches) {
$('#sidebar-collapse').collapse('hide')
Expand All @@ -32,8 +32,11 @@ $("#sidebars").load(mod_entry, function() {
}
$(document).ready(function() {
mobileSidenav(mediaQuery)
let sidenav = $(".sidenav-list");
let sidenav_active_elements = $(".sidenav .active");
sidenav_active_elements[0].scrollIntoView({ block: 'nearest', inline: 'start' })
if (sidenav_active_elements.length > 0) setTimeout(() => { //setTimeout gives bootstrap time to execute first
sidenav[0].scrollTop = sidenav_active_elements[0].offsetTop - 60;
});
});

mediaQuery.addEventListener('change', mobileSidenav)
Expand Down

0 comments on commit 5551c69

Please sign in to comment.