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