|
|
!function(a,b,c,d){a.fn.popup=function(e){var f,g=a(this),h=a(c),i=a("body"),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,g=a.isPlainObject(e)?a.extend(!0,{},a.fn.popup.settings,e):a.extend({},a.fn.popup.settings),p=g.selector,q=g.className,r=g.error,s=g.metadata,t=g.namespace,u="."+g.namespace,v="module-"+t,w=a(this),x=g.target?a(g.target):w,y=a(b),z=g.inline?x.offsetParent():y,A=g.inline?x.next(g.selector.popup):y.children(g.selector.popup).last(),B=0,C=this,D=w.data(v);c={initialize:function(){c.debug("Initializing module",w),"click"==g.on?w.on("click",c.toggle):w.on(c.get.startEvent()+u,c.event.start).on(c.get.endEvent()+u,c.event.end),g.target&&c.debug("Target set to element",x),y.on("resize"+u,c.event.resize),c.instantiate()},instantiate:function(){c.verbose("Storing instance of module",c),D=c,w.data(v,D)},refresh:function(){g.inline?(A=x.next(p.popup),z=x.offsetParent()):(console.log("found by refresh"),A=y.children(p.popup).last())},destroy:function(){c.debug("Destroying previous module"),y.off(u),A.remove(),w.off(u).removeData(v)},event:{start:function(){c.timer=setTimeout(function(){c.is.hidden()&&c.show()},g.delay)},end:function(){clearTimeout(c.timer),c.is.visible()&&c.hide()},resize:function(){c.is.visible()&&c.set.position()}},create:function(){c.debug("Creating pop-up html");var b=w.data(s.html)||g.html,d=w.data(s.variation)||g.variation,e=w.data(s.title)||g.title,f=w.data(s.content)||w.attr("title")||g.content;b||f||e?(b||(b=g.template({title:e,content:f})),A=a("<div/>").addClass(q.popup).addClass(d).html(b),g.inline?(c.verbose("Inserting popup element inline",A),A.insertAfter(w)):(c.verbose("Appending popup element to body",A),A.appendTo(i)),a.proxy(g.onCreate,A)()):c.error(r.content)},toggle:function(){c.debug("Toggling pop-up"),c.is.hidden()?(c.hideAll(),c.show()):c.hide()},show:function(){c.debug("Showing pop-up",g.transition),c.exists()||c.create(),c.set.position(),w.addClass(q.visible),g.transition&&a.fn.transition!==d?A.transition(g.transition+" in",g.duration,c.bind.close):A.stop().fadeIn(g.duration,g.easing,c.bind.close),a.proxy(g.onShow,A)()},hide:function(){w.removeClass(q.visible),c.unbind.close(),c.is.visible()&&(c.debug("Hiding pop-up"),g.transition&&a.fn.transition!==d?A.transition(g.transition+" out",g.duration,c.reset):A.stop().fadeOut(g.duration,g.easing,c.reset)),a.proxy(g.onHide,A)()},hideAll:function(){a(p.popup).filter(":visible").popup("hide")},hideGracefully:function(b){0===a(b.target).closest(p.popup).size()&&c.hide()},exists:function(){return g.inline?0!==A.size():A.parent(i).size()},remove:function(){c.debug("Removing popup"),A.remove()},get:{startEvent:function(){return"hover"==g.on?"mouseenter":"focus"==g.on?"focus":void 0},endEvent:function(){return"hover"==g.on?"mouseleave":"focus"==g.on?"blur":void 0},offstagePosition:function(){var d={top:a(b).scrollTop(),bottom:a(b).scrollTop()+a(b).height(),left:0,right:a(b).width()},e={width:A.width(),height:A.outerHeight(),position:A.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}},set:{position:function(d,e){var f,h,i=(a(b).width(),a(b).height(),x.outerWidth()),j=x.outerHeight(),k=A.width(),l=A.outerHeight(),m=z.outerWidth(),n=z.outerHeight(),o=g.distanceAway,p=g.inline?x.position():x.offset();switch(d=d||w.data(s.position)||g.position,e=e||w.data(s.offset)||g.offset,g.inline&&("left center"==d||"right center"==d?(e+=parseInt(b.getComputedStyl
|