Changeset 12818


Ignore:
Timestamp:
Aug 31, 2011, 2:22:28 PM (10 years ago)
Author:
jordan
Message:

fix a bug in jquery.transmenu that caused popping the menu up to be very slow if there are a lot of torrents in torrent_list.

Location:
trunk/web/javascript/jquery
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/web/javascript/jquery/jquery.transmenu.js

    r8797 r12818  
    5757                                div.timer = setTimeout( function() {
    5858                                        //check if the mouse is still over the parent item - if not dont show the submenu
    59                                         if (! $('div').parent().is('.hover')) {
     59                                        if (! $(div).parent().is('.hover')) {
    6060                                                return;
    6161                                        }
  • trunk/web/javascript/jquery/jquery.transmenu.min.js

    r9507 r12818  
    1 
    2 (function($)
    3 {var defaults={onClick:function(){$(this).find('>a').each(function(){if(this.href)
    4 {window.location=this.href;}});},arrow_char:'►',selected_char:'✓',subDelay:300,direction:'down',mainDelay:10};var transMenuSettings;$.fn.transMenu=function(options)
    5 {var shown=false;var liOffset=2;transMenuSettings=$.extend({},defaults,options);var hideDIV=function(div,delay){if(div.timer&&!div.isVisible){clearTimeout(div.timer);}else if(div.timer){return;}
    6 if(div.isVisible){div.timer=setTimeout(function(){$(div).find('ul li').unbind('mouseover',liHoverIn).unbind('mouseout',liHoverOut).unbind('click',transMenuSettings.onClick);$(div).hide();div.isVisible=false;div.timer=null;},delay);}};var showDIV=function(div,delay){if(div.timer){clearTimeout(div.timer);}
    7 if(!div.isVisible){div.timer=setTimeout(function(){if(!$('div').parent().is('.hover')){return;}
    8 $(div).find('ul li').mouseover(liHoverIn).mouseout(liHoverOut).click(transMenuSettings.onClick);if(!$(div).parent().is('.main')){$(div).css('left',$(div).parent().parent().width()-liOffset);}
    9 if(transMenuSettings.direction=='up'){$(div).css('top',($(div).height()*-1)+$(div).parent().parent().height());}
    10 div.isVisible=true;$(div).show();div.timer=null;},delay);}};var testHandleHover=function(e){var p=(e.type=="mouseover"?e.fromElement:e.toElement)||e.relatedTarget;while(p&&p!=this){try{p=p.parentNode;}catch(e){p=this;}}
    11 if(p==this){return false;}
    12 return true;};var mainHoverIn=function(e){$(this).addClass('hover').siblings('li.hover').removeClass('hover');if(shown){hoverIn(this,transMenuSettings.mainDelay);}};var liHoverIn=function(e){if(!testHandleHover(e)){return false;}
    13 if(e.target!=this){if(!isChild(this,e.target)){return;}}
    14 hoverIn(this,transMenuSettings.subDelay);};var hoverIn=function(li,delay){var n=li.parentNode.firstChild;for(;n;n=n.nextSibling){if(n.nodeType==1&&n.nodeName.toUpperCase()=='LI'){var div=getOneChild(n,'DIV');if(div&&div.timer&&!div.isVisible){clearTimeout(div.timer);div.timer=null;}}}
    15 var pNode=li.parentNode;for(;pNode;pNode=pNode.parentNode){if(pNode.nodeType==1&&pNode.nodeName.toUpperCase()=='DIV'){if(pNode.timer){clearTimeout(pNode.timer);pNode.timer=null;$(pNode.parentNode).addClass('hover');}}}
    16 $(li).addClass('hover');var innerDiv=$(li).children('div');innerDiv=innerDiv.length?innerDiv[0]:null;if(innerDiv&&innerDiv.isVisible){if(innerDiv.timer){clearTimeout(innerDiv.timer);innerDiv.timer=null;}else{return;}}
    17 $(li.parentNode.getElementsByTagName('DIV')).each(function(){if(this!=innerDiv&&this.isVisible){hideDIV(this,delay);$(this.parentNode).removeClass('hover');}});if(innerDiv){showDIV(innerDiv,delay);}};var liHoverOut=function(e){if(!testHandleHover(e)){return false;}
    18 if(e.target!=this){if(!isChild(this,e.target)){return;}}
    19 var div=getOneChild(this,'DIV');if(!div){$(this).removeClass('hover');}else{if(!div.isVisible){$(this).removeClass('hover');}}};var mainHoverOut=function(e){var div=getOneChild(this,'DIV');var relTarget=e.relatedTarget||e.toElement;var p;if(!shown){$(this).removeClass('hover');}else if(!div&&relTarget){p=$(e.target).parents('UL.trans_menu');if(p.contains(relTarget)){$(this).removeClass('hover');}}else if(relTarget){p=$(e.target).parents('UL.trans_menu');if(!div.isVisible&&(p.contains(relTarget))){$(this).removeClass('hover');}}};var mainClick=function(){var div=getOneChild(this,'DIV');if(div&&div.isVisible){clean();$(this).addClass('hover');}else{hoverIn(this,transMenuSettings.mainDelay);shown=true;$('ul.trans_menu li').addClass('active');$(document).bind('mousedown',checkMouse);}};var checkMouse=function(e){var vis=false;$(e.target).parents('UL.trans_menu').find('div').each(function(){if(this.isVisible){vis=true;}});if(!vis){clean();}};var clean=function(){$('ul.trans_menu div.outerbox').each(function(){if(this.timer){clearTimeout(this.timer);this.timer=null;}
    20 if(this.isVisible){$(this).hide();this.isVisible=false;}});$('ul.trans_menu li').removeClass('hover');$('ul.trans_menu>li li').unbind('mouseover',liHoverIn).unbind('mouseout',liHoverOut).unbind('click',transMenuSettings.onClick);$(document).unbind('mousedown',checkMouse);shown=false;$('ul.trans_menu li').removeClass('active');};var getOneChild=function(elem,name){if(!elem){return null;}
    21 var n=elem.firstChild;for(;n;n=n.nextSibling){if(n.nodeType==1&&n.nodeName.toUpperCase()==name){return n;}}
    22 return null;};var isChild=function(elem,childElem){var n=elem.firstChild;for(;n;n=n.nextSibling){if(n==childElem){return true;}}
    23 return false;};return this.each(function(){if(window.Node&&Node.prototype&&!Node.prototype.contains){Node.prototype.contains=function(arg){return!!(this.compareDocumentPosition(arg)&16);};}
    24 if(!$(this).is('.trans_menu')){$(this).addClass('trans_menu');}
    25 $('ul',this).shadowBox();$(this).bind('closemenu',function(){clean();});var liElems=$(this).children('li');for(var j=0;j<liElems.length;j++){if(getOneChild(getOneChild(getOneChild(liElems[j],'DIV'),'UL'),'LI')){$(liElems[j]).click(mainClick);}}
    26 $(liElems).hover(mainHoverIn,mainHoverOut).addClass('main').find('>div').addClass('inner');if(transMenuSettings.arrow_char){var arrow_markup=$("<span class='arrow'>"+transMenuSettings.arrow_char+'</span>');if($.browser.mozilla&&+$.browser.version.replace(/\./g,'').slice(0,3)<191){arrow_markup.css('margin-top','-13px');}
    27 $('div.inner div.outerbox',this).before(arrow_markup);}
    28 });};$.fn.transMenu.setDefaults=function(o){$.extend(defaults,o);};$.fn.shadowBox=function(){return this.each(function(){var outer=$('<div class="outerbox"></div>').get(0);if($(this).css('position')=='absolute'){$(outer).css({position:'relative',width:this.offsetWidth,height:this.offsetHeight});}else{$(outer).css('position','absolute');}
    29 $(this).addClass('innerBox').wrap(outer).before('<div class="shadowbox1"></div><div class="shadowbox2"></div><div class="shadowbox3"></div>');});};$.fn.selectMenuItem=function(){if(this.find('span.selected').length==0){this.prepend($("<span class='selected'>"+transMenuSettings.selected_char+"</span>"));}
    30 return this;};$.fn.deselectMenuItem=function(){return this.find('span.selected').remove();};$.fn.menuItemIsSelected=function(){return(this.find('span.selected').length>0);};$.fn.deselectMenuSiblings=function(){this.parent().find('span.selected').remove();this.selectMenuItem();return this;};})(jQuery);
     1(function(b){var c={onClick:function(){b(this).find(">a").each(function(){if(this.href){window.location=this.href}})},arrow_char:"&#x25BA;",selected_char:"&#x2713;",subDelay:300,direction:"down",mainDelay:10};var a;b.fn.transMenu=function(s){var q=false;var j=2;a=b.extend({},c,s);var k=function(u,t){if(u.timer&&!u.isVisible){clearTimeout(u.timer)}else{if(u.timer){return}}if(u.isVisible){u.timer=setTimeout(function(){b(u).find("ul li").unbind("mouseover",r).unbind("mouseout",h).unbind("click",a.onClick);b(u).hide();u.isVisible=false;u.timer=null},t)}};var g=function(u,t){if(u.timer){clearTimeout(u.timer)}if(!u.isVisible){u.timer=setTimeout(function(){if(!b(u).parent().is(".hover")){return}b(u).find("ul li").mouseover(r).mouseout(h).click(a.onClick);if(!b(u).parent().is(".main")){b(u).css("left",b(u).parent().parent().width()-j)}if(a.direction=="up"){b(u).css("top",(b(u).height()*-1)+b(u).parent().parent().height())}u.isVisible=true;b(u).show();u.timer=null},t)}};var n=function(u){var t=(u.type=="mouseover"?u.fromElement:u.toElement)||u.relatedTarget;while(t&&t!=this){try{t=t.parentNode}catch(u){t=this}}if(t==this){return false}return true};var i=function(t){b(this).addClass("hover").siblings("li.hover").removeClass("hover");if(q){o(this,a.mainDelay)}};var r=function(t){if(!n(t)){return false}if(t.target!=this){if(!e(this,t.target)){return}}o(this,a.subDelay)};var o=function(t,u){var y=t.parentNode.firstChild;for(;y;y=y.nextSibling){if(y.nodeType==1&&y.nodeName.toUpperCase()=="LI"){var x=d(y,"DIV");if(x&&x.timer&&!x.isVisible){clearTimeout(x.timer);x.timer=null}}}var v=t.parentNode;for(;v;v=v.parentNode){if(v.nodeType==1&&v.nodeName.toUpperCase()=="DIV"){if(v.timer){clearTimeout(v.timer);v.timer=null;b(v.parentNode).addClass("hover")}}}b(t).addClass("hover");var w=b(t).children("div");w=w.length?w[0]:null;if(w&&w.isVisible){if(w.timer){clearTimeout(w.timer);w.timer=null}else{return}}b(t.parentNode.getElementsByTagName("DIV")).each(function(){if(this!=w&&this.isVisible){k(this,u);b(this.parentNode).removeClass("hover")}});if(w){g(w,u)}};var h=function(t){if(!n(t)){return false}if(t.target!=this){if(!e(this,t.target)){return}}var u=d(this,"DIV");if(!u){b(this).removeClass("hover")}else{if(!u.isVisible){b(this).removeClass("hover")}}};var l=function(v){var w=d(this,"DIV");var u=v.relatedTarget||v.toElement;var t;if(!q){b(this).removeClass("hover")}else{if(!w&&u){t=b(v.target).parents("UL.trans_menu");if(t.contains(u)){b(this).removeClass("hover")}}else{if(u){t=b(v.target).parents("UL.trans_menu");if(!w.isVisible&&(t.contains(u))){b(this).removeClass("hover")}}}}};var f=function(){var t=d(this,"DIV");if(t&&t.isVisible){p();b(this).addClass("hover")}else{o(this,a.mainDelay);q=true;b("ul.trans_menu li").addClass("active");b(document).bind("mousedown",m)}};var m=function(u){var t=false;b(u.target).parents("UL.trans_menu").find("div").each(function(){if(this.isVisible){t=true}});if(!t){p()}};var p=function(){b("ul.trans_menu div.outerbox").each(function(){if(this.timer){clearTimeout(this.timer);this.timer=null}if(this.isVisible){b(this).hide();this.isVisible=false}});b("ul.trans_menu li").removeClass("hover");b("ul.trans_menu>li li").unbind("mouseover",r).unbind("mouseout",h).unbind("click",a.onClick);b(document).unbind("mousedown",m);q=false;b("ul.trans_menu li").removeClass("active")};var d=function(u,t){if(!u){return null}var v=u.firstChild;for(;v;v=v.nextSibling){if(v.nodeType==1&&v.nodeName.toUpperCase()==t){return v}}return null};var e=function(u,t){var v=u.firstChild;for(;v;v=v.nextSibling){if(v==t){return true}}return false};return this.each(function(){if(window.Node&&Node.prototype&&!Node.prototype.contains){Node.prototype.contains=function(w){return !!(this.compareDocumentPosition(w)&16)}}if(!b(this).is(".trans_menu")){b(this).addClass("trans_menu")}b("ul",this).shadowBox();b(this).bind("closemenu",function(){p()});var t=b(this).children("li");for(var u=0;u<t.length;u++){if(d(d(d(t[u],"DIV"),"UL"),"LI")){b(t[u]).click(f)}}b(t).hover(i,l).addClass("main").find(">div").addClass("inner");if(a.arrow_char){var v=b("<span class='arrow'>"+a.arrow_char+"</span>");if(b.browser.mozilla&&+b.browser.version.replace(/\./g,"").slice(0,3)<191){v.css("margin-top","-13px")}b("div.inner div.outerbox",this).before(v)}b(this).wrap('<div class="main_container"></div>').after('<div style="clear: both; visibility: hidden;"></div>')})};b.fn.transMenu.setDefaults=function(d){b.extend(c,d)};b.fn.shadowBox=function(){return this.each(function(){var d=b('<div class="outerbox"></div>').get(0);if(b(this).css("position")=="absolute"){b(d).css({position:"relative",width:this.offsetWidth,height:this.offsetHeight})}else{b(d).css("position","absolute")}b(this).addClass("innerBox").wrap(d).before('<div class="shadowbox1"></div><div class="shadowbox2"></div><div class="shadowbox3"></div>')})};b.fn.selectMenuItem=function(){if(this.find("span.selected").length==0){this.prepend(b("<span class='selected'>"+a.selected_char+"</span>"))}return this};b.fn.deselectMenuItem=function(){return this.find("span.selected").remove()};b.fn.menuItemIsSelected=function(){return(this.find("span.selected").length>0)};b.fn.deselectMenuSiblings=function(){this.parent().find("span.selected").remove();this.selectMenuItem();return this}})(jQuery);
Note: See TracChangeset for help on using the changeset viewer.