(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("
").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.topn.bottom,right:o.position.left+o.width>n.right,left:o.position.left0?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.visible),p.removeClass(b.loading),"pop"==s.animation&&e.fn.popIn!==o?p.stop().popIn(s.duration,s.easing):p.stop().fadeIn(s.duration,s.easing),"click"==s.event&&s.clicktoClose&&(l.debug("Binding popup close event"),e(n).on("click."+C,l.gracefully.hide)),e.proxy(s.onShow,p)()},hide:function(){u.removeClass(b.visible),p.is(":visible")&&(l.debug("Hiding pop-up"),"pop"==s.animation&&e.fn.popOut!==o?p.stop().popOut(s.duration,s.easing,function(){p.hide()}):p.stop().fadeOut(s.duration,s.easing)),"click"==s.event&&s.clicktoClose&&e(n).off("click."+C),e.proxy(s.onHide,p)(),s.inline||l.remove()},gracefully:{hide:function(t){0===e(t.target).closest(v.popup).size()&&l.hide()}},setting:function(e,t){return t===o?s[e]:(s[e]=t,o)},debug:function(){var e=[],t=s.moduleName+": "+arguments[0],n=[].slice.call(arguments,1),o=console.info||console.log||function(){};s.debug&&(e.push(t),o.apply(console,e.concat(n)))},error:function(){var e=[],t=s.moduleName+": "+arguments[0],n=[].slice.call(arguments,1),o=console.warn||console.log||function(){};s.debug&&(e.push(t),e.concat(n),o.apply(console,e.concat(n)))},invoke:function(t,n,i){var a,r;return i=i||[].slice.call(arguments,2),"string"==typeof t&&g!==o&&(t=t.split("."),a=t.length-1,e.each(t,function(t,n){return e.isPlainObject(g[n])&&t!=a?(g=g[n],!0):g[n]!==o?(r=g[n],!0):(l.error(s.errors.method),!1)})),e.isFunction(r)?r.apply(n,i):r}},h?a=l.invoke(r[0],this,Array.prototype.slice.call(r,1)):(g&&l.destroy(),l.initialize())}),a!==o?a:this},e.fn.popup.settings={moduleName:"Pop-up Module",debug:!0,namespace:"popup",onShow:function(){},onHide:function(){},content:!1,html:!1,title:!1,position:"top center",delay:0,inline:!0,duration:250,easing:"easeOutQuint",animation:"pop",errors:{content:"Warning: Your popup has no content specified",method:"The method you called is not defined.",recursion:"Popup attempted to reposition element to fit, but could not find an adequate position."},distanceAway:2,arrowOffset:0,maxRecursion:10,event:"hover",clicktoClose:!0,metadata:{content:"content",html:"html",title:"title",position:"position",arrowOffset:"arrowOffset"},className:{popup:"ui popup",visible:"visible",loading:"loading"},selector:{popup:".ui.popup"},template:function(e){var t="";return typeof e!==o&&(typeof e.title!==o&&e.title&&(t+=""+e.title+"
"),typeof e.content!==o&&e.content&&(t+=''+e.content+"
")),t}}})(jQuery,window,document);