Team:Heidelberg/js/wikipage

From 2014.igem.org

var collapsed = false;

jQuery.extend(jQuery.easing, { easeInOutCubic: function (x, t, b, c, d) {

   if ((t/=d/2) < 1) return c/2*t*t*t + b;
   return c/2*((t-=2)*t*t + 2) + b;
 }

});

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").children(".dropdown-toggle").addClass('active'); if($.isFunction($.fn.fancybox))

  $(".img-enlarge")
   .fancybox({
       beforeLoad: function() {
           var el = $(this.element).parent().children('.caption');
           
               if (el.length) {
this.title = el.html() + '

<a target="_blank" href="' + $(this.element).attr('href') +'">Open Image in new Tab</a>

';
               }
           },
       helpers : {
           title: {
               type: 'inside'
           }
       }
   });
  });

/* 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;
   }

} }); $(document).ready(function(){ document.styleSheets[0].disabled = true; });