mirror of
https://github.com/transmission/transmission
synced 2024-12-27 01:57:52 +00:00
1 line
No EOL
2.2 KiB
JavaScript
1 line
No EOL
2.2 KiB
JavaScript
(function(a){function i(d,h,i,k){var l=f[d],m=i[l.eventPosY],n=i[l.eventPosX];e=a("#"+l.id).find("ul:first").clone(!0),e.css(l.menuStyle).find("li").css(l.itemStyle).hover(function(){a(this).css(l.itemHoverStyle)},function(){a(this).css(l.itemStyle)}).find("img").css({verticalAlign:"middle",paddingRight:"2px"}),b.html(e),!l.onShowMenu||(b=l.onShowMenu(i,b)),a.each(l.bindings,function(c,d){a("#"+c,b).bind("click",function(a){j(),d(h,g)})}),m+b.height()>a(window).height()&&(m=m-b.height()),n+b.width()>a(window).width()&&(n=n-b.width()),b.css({left:n,top:m}).show(),l.shadow&&c.css({width:b.width(),height:b.height(),left:i.pageX+2,top:i.pageY+2}).show(),setTimeout(function(){a(document).click(function(){return a(document).unbind("click"),j(),!1})},0)}function j(){b.hide(),c.hide()}var b,c,d,e,f,g,h={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:!0,onContextMenu:null,onShowMenu:null};a.fn.contextMenu=function(d,e){b||(b=a('<div id="jqContextMenu"></div>').hide().css({position:"absolute",zIndex:"500"}).appendTo("body").bind("click",function(a){a.stopPropagation()})),c||(c=a("<div></div>").css({backgroundColor:"#000",position:"absolute",opacity:.2,zIndex:499}).appendTo("body").hide()),f=f||[],f.push({id:d,menuStyle:a.extend({},h.menuStyle,e.menuStyle||{}),itemStyle:a.extend({},h.itemStyle,e.itemStyle||{}),itemHoverStyle:a.extend({},h.itemHoverStyle,e.itemHoverStyle||{}),bindings:e.bindings||{},shadow:e.shadow||e.shadow===!1?e.shadow:h.shadow,onContextMenu:e.onContextMenu||h.onContextMenu,onShowMenu:e.onShowMenu||h.onShowMenu,eventPosX:e.eventPosX||h.eventPosX,eventPosY:e.eventPosY||h.eventPosY});var g=f.length-1;return a(this).bind("contextmenu",function(a){var b=f[g].onContextMenu?f[g].onContextMenu(a):!0;return b&&i(g,this,a,e),!1}),this},a.contextMenu={defaults:function(b){a.each(b,function(b,c){typeof c=="object"&&h[b]?a.extend(h[b],c):h[b]=c})}}})(jQuery),$(function(){$("div.contextMenu").hide()}) |