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