!function(a,b,c){var e=function(a,b){this.init(a,b)};e.prototype={init:function(a,b){this.ele=a,this.defaults={menu:[{text:"菜单一",callback:function(){}},{text:"菜单二",callback:function(){}}],target:function(){},width:100,itemHeight:28,bgColor:"#fff",color:"#333","class":"",fontSize:14,hoverBgColor:"#f5f5f5"},this.opts=c.extend(!0,{},this.defaults,b),this.random=(new Date).getTime()+parseInt(1e3*Math.random()),this.eventBind()},renderMenu:function(){var d,a=this,b="#uiContextMenu_"+this.random;c(b).length>0||(a=this,d='<ul class="ul-context-menu" id="uiContextMenu_'+this.random+'">',c.each(this.opts.menu,function(a,b){d+=b.icon?'<li class="ui-context-menu-item" style="'+b.css+'" title="'+(b.title?b.title:"")+'"><a id="cmu_applink" href="javascript:void(0);" target="_blank"><img class="icon" src="'+b.icon+'" /><span>'+b.text+"</span></a></li>":'<li class="ui-context-menu-item" style="'+b.css+'"><a href="javascript:void(0);"><span>'+b.text+"</span></a></li>"}),d+="</ul>",c("body").append(d).find(".ul-context-menu").removeClass("show").addClass("hide"),this.initStyle(b),c(b).on("click",".ui-context-menu-item",function(b){a.menuItemClick(c(this)),b.stopPropagation(),app.ImgThat=null,app.MuluThat=null}))},initStyle:function(a){var b=this.opts;c(a).addClass(b.class),c(a).css({width:b.width,backgroundColor:b.bgColor}).find(".ui-context-menu-item a").css({color:b.color,fontSize:b.fontSize,height:b.itemHeight,lineHeight:b.itemHeight+"px"}).hover(function(){c(this).css({backgroundColor:b.hoverBgColor})},function(){c(this).css({backgroundColor:b.bgColor})})},menuItemClick:function(a){var b=this,c=a.index();a.parent(".ul-context-menu").removeClass("show").addClass("hide"),b.opts.menu[c].callback&&"function"==typeof b.opts.menu[c].callback&&b.opts.menu[c].callback(a)},setPosition:function(a){var b,d;$(".ul-context-menu").removeClass("show").addClass("hide"),b=a.pageX+2,d=a.pageY+2,$(window).width()-a.pageX<$(".ul-context-menu").width()&&(b=a.pageX-$(".ul-context-menu").width()+2),$(window).height()-a.pageY<$(".ul-context-menu").height()&&(d=a.pageY-$(".ul-context-menu").height()+2),app.ImgThat&&c("#uiContextMenu_"+this.random).css({left:b,top:d}).removeClass("hide").removeClass("hide").addClass("show")},eventBind:function(){var a=this;this.ele.on("contextmenu",function(b){b.preventDefault(),a.renderMenu(),a.setPosition(b),a.opts.target&&"function"==typeof a.opts.target&&a.opts.target(c(this))}),c(b).on("click",function(){c(".ul-context-menu").removeClass("show").addClass("hide"),app.ImgThat=null,app.MuluThat=null})}},c.fn.contextMenu=function(a){return new e(this,a),this}}(window,document,jQuery);