You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

0 lines
1.3 KiB

2 years ago
  1. jQuery.fn.contextPopup=function(n){function i(n){var i=$('<ul class="'+t.contextMenuClass+'"><div class="'+t.gutterLineClass+'"><\/div><\/ul>').appendTo(document.body);return t.title&&$('<li class="'+t.headerClass+'"><\/li>').text(t.title).appendTo(i),$.each(t.items,function(r,u){var o,f,e;u?(o='<li><a href="#"><span><\/span><\/a><\/li>',f=$(o).appendTo(i),u.icon&&(e=$("<img>"),e.attr("src",u.icon),e.insertBefore(f.find("span"))),f.find("span").text(u.label),u.isEnabled==undefined||u.isEnabled()?u.action&&f.find("a").click(function(){u.action(n)}):f.addClass("disabled")):$('<li class="'+t.seperatorClass+'"><\/li>').appendTo(i)}),i.find("."+t.headerClass).text(t.title),i}var t={contextMenuClass:"contextMenuPlugin",gutterLineClass:"gutterLine",headerClass:"header",seperatorClass:"divider",title:"",items:[]};return $.extend(t,n),this.bind("contextmenu",function(n){var t=i(n).show(),r=n.pageX+5,u=n.pageY,f;return u+t.height()>=$(window).height()&&(u-=t.height()),r+t.width()>=$(window).width()&&(r-=t.width()),t.css({zIndex:1000001,left:r,top:u}).bind("contextmenu",function(){return!1}),f=$("<div><\/div>").css({left:0,top:0,width:"100%",height:"100%",position:"absolute",zIndex:1e6}).appendTo(document.body).bind("contextmenu click",function(){return f.remove(),t.remove(),!1}),t.find("a").click(function(){f.remove();t.remove()}),!1}),this};