Team:WHU-China/menujs

From 2013.igem.org

(Difference between revisions)
(Created page with "/*@Allen Zhou 20110818 */ - this part copied from the http://www.geneetics.cn all rights reserved by 2013 BGI: $(function(){ //event configs var menuEvents={timeoutId:0,ti...")
 
(8 intermediate revisions not shown)
Line 42: Line 42:
if(menuEvents.mouseover==true&&$('.sec',that).length>0){
if(menuEvents.mouseover==true&&$('.sec',that).length>0){
document.getElementById('menu-sub-container-inner').innerHTML=$('.sec',that)[0].innerHTML;
document.getElementById('menu-sub-container-inner').innerHTML=$('.sec',that)[0].innerHTML;
-
$('#menu-sub-container').animate({height:$('#menu-sub-container-inner').height()+10},400);
+
$('#menu-sub-container').animate({height:$('#menu-sub-container-inner').height()+10},200);
}
}
-
},150);
+
},0);
},function(e){
},function(e){
menuEvents.mouseover=false;
menuEvents.mouseover=false;
Line 52: Line 52:
menuEvents.timeoutId=setTimeout(function(){
menuEvents.timeoutId=setTimeout(function(){
if(menuEvents.haschild===false || menuEvents.mouseover===false){
if(menuEvents.haschild===false || menuEvents.mouseover===false){
-
$('#menu-sub-container').animate({height:0},400);
+
$('#menu-sub-container').animate({height:0},0);
}
}
-
},300);
+
},0);
});
});
$('.topla').hover(function(){
$('.topla').hover(function(){
Line 70: Line 70:
menuEvents.timeoutId=setTimeout(function(){
menuEvents.timeoutId=setTimeout(function(){
$('#menu-sub-container').animate({height:0},400);
$('#menu-sub-container').animate({height:0},400);
-
},300);
+
},0);
});
});
});
});

Latest revision as of 07:29, 15 September 2013

/*@Allen Zhou 20110818 */ /*this part copied from the http://www.geneetics.cn all rights reserved by 2013 BGI */ $(function(){ //event configs var menuEvents={timeoutId:0,timeId2:null,mouseover:false,haschild:false,currentLiTarget:null}; //(sub menu's)containter element var container=document.getElementById('menu-sub-container'); //event proxy : the child nodes of the container element are changes all the time // so that i bind the event on the (sub menu's)container element container.onmouseover=function(e){ var even=e||window.event; var target=even.srcElement||even.target; while(target && target.id!="menu-sub-container" && target.tagName.toLowerCase()!="body"){ //find son element of the (sub menu's)container if(target.parentNode.className.indexOf("menu-sub-list-row")!=-1){ //contrast with the last target that we saved if(target!=menuEvents.currentLiTarget){ menuEvents.currentLiTarget=target; $('#menu-sub-container .hover').removeClass('hover'); $(target).addClass('hover'); } break; } target=target.parentNode; } }; //events about level1 menus $('.toplist').hover(function(e){ menuEvents.mouseover=true; var that=this; //has child if($('.sec',that).length>0){ clearTimeout(menuEvents.timeoutId); menuEvents.timeoutId=null; menuEvents.haschild=true; //no child }else{ menuEvents.haschild=false; } //set a delay to show sub menus menuEvents.timeoutId2=setTimeout(function(){ if(menuEvents.mouseover==true&&$('.sec',that).length>0){ document.getElementById('menu-sub-container-inner').innerHTML=$('.sec',that)[0].innerHTML; $('#menu-sub-container').animate({height:$('#menu-sub-container-inner').height()+10},200); } },0); },function(e){ menuEvents.mouseover=false; clearTimeout(menuEvents.timeoutId2); menuEvents.timeoutId2=null; //set a delay to hide sub menus menuEvents.timeoutId=setTimeout(function(){ if(menuEvents.haschild===false || menuEvents.mouseover===false){ $('#menu-sub-container').animate({height:0},0); } },0); }); $('.topla').hover(function(){ $(this).addClass('hover'); },function(){ $(this).removeClass('hover'); })/*.click(function(){ $(this).removeClass('hover'); });*/ //events about (sub menu's)container $('#menu-sub-container').hover(function(e){ clearTimeout(menuEvents.timeoutId); menuEvents.timeoutId=null; },function(e){ menuEvents.timeoutId=setTimeout(function(){ $('#menu-sub-container').animate({height:0},400); },0); }); });