Difference between revisions of "Template:Shanghaitech/js"

Line 27: Line 27:
 
     createEmptySidenav();
 
     createEmptySidenav();
 
     parseContentTitles();
 
     parseContentTitles();
 +
}
 +
 +
function adjustSidenavHeight(){
 +
    if($("#sidenav-wrapper").height() > $("#mySidenav").height()*0.9){
 +
        if(! $("#sidenav-wrapper").hasClass("narrow")){
 +
            $("#sidenav-wrapper").addClass("narrow");
 +
        }else if (! $("#sidenav-wrapper").hasClass("narrower")){
 +
            $("#sidenav-wrapper").addClass("narrower");
 +
        }else{
 +
            $("#sidenav-wrapper").addClass("scroll");
 +
        }
 +
    }else{
 +
        if($("#sidenav-wrapper").hasClass("scroll")){
 +
            $("#sidenav-wrapper").removeClass("scroll");
 +
        }else if($("#sidenav-wrapper").hasClass("narrower")){
 +
            $("#sidenav-wrapper").removeClass("narrower");
 +
        }else{
 +
            $("#sidenav-wrapper").removeClass("narrow");
 +
        }
 +
    }
 
}
 
}
  
 
$(document).ready(createSidenav);
 
$(document).ready(createSidenav);
 +
adjustSidenavHeight();
 +
$( window ).resize(adjustSidenavHeight);
 +
 +
  
 
</script></html>
 
</script></html>

Revision as of 15:15, 30 October 2017