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