/*! * # 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),j0}},is:{offstage:function(e,o){var n=[];return t.each(e,function(t,e){e<-P.jitter&&(y.debug("Position exceeds allowable distance from edge",t,e,o),n.push(t))}),n.length>0?!0:!1},svg:function(t){return y.supports.svg()&&t instanceof SVGGraphicsElement},active:function(){return E.hasClass(C.active)},animating:function(){return a!==n&&a.hasClass(C.animating)},fluid:function(){return a!==n&&a.hasClass(C.fluid)},visible:function(){return a!==n&&a.hasClass(C.visible)},dropdown:function(){return E.hasClass(C.dropdown)},hidden:function(){return!y.is.visible()},rtl:function(){return"rtl"==E.css("direction")}},reset:function(){y.remove.visible(),P.preserve?t.fn.transition!==n&&a.transition("remove transition"):y.removePopup()},setting:function(e,o){if(t.isPlainObject(e))t.extend(!0,P,e);else{if(o===n)return P[e];P[e]=o}},internal:function(e,o){if(t.isPlainObject(e))t.extend(!0,y,e);else{if(o===n)return y[e];y[e]=o}},debug:function(){!P.silent&&P.debug&&(P.performance?y.performance.log(arguments):(y.debug=Function.prototype.bind.call(console.info,console,P.name+":"),y.debug.apply(console,arguments)))},verbose:function(){!P.silent&&P.verbose&&P.debug&&(P.performance?y.performance.log(arguments):(y.verbose=Function.prototype.bind.call(console.info,console,P.name+":"),y.verbose.apply(console,arguments)))},error:function(){P.silent||(y.error=Function.prototype.bind.call(console.error,console,P.name+":"),y.error.apply(console,arguments))},performance:{log:function(t){var e,o,n;P.performance&&(e=(new Date).getTime(),n=d||e,o=e-n,d=e,f.push({Name:t[0],Arguments:[].slice.call(t,1)||"",Element:I,"Execution Time":o})),clearTimeout(y.performance.timer),y.performance.timer=setTimeout(y.performance.display,500)},display:function(){var e=P.name+":",o=0;d=!1,clearTimeout(y.performance.timer),t.each(f,function(t,e){o+=e["Execution Time"]}),e+=" "+o+"ms",u&&(e+=" '"+u+"'"),(console.group!==n||console.table!==n)&&f.length>0&&(console.groupCollapsed(e),console.table?console.table(f):t.each(f,function(t,e){console.log(e.Name+": "+e["Execution Time"]+"ms")}),console.groupEnd()),f=[]}},invoke:function(e,o,i){var a,s,p,l=G;return o=o||m,i=I||i,"string"==typeof e&&l!==n&&(e=e.split(/[\. ]/),a=e.length-1,t.each(e,function(o,i){var r=o!=a?i+e[o+1].charAt(0).toUpperCase()+e[o+1].slice(1):e;if(t.isPlainObject(l[r])&&o!=a)l=l[r];else{if(l[r]!==n)return s=l[r],!1;if(!t.isPlainObject(l[i])||o==a)return l[i]!==n?(s=l[i],!1):!1;l=l[i]}})),t.isFunction(s)?p=s.apply(i,o):s!==n&&(p=s),t.isArray(r)?r.push(p):r!==n?r=[r,p]:p!==n&&(r=p),s}},h?(G===n&&y.initialize(),y.invoke(g)):(G!==n&&G.invoke("destroy"),y.initialize())}),r!==n?r:this},t.fn.popup.settings={name:"Popup",silent:!1,debug:!1,verbose:!1,performance:!0,namespace:"popup",onCreate:function(){},onRemove:function(){},onShow:function(){},onVisible:function(){},onHide:function(){},onUnplaceable:function(){},onHidden:function(){},autoRemove:!0,on:"hover",addTouchEvents:!0,position:"top left",variation:"",movePopup:!0,target:!1,popup:!1,inline:!1,preserve:!1,hoverable:!1,content:!1,html:!1,title:!1,closable:!0,hideOnScroll:"auto",exclusive:!1,context:"body",prefer:"opposite",lastResort:!1,delay:{show:50,hide:70},setFluidWidth:!0,duration:200,transition:"scale",distanceAway:0,jitter:2,offset:0,maxSearchDepth:15,error:{invalidPosition:"The position you specified is not a valid position",cannotPlace:"Popup does not fit within the boundaries of the viewport",method:"The method you called is not defined.",noTransition:"This module requires ui transitions ",notFound:"The target or popup you specified does not exist on the page"},metadata:{activator:"activator",content:"content",html:"html",offset:"offset",position:"position",title:"title",variation:"variation"},className:{active:"active",animating:"animating",dropdown:"dropdown",fluid:"fluid",loading:"loading",popup:"ui popup",position:"top left center bottom right",visible:"visible"},selector:{popup:".ui.popup"},templates:{escape:function(t){var e=/[&<>"'`]/g,o=/[&<>"'`]/,n={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},i=function(t){return n[t]};return o.test(t)?t.replace(e,i):t},popup:function(e){var o="",i=t.fn.popup.settings.templates.escape;return typeof e!==n&&(typeof e.title!==n&&e.title&&(e.title=i(e.title),o+='
'+e.title+"
"),typeof e.content!==n&&e.content&&(e.content=i(e.content),o+='
'+e.content+"
")),o}}}}(jQuery,window,document);