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

  1. (function(e,t,n,o){e.fn.popup=function(i){var a,s=e.extend(!0,{},e.fn.popup.settings,i),r=arguments||!1;return e(this).each(function(){var c,l,u=e(this),d=e(t),f=u.offsetParent(),p=s.inline?u.next(s.selector.popup):d.children(s.selector.popup).last(),m=0,g=u.data("module-"+s.namespace),h=g!==o&&"string"==typeof i,v=s.selector,b=s.className,y=s.errors,x=s.metadata,C=s.namespace;l={initialize:function(){"hover"==s.event?u.on("mouseenter."+C,l.event.mouseenter).on("mouseleave."+C,l.event.mouseleave):u.on(s.event+"."+C,l.event[s.event]),d.on("resize."+C,l.event.resize),u.data("module-"+C,l)},refresh:function(){p=s.inline?u.next(v.popup):d.children(v.popup).last(),f=u.offsetParent()},destroy:function(){l.debug("Destroying existing popups"),u.off("."+C),p.remove()},event:{mouseenter:function(t){var n=this;c=setTimeout(function(){e.proxy(l.toggle,n)(),e(n).hasClass(b.visible)&&t.stopPropagation()},s.delay)},mouseleave:function(){clearTimeout(c),u.is(":visible")&&l.hide()},click:function(t){e.proxy(l.toggle,this)(),e(this).hasClass(b.visible)&&t.stopPropagation()},resize:function(){p.is(":visible")&&l.position()}},create:function(){l.debug("Creating pop-up content");var t=u.data(x.html)||s.html,n=u.data(x.title)||s.title,o=u.data(x.content)||u.attr("title")||s.content;t||o||n?(t||(t=s.template({title:n,content:o})),p=e("<div/>").addClass(b.popup).html(t),s.inline?p.insertAfter(u):p.appendTo(e("body"))):l.error(y.content)},remove:function(){p.remove()},get:{offstagePosition:function(){var n={top:e(t).scrollTop(),bottom:e(t).scrollTop()+e(t).height(),left:0,right:e(t).width()},o={width:p.outerWidth(),height:p.outerHeight(),position:p.offset()},i={},a=[];return o.position&&(i={top:o.position.top<n.top,bottom:o.position.top+o.height>n.bottom,right:o.position.left+o.width>n.right,left:o.position.left<n.left}),e.each(i,function(e,t){t&&a.push(e)}),a.length>0?a.join(" "):!1},nextPosition:function(e){switch(e){case"top left":e="bottom left";break;case"bottom left":e="top right";break;case"top right":e="bottom right";break;case"bottom right":e="top center";break;case"top center":e="bottom center";break;case"bottom center":e="right center";break;case"right center":e="left center";break;case"left center":e="top center"}return e}},toggle:function(){u=e(this),l.debug("Toggling pop-up"),l.refresh(),0===p.size()&&l.create(),u.hasClass(b.visible)?l.hide():l.position()&&l.show()},position:function(n,o){var i,a,r=(e(t).width(),e(t).height(),u.outerWidth()),c=u.outerHeight(),g=p.outerWidth(),h=p.outerHeight(),v=s.inline?u.position():u.offset(),C=s.inline?f.outerWidth():d.outerWidth(),w=s.inline?f.outerHeight():d.outerHeight();switch(n=n||u.data(x.position)||s.position,o=o||u.data(x.arrowOffset)||s.arrowOffset,l.debug("Calculating offset for position",n),n){case"top left":i={top:"auto",bottom:w-v.top+s.distanceAway,left:v.left+o};break;case"top center":i={bottom:w-v.top+s.distanceAway,left:v.left+r/2-g/2+o,top:"auto",right:"auto"};break;case"top right":i={bottom:w-v.top+s.distanceAway,right:C-v.left-r-o,top:"auto",left:"auto"};break;case"left center":i={top:v.top+c/2-h/2,right:C-v.left+s.distanceAway-o,left:"auto",bottom:"auto"};break;case"right center":i={top:v.top+c/2-h/2,left:v.left+r+s.distanceAway+o,bottom:"auto",right:"auto"};break;case"bottom left":i={top:v.top+c+s.distanceAway,left:v.left+o,bottom:"auto",right:"auto"};break;case"bottom center":i={top:v.top+c+s.distanceAway,left:v.left+r/2-g/2+o,bottom:"auto",right:"auto"};break;case"bottom right":i={top:v.top+c+s.distanceAway,right:C-v.left-r-o,left:"auto",bottom:"auto"}}return e.extend(i,{width:p.width()+1}),p.removeAttr("style").removeClass("top right bottom left center").css(i).addClass(n).addClass(b.loading),a=l.get.offstagePosition(),a?(l.debug("Element is outside boundaries ",a),s.maxRecursion>m?(n=l.get.nextPosition(n),m++,l.debug("Trying new position: ",n),l.position(n)):(l.error(y.recursion),m=0,!1)):(l.debug("Position is on stage",n),m=0,!0)},show:function(){l.debug("Showing pop-up"),e(v.popup).filter(":visible").stop().fadeOut(200).prev(u).removeClass(b.visible),u.addClass(b.vis