Team:Johns Hopkins-Software/header

From 2012.igem.org

(Difference between revisions)
Line 47: Line 47:
</div>
</div>
</div>
</div>
 +
 +
<script type="text/javascript">
 +
 +
/*********************
 +
//* jQuery Drop Line Menu- By Dynamic Drive: http://www.dynamicdrive.com/
 +
//* Last updated: May 9th, 11'
 +
//* Menu avaiable at DD CSS Library: http://www.dynamicdrive.com/style/
 +
*********************/
 +
 +
var droplinemenu={
 +
 +
/*arrowimage: {classname: 'downarrowclass', src: '', leftpadding: 5}, //customize down arrow image*/
 +
animateduration: {over: 80, out: 50}, //duration of slide in/ out animation, in milliseconds
 +
 +
buildmenu:function(menuid){
 +
jQuery(document).ready(function($){
 +
var $mainmenu=$("#"+menuid+">ul")
 +
var $headers=$mainmenu.find("ul").parent()
 +
$headers.each(function(i){
 +
var $curobj=$(this)
 +
var $subul=$(this).find('ul:eq(0)')
 +
this._dimensions={h:$curobj.find('a:eq(0)').outerHeight()}
 +
this.istopheader=$curobj.parents("ul").length==1? true : false
 +
if (!this.istopheader)
 +
$subul.css({left:0, top:this._dimensions.h})
 +
var $innerheader=$curobj.children('a').eq(0)
 +
$innerheader=($innerheader.children().eq(0).is('span'))? $innerheader.children().eq(0) : $innerheader //if header contains inner SPAN, use that
 +
/* $innerheader.append(
 +
'<img src="'+ droplinemenu.arrowimage.src
 +
+'" class="' + droplinemenu.arrowimage.classname
 +
+ '" style="border:0; padding-left: '+droplinemenu.arrowimage.leftpadding+'px" />'
 +
)*/
 +
$curobj.hoverIntent(
 +
function(e){
 +
var $targetul=$(this).children("ul:eq(0)")
 +
if ($targetul.queue().length<=1) //if 1 or less queued animations
 +
if (this.istopheader)
 +
$targetul.css({left: $mainmenu.position().left, top: $mainmenu.position().top+this._dimensions.h})
 +
if (document.all && !window.XMLHttpRequest) //detect IE6 or less, fix issue with overflow
 +
$mainmenu.find('ul').css({overflow: (this.istopheader)? 'hidden' : 'visible'})
 +
$targetul.dequeue().slideDown(droplinemenu.animateduration.over)
 +
},
 +
function(e){
 +
var $targetul=$(this).children("ul:eq(0)")
 +
$targetul.dequeue().slideUp(droplinemenu.animateduration.out)
 +
}
 +
) //end hover
 +
}) //end $headers.each()
 +
$mainmenu.find("ul").css({display:'none', visibility:'visible', width:$mainmenu.width()})
 +
}) //end document.ready
 +
}
 +
}
 +
 +
</text>
 +
 +
 +
<script type="text/javascript">
 +
 +
 +
var DDSPEED = 10;
 +
var DDTIMER = 15;
 +
 +
// main function to handle the mouse events //
 +
function ddMenu(id,d){
 +
  var h = document.getElementById(id + '-ddheader');
 +
  var c = document.getElementById(id + '-ddcontent');
 +
  clearInterval(c.timer);
 +
  if(d == 1){
 +
    clearTimeout(h.timer);
 +
    if(c.maxh && c.maxh <= c.offsetHeight){return}
 +
    else if(!c.maxh){
 +
      c.style.display = 'block';
 +
      c.style.height = 'auto';
 +
      c.maxh = c.offsetHeight;
 +
      c.style.height = '0px';
 +
    }
 +
    c.timer = setInterval(function(){ddSlide(c,1)},DDTIMER);
 +
  }else{
 +
    h.timer = setTimeout(function(){ddCollapse(c)},50);
 +
  }
 +
}
 +
 +
// collapse the menu //
 +
function ddCollapse(c){
 +
  c.timer = setInterval(function(){ddSlide(c,-1)},DDTIMER);
 +
}
 +
 +
// cancel the collapse if a user rolls over the dropdown //
 +
