/*! * # Semantic UI 2.2.2 - Popup * http://github.com/semantic-org/semantic-ui/ * * * Released under the MIT license * http://opensource.org/licenses/MIT * */ !function(t,e,o,n){"use strict";e="undefined"!=typeof e&&e.Math==Math?e:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")(),t.fn.popup=function(i){var r,a=t(this),s=t(o),p=t(e),l=t("body"),u=a.selector||"",c=!0,d=(new Date).getTime(),f=[],g=arguments[0],h="string"==typeof g,m=[].slice.call(arguments,1);return a.each(function(){var a,v,b,w,y,T,C=t.isPlainObject(i)?t.extend(!0,{},t.fn.popup.settings,i):t.extend({},t.fn.popup.settings),P=C.selector,x=C.className,k=C.error,S=C.metadata,E=C.namespace,A="."+C.namespace,D="module-"+E,O=t(this),j=t(C.context),F=t(C.scrollContext),R=t(C.boundary),H=C.target?t(C.target):O,N=0,M=!1,W=!1,G=this,I=O.data(D);T={initialize:function(){T.debug("Initializing",O),T.createID(),T.bind.events(),!T.exists()&&C.preserve&&T.create(),T.observeChanges(),T.instantiate()},instantiate:function(){T.verbose("Storing instance",T),I=T,O.data(D,I)},observeChanges:function(){"MutationObserver"in e&&(b=new MutationObserver(T.event.documentChanged),b.observe(o,{childList:!0,subtree:!0}),T.debug("Setting up mutation observer",b))},refresh:function(){C.popup?a=t(C.popup).eq(0):C.inline&&(a=H.nextAll(P.popup).eq(0),C.popup=a),C.popup?(a.addClass(x.loading),v=T.get.offsetParent(),a.removeClass(x.loading),C.movePopup&&T.has.popup()&&T.get.offsetParent(a)[0]!==v[0]&&(T.debug("Moving popup to the same offset parent as activating element"),a.detach().appendTo(v))):v=C.inline?T.get.offsetParent(H):T.has.popup()?T.get.offsetParent(a):l,v.is("html")&&v[0]!==l[0]&&(T.debug("Setting page as offset parent"),v=l),T.get.variation()&&T.set.variation()},reposition:function(){T.refresh(),T.set.position()},destroy:function(){T.debug("Destroying previous module"),b&&b.disconnect(),a&&!C.preserve&&T.removePopup(),clearTimeout(T.hideTimer),clearTimeout(T.showTimer),T.unbind.close(),T.unbind.events(),O.removeData(D)},event:{start:function(e){var o=t.isPlainObject(C.delay)?C.delay.show:C.delay;clearTimeout(T.hideTimer),W||(T.showTimer=setTimeout(T.show,o))},end:function(){var e=t.isPlainObject(C.delay)?C.delay.hide:C.delay;clearTimeout(T.showTimer),T.hideTimer=setTimeout(T.hide,e)},touchstart:function(t){W=!0,T.show()},resize:function(){T.is.visible()&&T.set.position()},documentChanged:function(e){[].forEach.call(e,function(e){e.removedNodes&&[].forEach.call(e.removedNodes,function(e){(e==G||t(e).find(G).length>0)&&(T.debug("Element removed from DOM, tearing down events"),T.destroy())})})},hideGracefully:function(e){var n=t(e.target),i=t.contains(o.documentElement,e.target),r=n.closest(P.popup).length>0;e&&!r&&i?(T.debug("Click occurred outside popup hiding popup"),T.hide()):T.debug("Click was inside popup, keeping popup open")}},create:function(){var e=T.get.html(),o=T.get.title(),n=T.get.content();e||n||o?(T.debug("Creating pop-up html"),e||(e=C.templates.popup({title:o,content:n})),a=t("
").addClass(x.popup).data(S.activator,O).html(e),C.inline?(T.verbose("Inserting popup element inline",a),a.insertAfter(O)):(T.verbose("Appending popup element to body",a),a.appendTo(j)),T.refresh(),T.set.variation(),C.hoverable&&T.bind.popup(),C.onCreate.call(a,G)):0!==H.next(P.popup).length?(T.verbose("Pre-existing popup found"),C.inline=!0,C.popup=H.next(P.popup).data(S.activator,O),T.refresh(),C.hoverable&&T.bind.popup()):C.popup?(t(C.popup).data(S.activator,O),T.verbose("Used popup specified in settings"),T.refresh(),C.hoverable&&T.bind.popup()):T.debug("No content specified skipping display",G)},createID:function(){y=(Math.random().toString(16)+"000000000").substr(2,8),w="."+y,T.verbose("Creating unique id for element",y)},toggle:function(){T.debug("Toggling pop-up"),T.is.hidden()?(T.debug("Popup is hidden, showing pop-up"),T.unbind.close(),T.show()):(T.debug("Popup is visible, hiding pop-up"),T.hide())},show:function(t){if(t=t||function(){},T.debug("Showing pop-up",C.transition),T.is.hidden()&&(!T.is.active()||!T.is.dropdown())){if(T.exists()||T.create(),C.onShow.call(a,G)===!1)return void T.debug("onShow callback returned false, cancelling popup animation");C.preserve||C.popup||T.refresh(),a&&T.set.position()&&(T.save.conditions(),C.exclusive&&T.hideAll(),T.animate.show(t))}},hide:function(t){if(t=t||function(){},T.is.visible()||T.is.animating()){if(C.onHide.call(a,G)===!1)return void T.debug("onHide callback returned false, cancelling popup animation");T.remove.visible(),T.unbind.close(),T.restore.conditions(),T.animate.hide(t)}},hideAll:function(){t(P.popup).filter("."+x.visible).each(function(){t(this).data(S.activator).popup("hide")})},exists:function(){return a?C.inline||C.popup?T.has.popup():a.closest(j).length>=1?!0:!1:!1},removePopup:function(){T.has.popup()&&!C.popup&&(T.debug("Removing popup",a),a.remove(),a=n,C.onRemove.call(a,G))},save:{conditions:function(){T.cache={title:O.attr("title")},T.cache.title&&O.removeAttr("title"),T.verbose("Saving original attributes",T.cache.title)}},restore:{conditions:function(){return T.cache&&T.cache.title&&(O.attr("title",T.cache.title),T.verbose("Restoring original attributes",T.cache.title)),!0}},supports:{svg:function(){return typeof SVGGraphicsElement===n}},animate:{show:function(e){e=t.isFunction(e)?e:function(){},C.transition&&t.fn.transition!==n&&O.transition("is supported")?(T.set.visible(),a.transition({animation:C.transition+" in",queue:!1,debug:C.debug,verbose:C.verbose,duration:C.duration,onComplete:function(){T.bind.close(),e.call(a,G),C.onVisible.call(a,G)}})):T.error(k.noTransition)},hide:function(e){return e=t.isFunction(e)?e:function(){},T.debug("Hiding pop-up"),C.onHide.call(a,G)===!1?void T.debug("onHide callback returned false, cancelling popup animation"):void(C.transition&&t.fn.transition!==n&&O.transition("is supported")?a.transition({animation:C.transition+" out",queue:!1,duration:C.duration,debug:C.debug,verbose:C.verbose,onComplete:function(){T.reset(),e.call(a,G),C.onHidden.call(a,G)}}):T.error(k.noTransition))}},change:{content:function(t){a.html(t)}},get:{html:function(){return O.removeData(S.html),O.data(S.html)||C.html},title:function(){return O.removeData(S.title),O.data(S.title)||C.title},content:function(){return O.removeData(S.content),O.data(S.content)||O.attr("title")||C.content},variation:function(){return O.removeData(S.variation),O.data(S.variation)||C.variation},popup:function(){return a},popupOffset:function(){return a.offset()},calculations:function(){var t,o=H[0],n=R[0]==e,i=C.inline||C.popup&&C.movePopup?H.position():H.offset(),r=n?{top:0,left:0}:R.offset(),s={},l=n?{top:p.scrollTop(),left:p.scrollLeft()}:{top:0,left:0};return s={target:{element:H[0],width:H.outerWidth(),height:H.outerHeight(),top:i.top,left:i.left,margin:{}},popup:{width:a.outerWidth(),height:a.outerHeight()},parent:{width:v.outerWidth(),height:v.outerHeight()},screen:{top:r.top,left:r.left,scroll:{top:l.top,left:l.left},width:R.width(),height:R.height()}},C.setFluidWidth&&T.is.fluid()&&(s.container={width:a.parent().outerWidth()},s.popup.width=s.container.width),s.target.margin.top=C.inline?parseInt(e.getComputedStyle(o).getPropertyValue("margin-top"),10):0,s.target.margin.left=C.inline?T.is.rtl()?parseInt(e.getComputedStyle(o).getPropertyValue("margin-right"),10):parseInt(e.getComputedStyle(o).getPropertyValue("margin-left"),10):0,t=s.screen,s.boundary={top:t.top+t.scroll.top,bottom:t.top+t.scroll.top+t.height,left:t.left+t.scroll.left,right:t.left+t.scroll.left+t.width},s},id:function(){return y},startEvent:function(){return"hover"==C.on?"mouseenter":"focus"==C.on?"focus":!1},scrollEvent:function(){return"scroll"},endEvent:function(){return"hover"==C.on?"mouseleave":"focus"==C.on?"blur":!1},distanceFromBoundary:function(t,e){var o,n,i={};return e=e||T.get.calculations(),o=e.popup,n=e.boundary,t&&(i={top:t.top-n.top,left:t.left-n.left,right:n.right-(t.left+o.width),bottom:n.bottom-(t.top+o.height)},T.verbose("Distance from boundaries determined",t,i)),i},offsetParent:function(e){var o=e!==n?e[0]:O[0],i=o.parentNode,r=t(i);if(i)for(var a="none"===r.css("transform"),s="static"===r.css("position"),p=r.is("html");i&&!p&&s&&a;)i=i.parentNode,r=t(i),a="none"===r.css("transform"),s="static"===r.css("position"),p=r.is("html");return r&&r.length>0?r:t()},positions:function(){return{"top left":!1,"top center":!1,"top right":!1,"bottom left":!1,"bottom center":!1,"bottom right":!1,"left center":!1,"right center":!1}},nextPosition:function(t){var e=t.split(" "),o=e[0],n=e[1],i={top:"bottom",bottom:"top",left:"right",right:"left"},r={left:"center",center:"right",right:"left"},a={"top left":"top center","top center":"top right","top right":"right center","right center":"bottom right","bottom right":"bottom center","bottom center":"bottom left","bottom left":"left center","left center":"top left"},s="top"==o||"bottom"==o,p=!1,l=!1,u=!1;return M||(T.verbose("All available positions available"),M=T.get.positions()),T.debug("Recording last position tried",t),M[t]=!0,"opposite"===C.prefer&&(u=[i[o],n],u=u.join(" "),p=M[u]===!0,T.debug("Trying opposite strategy",u)),"adjacent"===C.prefer&&s&&(u=[o,r[n]],u=u.join(" "),l=M[u]===!0,T.debug("Trying adjacent strategy",u)),(l||p)&&(T.debug("Using backup position",u),u=a[t]),u}},set:{position:function(t,e){if(0===H.length||0===a.length)return void T.error(k.notFound);var o,i,r,s,p,l,u,c;if(e=e||T.get.calculations(),t=t||O.data(S.position)||C.position,o=O.data(S.offset)||C.offset,i=C.distanceAway,r=e.target,s=e.popup,p=e.parent,0===r.width&&0===r.height&&!T.is.svg(r.element))return T.debug("Popup target is hidden, no action taken"),!1;switch(C.inline&&(T.debug("Adding margin to calculation",r.margin),"left center"==t||"right center"==t?(o+=r.margin.top,i+=-r.margin.left):"top left"==t||"top center"==t||"top right"==t?(o+=r.margin.left,i-=r.margin.top):(o+=r.margin.left,i+=r.margin.top)),T.debug("Determining popup position from calculations",t,e),T.is.rtl()&&(t=t.replace(/left|right/g,function(t){return"left"==t?"right":"left"}),T.debug("RTL: Popup position updated",t)),N==C.maxSearchDepth&&"string"==typeof C.lastResort&&(t=C.lastResort),t){case"top left":l={top:"auto",bottom:p.height-r.top+i,left:r.left+o,right:"auto"};break;case"top center":l={bottom:p.height-r.top+i,left:r.left+r.width/2-s.width/2+o,top:"auto",right:"auto"};break;case"top right":l={bottom:p.height-r.top+i,right:p.width-r.left-r.width-o,top:"auto",left:"auto"};break;case"left center":l={top:r.top+r.height/2-s.height/2+o,right:p.width-r.left+i,left:"auto",bottom:"auto"};break;case"right center":l={top:r.top+r.height/2-s.height/2+o,left:r.left+r.width+i,bottom:"auto",right:"auto"};break;case"bottom left":l={top:r.top+r.height+i,left:r.left+o,bottom:"auto",right:"auto"};break;case"bottom center":l={top:r.top+r.height+i,left:r.left+r.width/2-s.width/2+o,bottom:"auto",right:"auto"};break;case"bottom right":l={top:r.top+r.height+i,right:p.width-r.left-r.width-o,left:"auto",bottom:"auto"}}if(l===n&&T.error(k.invalidPosition,t),T.debug("Calculated popup positioning values",l),a.css(l).removeClass(x.position).addClass(t).addClass(x.loading),u=T.get.popupOffset(),c=T.get.distanceFromBoundary(u,e),T.is.offstage(c,t)){if(T.debug("Position is outside viewport",t),N