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
8.0 KiB

  1. !function(a,b,c,d){a.fn.popup=function(e){var f,g=a(this),h=a(c),i=a.isPlainObject(e)?a.extend(!0,{},a.fn.popup.settings,e):a.fn.popup.settings,j=g.selector||"",k=(new Date).getTime(),l=[],m=arguments[0],n="string"==typeof m,o=[].slice.call(arguments,1);return g.each(function(){var c,e=a(this),g=a(b),p=e.offsetParent(),q=i.inline?e.next(i.selector.popup):g.children(i.selector.popup).last(),r=0,s="."+i.namespace,t=i.namespace+"-module",u=i.selector,v=i.className,w=i.error,x=i.metadata,y=i.namespace,z=this,A=e.data(t);c={initialize:function(){c.debug("Initializing module",e),"hover"==i.on?e.on("mouseenter"+s,c.event.mouseenter).on("mouseleave"+s,c.event.mouseleave):e.on(i.on+""+s,c.event[i.on]),g.on("resize"+s,c.event.resize),c.instantiate()},instantiate:function(){c.verbose("Storing instance of module",c),A=c,e.data(t,A)},refresh:function(){q=i.inline?e.next(u.popup):g.children(u.popup).last(),p=e.offsetParent()},destroy:function(){c.debug("Destroying previous module"),e.off(s).removeData(t)},event:{mouseenter:function(b){var d=this;c.timer=setTimeout(function(){a.proxy(c.toggle,d)(),a(d).hasClass(v.visible)&&b.stopPropagation()},i.delay)},mouseleave:function(){clearTimeout(c.timer),e.is(":visible")&&c.hide()},click:function(b){a.proxy(c.toggle,this)(),a(this).hasClass(v.visible)&&b.stopPropagation()},resize:function(){q.is(":visible")&&c.position()}},create:function(){c.debug("Creating pop-up html");var b=e.data(x.html)||i.html,d=e.data(x.variation)||i.variation,f=e.data(x.title)||i.title,g=e.data(x.content)||e.attr("title")||i.content;b||g||f?(b||(b=i.template({title:f,content:g})),q=a("<div/>").addClass(v.popup).addClass(d).html(b),i.inline?(c.verbose("Inserting popup element inline"),q.insertAfter(e)):(c.verbose("Appending popup element to body"),q.appendTo(a("body"))),a.proxy(i.onInit,q)()):c.error(w.content)},remove:function(){c.debug("Removing popup"),q.remove()},get:{offstagePosition:function(){var d={top:a(b).scrollTop(),bottom:a(b).scrollTop()+a(b).height(),left:0,right:a(b).width()},e={width:q.width(),height:q.outerHeight(),position:q.offset()},f={},g=[];return e.position&&(f={top:e.position.top<d.top,bottom:e.position.top+e.height>d.bottom,right:e.position.left+e.width>d.right,left:e.position.left<d.left}),c.verbose("Checking if outside viewable area",e.position),a.each(f,function(a,b){b&&g.push(a)}),g.length>0?g.join(" "):!1},nextPosition:function(a){switch(a){case"top left":a="bottom left";break;case"bottom left":a="top right";break;case"top right":a="bottom right";break;case"bottom right":a="top center";break;case"top center":a="bottom center";break;case"bottom center":a="right center";break;case"right center":a="left center";break;case"left center":a="top center"}return a}},toggle:function(){e=a(this),c.debug("Toggling pop-up"),c.refresh(),e.hasClass(v.visible)||("click"==i.on&&c.hideAll(),c.show())},position:function(d,f){var h,j,k=(a(b).width(),a(b).height(),e.outerWidth()),l=e.outerHeight(),m=q.width(),n=q.outerHeight(),o=i.inline?e.position():e.offset(),s=i.inline?p.outerWidth():g.outerWidth(),t=i.inline?p.outerHeight():g.outerHeight();switch(d=d||e.data(x.position)||i.position,f=f||e.data(x.arrowOffset)||i.arrowOffset,c.debug("Calculating offset for position",d),d){case"top left":h={bottom:t-o.top+i.distanceAway,right:s-o.left-k-f,top:"auto",left:"auto"};break;case"top center":h={bottom:t-o.top+i.distanceAway,left:o.left+k/2-m/2+f,top:"auto",right:"auto"};break;case"top right":h={top:"auto",bottom:t-o.top+i.distanceAway,left:o.left+f};break;case"left center":h={top:o.top+l/2-n/2,right:s-o.left+i.distanceAway-f,left:"auto",bottom:"auto"};break;case"right center":h={top:o.top+l/2-n/2,left:o.left+k+i.distanceAway+f,bottom:"auto",right:"auto"};break;case"bottom left":h={top:o.top+l+i.distanceAway,right:s-o.left-k-f,left:"auto",bottom:"auto"};break;case"bottom center":h={top:o.top+l+i.distanceAway,left:o.left+k/2-m/2+f,bottom:"auto",right:"auto"};break;case"bottom right":h={top:o.top+l+i.distanceAway,left:o.left+f,bottom:"auto",right:"auto"}}return a.extend(h,{width:q.width()+1}),q.attr("class",d+" "+v.po