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

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