function cancelHide(id){
 +
  var h = document.getElementById(id + '-ddheader');
 +
  var c = document.getElementById(id + '-ddcontent');
 +
  clearTimeout(h.timer);
 +
  clearInterval(c.timer);
 +
  if(c.offsetHeight < c.maxh){
 +
    c.timer = setInterval(function(){ddSlide(c,1)},DDTIMER);
 +
  }
 +
}
 +
 +
// incrementally expand/contract the dropdown and change the opacity //
 +
function ddSlide(c,d){
 +
  var currh = c.offsetHeight;
 +
  var dist;
 +
  if(d == 1){
 +
    dist = (Math.round((c.maxh - currh) / DDSPEED));
 +
  }else{
 +
    dist = (Math.round(currh / DDSPEED));
 +
  }
 +
  if(dist <= 1 && d == 1){
 +
    dist = 1;
 +
  }
 +
  c.style.height = currh + (dist * d) + 'px';
 +
  c.style.opacity = currh / c.maxh;
 +
  c.style.filter = 'alpha(opacity=' + (currh * 100 / c.maxh) + ')';
 +
  if((currh < 2 && d != 1) || (currh > (c.maxh - 2) && d == 1)){
 +
    clearInterval(c.timer);
 +
  }
 +
}
 +
 +
</script>
 +
 +
 +
<script type="text/javascript">
 +
/**
 +
* jQuery Opacity Rollover plugin
 +
*
 +
* Copyright (c) 2009 Trent Foley (http://trentacular.com)
 +
* Licensed under the MIT License:
 +
*  http://www.opensource.org/licenses/mit-license.php
 +
*/
 +
;(function($) {
 +
var defaults = {
 +
mouseOutOpacity:  0.67,
 +
mouseOverOpacity:  1.0,
 +
fadeSpeed:        'fast',
 +
exemptionSelector: '.selected'
 +
};
 +
 +
$.fn.opacityrollover = function(settings) {
 +
// Initialize the effect
 +
$.extend(this, defaults, settings);
 +
 +
var config = this;
 +
 +
function fadeTo(element, opacity) {
 +
var $target = $(element);
 +
 +
if (config.exemptionSelector)
 +
$target = $target.not(config.exemptionSelector);
 +
 +
$target.fadeTo(config.fadeSpeed, opacity);
 +
}
 +
 +
this.css('opacity', this.mouseOutOpacity)
 +
.hover(
 +
function () {
 +
fadeTo(this, config.mouseOverOpacity);
 +
},
 +
function () {
 +
fadeTo(this, config.mouseOutOpacity);
 +
});
 +
 +
return this;
 +
};
 +
})(jQuery);
 +
 +
</script>
 +
 +
 +
<script type="text/javascript">
 +
$(function() {
 +
 +
    var offset = $("#navigation_low").offset();
 +
    var topPadding = 0;
 +
 +
    $(window).scroll(function() {
 +
   
 +
        if ($(window).scrollTop() > offset.top) {
 +
       
 +
            $("#navigation_low").stop().animate({
 +
           
 +
                marginTop: $(window).scrollTop() - offset.top + topPadding
 +
           
 +
            });
 +
       
 +
        } else {
 +
       
 +
            $("#navigation_low").stop().animate({
 +
           
 +
                marginTop: 0
 +
           
 +
            });
 +
       
 +
        }
 +
       
 +
           
 +
    });
 +
 +
});
 +
 +
 +
</script>
 +
 +
 +
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
 +
<script type="text/javascript">
 +
//build menu with DIV ID="myslidemenu" on page:
 +
droplinemenu.buildmenu("mydroplinemenu")
 +
 +
//Nivoslider
 +
    $(window).load(function() {
 +
        $('#slider').nivoSlider({
 +
effect:'fade',
 +
pauseOnHover:true
 +
});
 +
    });
 +
 +
//Profile script from http://www.willmaster.com/library/web-development/replace-div-content.php
 +
function ReplaceContentInContainer(id,content) {
 +
var container = document.getElementById(id);
 +
container.innerHTML = content;
 +
}
 +
 +
</script>
</html>
</html>

Revision as of 07:15, 3 October 2012