Team:Heidelberg/js/wikipage

From 2014.igem.org

(Difference between revisions)
Line 23: Line 23:
$(document).ready(function(){
$(document).ready(function(){
var $navlink = $('.nav li a[href="/'+wgPageName+'"]').addClass('active');
var $navlink = $('.nav li a[href="/'+wgPageName+'"]').addClass('active');
-
$navlink.parents('.dropdown').addClass('active');
+
$navlink.parents('.dropdown-toggle').addClass('active');
});
});

Revision as of 21:08, 3 October 2014

var collapsed = false;

function centerDropdowns(){ $("ul.dropdown-menu").each(function(){

   var parentWidth = $(this).parent().innerWidth();
   var menuWidth = $(this).innerWidth();
   var margin = (parentWidth / 2 ) - (menuWidth / 2);
   margin = margin + "px";
   $(this).css("margin-left", margin);

}); }

document.onreadystatechange = function() {

   if (document.readyState === 'complete'){
       if($(window).width() >= 768) {
           centerDropdowns();
       }
       else
           collapsed = true;
   }

}

$(document).ready(function(){ var $navlink = $('.nav li a[href="/'+wgPageName+'"]').addClass('active'); $navlink.parents('.dropdown-toggle').addClass('active'); });

/* Center Dropdown menu if not collapsed */ $(window).resize(function(){ if($(window).width() >= 768){

   if(collapsed == true){
       centerDropdowns();
       collapsed = false;
   }

} else{

   if(collapsed == false){
       $("ul.dropdown-menu").css("margin-left", "");
       collapsed = true;
   }

} });