#3881 Right click torrent context menu does not work with Firefox / Firegestures / Ubuntu

This commit is contained in:
Mitchell Livingston 2011-01-15 17:00:52 +00:00
parent b9e4fcdb40
commit f74e3b5b3a
2 changed files with 9 additions and 8 deletions

View File

@ -1,7 +1 @@
(function($){var menu,shadow,trigger,content,hash,currentTarget;var defaults={menuStyle:{listStyle:'none',padding:'1px',margin:'0px',backgroundColor:'#fff',border:'1px solid #999',width:'100px'},itemStyle:{margin:'0px',color:'#000',display:'block',cursor:'default',padding:'3px',border:'1px solid #fff',backgroundColor:'transparent'},itemHoverStyle:{border:'1px solid #0a246a',backgroundColor:'#b6bdd2'},eventPosX:'pageX',eventPosY:'pageY',shadow:true,onContextMenu:null,onShowMenu:null};$.fn.contextMenu=function(id,options){if(!menu){menu=$('<div id="jqContextMenu"></div>').hide().css({position:'absolute',zIndex:'500'}).appendTo('body').bind('click',function(e){e.stopPropagation();});}
if(!shadow){shadow=$('<div></div>').css({backgroundColor:'#000',position:'absolute',opacity:0.2,zIndex:499}).appendTo('body').hide();}
hash=hash||[];hash.push({id:id,menuStyle:$.extend({},defaults.menuStyle,options.menuStyle||{}),itemStyle:$.extend({},defaults.itemStyle,options.itemStyle||{}),itemHoverStyle:$.extend({},defaults.itemHoverStyle,options.itemHoverStyle||{}),bindings:options.bindings||{},shadow:options.shadow||options.shadow===false?options.shadow:defaults.shadow,onContextMenu:options.onContextMenu||defaults.onContextMenu,onShowMenu:options.onShowMenu||defaults.onShowMenu,eventPosX:options.eventPosX||defaults.eventPosX,eventPosY:options.eventPosY||defaults.eventPosY});var index=hash.length-1;$(this).bind('contextmenu',function(e){var bShowContext=(!!hash[index].onContextMenu)?hash[index].onContextMenu(e):true;if(bShowContext)display(index,this,e,options);return false;});return this;};function display(index,trigger,e,options){var cur=hash[index];var top=e[cur.eventPosY];var left = e[cur.eventPosX];content=$('#'+cur.id).find('ul:first').clone(true);content.css(cur.menuStyle).find('li').css(cur.itemStyle).hover(function(){$(this).css(cur.itemHoverStyle);},function(){$(this).css(cur.itemStyle);}).find('img').css({verticalAlign:'middle',paddingRight:'2px'});menu.html(content);if(!!cur.onShowMenu)menu=cur.onShowMenu(e,menu);$.each(cur.bindings,function(id,func){$('#'+id,menu).bind('click',function(e){hide();func(trigger,currentTarget);});});if(top+menu.height()>$(window).height())top=top-menu.height();if(left+menu.width()>$(window).width())left=left-menu.width();menu.css({'left':left,'top':top}).show();if(cur.shadow)shadow.css({width:menu.width(),height:menu.height(),left:e.pageX+2,top:e.pageY+2}).show();$(document).one('click',hide);}
function hide(){menu.hide();shadow.hide();}
$.contextMenu={defaults:function(userDefaults){$.each(userDefaults,function(i,val){if(typeof val=='object'&&defaults[i]){$.extend(defaults[i],val);}
else defaults[i]=val;});}};})(jQuery);$(function(){$('div.contextMenu').hide();});
(function($){var _1,_2,_3,_4,_5,_6;var _7={menuStyle:{listStyle:"none",padding:"1px",margin:"0px",backgroundColor:"#fff",border:"1px solid #999",width:"100px"},itemStyle:{margin:"0px",color:"#000",display:"block",cursor:"default",padding:"3px",border:"1px solid #fff",backgroundColor:"transparent"},itemHoverStyle:{border:"1px solid #0a246a",backgroundColor:"#b6bdd2"},eventPosX:"pageX",eventPosY:"pageY",shadow:true,onContextMenu:null,onShowMenu:null};$.fn.contextMenu=function(id,_8){if(!_1){_1=$("<div id=\"jqContextMenu\"></div>").hide().css({position:"absolute",zIndex:"500"}).appendTo("body").bind("click",function(e){e.stopPropagation();});}if(!_2){_2=$("<div></div>").css({backgroundColor:"#000",position:"absolute",opacity:0.2,zIndex:499}).appendTo("body").hide();}_5=_5||[];_5.push({id:id,menuStyle:$.extend({},_7.menuStyle,_8.menuStyle||{}),itemStyle:$.extend({},_7.itemStyle,_8.itemStyle||{}),itemHoverStyle:$.extend({},_7.itemHoverStyle,_8.itemHoverStyle||{}),bindings:_8.bindings||{},shadow:_8.shadow||_8.shadow===false?_8.shadow:_7.shadow,onContextMenu:_8.onContextMenu||_7.onContextMenu,onShowMenu:_8.onShowMenu||_7.onShowMenu,eventPosX:_8.eventPosX||_7.eventPosX,eventPosY:_8.eventPosY||_7.eventPosY});var _9=_5.length-1;$(this).bind("contextmenu",function(e){var _a=(!!_5[_9].onContextMenu)?_5[_9].onContextMenu(e):true;if(_a){_b(_9,this,e,_8);}return false;});return this;};function _b(_c,_d,e,_e){var _f=_5[_c];var top=e[_f.eventPosY];var _10=e[_f.eventPosX];_4=$("#"+_f.id).find("ul:first").clone(true);_4.css(_f.menuStyle).find("li").css(_f.itemStyle).hover(function(){$(this).css(_f.itemHoverStyle);},function(){$(this).css(_f.itemStyle);}).find("img").css({verticalAlign:"middle",paddingRight:"2px"});_1.html(_4);if(!!_f.onShowMenu){_1=_f.onShowMenu(e,_1);}$.each(_f.bindings,function(id,_11){$("#"+id,_1).bind("click",function(e){_12();_11(_d,_6);});});if(top+_1.height()>$(window).height()){top=top-_1.height();}if(_10+_1.width()>$(window).width()){_10=_10-_1.width();}_1.css({"left":_10,"top":top}).show();if(_f.shadow){_2.css({width:_1.width(),height:_1.height(),left:e.pageX+2,top:e.pageY+2}).show();}setTimeout(function(){$(document).click(function(){$(document).unbind("click");_12();return false;});},0);};function _12(){_1.hide();_2.hide();};$.contextMenu={defaults:function(_13){$.each(_13,function(i,val){if(typeof val=="object"&&_7[i]){$.extend(_7[i],val);}else{_7[i]=val;}});}};})(jQuery);$(function(){$("div.contextMenu").hide();});

View File

@ -122,7 +122,14 @@
if( left + menu.width() > $(window).width() ) left = left - menu.width();
menu.css({'left':left,'top':top}).show();
if (cur.shadow) shadow.css({width:menu.width(),height:menu.height(),left:e.pageX+2,top:e.pageY+2}).show();
$(document).one('click', hide);
setTimeout( function() { // Delay for Mozilla
$(document).click( function() {
$(document).unbind('click');
hide();
return false;
});
}, 0);
}
function hide() {