1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-25 17:17:31 +00:00
transmission/web/javascript/jquery/jquery.contextmenu.min.js

1 line
No EOL
2.4 KiB
JavaScript

(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();});