/*! * # Semantic UI 2.0.0 - Popup * http://github.com/semantic-org/semantic-ui/ * * * Copyright 2015 Contributors * Released under the MIT license * http://opensource.org/licenses/MIT * */ !function(e,t,o,n){"use strict";e.fn.popup=function(i){var r,a=e(this),s=e(o),p=a.selector||"",l="ontouchstart"in o.documentElement,u=(new Date).getTime(),c=[],d=arguments[0],f="string"==typeof d,g=[].slice.call(arguments,1);return a.each(function(){var o,a,h,m,v,b=e.isPlainObject(i)?e.extend(!0,{},e.fn.popup.settings,i):e.extend({},e.fn.popup.settings),y=b.selector,w=b.className,T=b.error,P=b.metadata,C=b.namespace,k="."+b.namespace,x="module-"+C,S=e(this),E=e(b.context),O=b.target?e(b.target):S,j=e(t),A=e("body"),D=0,R=!1,F=this,H=S.data(x);v={initialize:function(){v.debug("Initializing",S),v.createID(),v.bind.events(),!v.exists()&&b.preserve&&v.create(),v.instantiate()},instantiate:function(){v.verbose("Storing instance",v),H=v,S.data(x,H)},refresh:function(){b.popup?o=e(b.popup).eq(0):b.inline&&(o=O.next(y.popup).eq(0),b.popup=o),b.popup?(o.addClass(w.loading),a=v.get.offsetParent(),o.removeClass(w.loading),b.movePopup&&v.has.popup()&&v.get.offsetParent(o)[0]!==a[0]&&(v.debug("Moving popup to the same offset parent as activating element"),o.detach().appendTo(a))):a=b.inline?v.get.offsetParent(O):v.has.popup()?v.get.offsetParent(o):A,a.is("html")&&(v.debug("Setting page as offset parent"),a=A)},reposition:function(){v.refresh(),v.set.position()},destroy:function(){v.debug("Destroying previous module"),o&&!b.preserve&&v.removePopup(),clearTimeout(v.hideTimer),clearTimeout(v.showTimer),j.off(h),S.off(k).removeData(x)},event:{start:function(t){var o=e.isPlainObject(b.delay)?b.delay.show:b.delay;clearTimeout(v.hideTimer),v.showTimer=setTimeout(v.show,o)},end:function(){var t=e.isPlainObject(b.delay)?b.delay.hide:b.delay;clearTimeout(v.showTimer),v.hideTimer=setTimeout(v.hide,t)},resize:function(){v.is.visible()&&v.set.position()}},create:function(){var t=v.get.html(),n=v.get.variation(),i=v.get.title(),r=v.get.content();t||r||i?(v.debug("Creating pop-up html"),t||(t=b.templates.popup({title:i,content:r})),o=e("
").addClass(w.popup).addClass(n).data(P.activator,S).html(t),n&&o.addClass(n),b.inline?(v.verbose("Inserting popup element inline",o),o.insertAfter(S)):(v.verbose("Appending popup element to body",o),o.appendTo(E)),v.refresh(),b.hoverable&&v.bind.popup(),b.onCreate.call(o,F)):0!==O.next(y.popup).length?(v.verbose("Pre-existing popup found"),b.inline=!0,b.popups=O.next(y.popup).data(P.activator,S),v.refresh(),b.hoverable&&v.bind.popup()):b.popup?(e(b.popup).data(P.activator,S),v.verbose("Used popup specified in settings"),v.refresh(),b.hoverable&&v.bind.popup()):v.debug("No content specified skipping display",F)},createID:function(){m=(Math.random().toString(16)+"000000000").substr(2,8),h="."+m,v.verbose("Creating unique id for element",m)},toggle:function(){v.debug("Toggling pop-up"),v.is.hidden()?(v.debug("Popup is hidden, showing pop-up"),v.unbind.close(),v.show()):(v.debug("Popup is visible, hiding pop-up"),v.hide())},show:function(t){if(t=e.isFunction(t)?t:function(){},v.debug("Showing pop-up",b.transition),v.is.hidden()&&(!v.is.active()||!v.is.dropdown())){if(v.exists()||v.create(),b.onShow.call(o,F)===!1)return void v.debug("onShow callback returned false, cancelling popup animation");b.preserve||b.popup||v.refresh(),o&&v.set.position()&&(v.save.conditions(),b.exclusive&&v.hideAll(),v.animate.show(t))}},hide:function(t){if(t=e.isFunction(t)?t:function(){},v.is.visible()||v.is.animating()){if(b.onHide.call(o,F)===!1)return void v.debug("onHide callback returned false, cancelling popup animation");v.remove.visible(),v.unbind.close(),v.restore.conditions(),v.animate.hide(t)}},hideAll:function(){e(y.popup).filter("."+w.visible).each(function(){e(this).data(P.activator).popup("hide")})},hideGracefully:function(t){t&&0===e(t.target).closest(y.popup).length?(v.debug("Click occurred outside popup hiding popup"),v.hide()):v.debug("Click was inside popup, keeping popup open")},exists:function(){return o?b.inline||b.popup?v.has.popup():o.closest(E).length>=1?!0:!1:!1},removePopup:function(){v.debug("Removing popup",o),v.has.popup()&&!b.popup&&(o.remove(),o=n),b.onRemove.call(o,F)},save:{conditions:function(){v.cache={title:S.attr("title")},v.cache.title&&S.removeAttr("title"),v.verbose("Saving original attributes",v.cache.title)}},restore:{conditions:function(){return v.cache&&v.cache.title&&(S.attr("title",v.cache.title),v.verbose("Restoring original attributes",v.cache.title)),!0}},animate:{show:function(t){t=e.isFunction(t)?t:function(){},b.transition&&e.fn.transition!==n&&S.transition("is supported")?(v.set.visible(),o.transition({animation:b.transition+" in",queue:!1,debug:b.debug,verbose:b.verbose,duration:b.duration,onComplete:function(){v.bind.close(),t.call(o,F),b.onVisible.call(o,F)}})):v.error(T.noTransition)},hide:function(t){return t=e.isFunction(t)?t:function(){},v.debug("Hiding pop-up"),b.onShow.call(o,F)===!1?void v.debug("onShow callback returned false, cancelling popup animation"):void(b.transition&&e.fn.transition!==n&&S.transition("is supported")?o.transition({animation:b.transition+" out",queue:!1,duration:b.duration,debug:b.debug,verbose:b.verbose,onComplete:function(){v.reset(),t.call(o,F),b.onHidden.call(o,F)}}):v.error(T.noTransition))}},get:{html:function(){return S.removeData(P.html),S.data(P.html)||b.html},title:function(){return S.removeData(P.title),S.data(P.title)||b.title},content:function(){return S.removeData(P.content),S.data(P.content)||S.attr("title")||b.content},variation:function(){return S.removeData(P.variation),S.data(P.variation)||b.variation},id:function(){return m},startEvent:function(){return"hover"==b.on?l&&b.addTouchEvents?"touchstart mouseenter":"mouseenter":"focus"==b.on?"focus":!1},scrollEvent:function(){return l&&b.addTouchEvents?"touchmove scroll":"scroll"},endEvent:function(){return"hover"==b.on?"mouseleave":"focus"==b.on?"blur":!1},offsetParent:function(t){var o=t!==n?t[0]:S[0],i=o.parentNode,r=e(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=e(i),a="none"===r.css("transform"),s="static"===r.css("position"),p=r.is("html");return r&&r.length>0?r:e()},offstagePosition:function(n){var i={top:e(t).scrollTop(),left:e(t).scrollLeft(),width:e(t).width(),height:e(t).height()},r={top:i.top,bottom:i.top+i.height,left:i.left,right:i.left+i.width},a={width:o.width(),height:o.height(),offset:o.offset()},s={},p=[];return n=n||!1,a.offset&&n&&(v.verbose("Checking if outside viewable area",a.offset),s={top:a.offset.topr.bottom,right:a.offset.left+a.width>r.right,left:a.offset.left0?p.join(" "):!1},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(e){var t=e.split(" "),o=t[0],n=t[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 R||(v.verbose("All available positions available"),R=v.get.positions()),v.debug("Recording last position tried",e),R[e]=!0,"opposite"===b.prefer&&(u=[i[o],n],u=u.join(" "),p=R[u]===!0,v.debug("Trying opposite strategy",u)),"adjacent"===b.prefer&&s&&(u=[o,r[n]],u=u.join(" "),l=R[u]===!0,v.debug("Trying adjacent strategy",u)),(l||p)&&(v.debug("Using backup position",u),u=a[e]),u}},set:{position:function(i,r){if(0===O.length||0===o.length)return void v.error(T.notFound);var s,p,l,u=(e(t).width(),e(t).height(),O.outerWidth()),c=O.outerHeight(),d=o.outerWidth(),f=o.outerHeight(),g=a.outerWidth(),h=a.outerHeight(),m=b.distanceAway,y=O[0],C=b.inline?parseInt(t.getComputedStyle(y).getPropertyValue("margin-top"),10):0,k=b.inline?v.is.rtl()?parseInt(t.getComputedStyle(y).getPropertyValue("margin-right"),10):parseInt(t.getComputedStyle(y).getPropertyValue("margin-left"),10):0,x=b.inline||b.popup?O.position():O.offset();if(i=i||S.data(P.position)||b.position,r=r||S.data(P.offset)||b.offset,0===x.top&&0===x.left)return v.debug("Popup target is hidden, no action taken"),!1;switch(D==b.maxSearchDepth&&b.lastResort&&(v.debug("Using last resort position to display",b.lastResort),i=b.lastResort),b.inline&&(v.debug("Adding targets margin to calculation"),"left center"==i||"right center"==i?(r+=C,m+=-k):"top left"==i||"top center"==i||"top right"==i?(r+=k,m-=C):(r+=k,m+=C)),v.debug("Calculating popup positioning",i),s=i,v.is.rtl()&&(s=s.replace(/left|right/g,function(e){return"left"==e?"right":"left"}),v.debug("RTL: Popup positioning updated",s)),s){case"top left":p={top:"auto",bottom:h-x.top+m,left:x.left+r,right:"auto"};break;case"top center":p={bottom:h-x.top+m,left:x.left+u/2-d/2+r,top:"auto",right:"auto"};break;case"top right":p={bottom:h-x.top+m,right:g-x.left-u-r,top:"auto",left:"auto"};break;case"left center":p={top:x.top+c/2-f/2+r,right:g-x.left+m,left:"auto",bottom:"auto"};break;case"right center":p={top:x.top+c/2-f/2+r,left:x.left+u+m,bottom:"auto",right:"auto"};break;case"bottom left":p={top:x.top+c+m,left:x.left+r,bottom:"auto",right:"auto"};break;case"bottom center":p={top:x.top+c+m,left:x.left+u/2-d/2+r,bottom:"auto",right:"auto"};break;case"bottom right":p={top:x.top+c+m,right:g-x.left-u-r,left:"auto",bottom:"auto"}}if(p===n&&v.error(T.invalidPosition,i),v.debug("Calculated popup positioning values",p),o.css(p).removeClass(w.position).addClass(i).addClass(w.loading),l=v.get.offstagePosition(i)){if(v.debug("Popup cant fit into viewport",i,l),D0}},is:{active:function(){return S.hasClass(w.active)},animating:function(){return o&&o.hasClass(w.animating)},visible:function(){return o&&o.hasClass(w.visible)},dropdown:function(){return S.hasClass(w.dropdown)},hidden:function(){return!v.is.visible()},rtl:function(){return"rtl"==S.css("direction")}},reset:function(){v.remove.visible(),b.preserve?e.fn.transition!==n&&o.transition("remove transition"):v.removePopup()},setting:function(t,o){if(e.isPlainObject(t))e.extend(!0,b,t);else{if(o===n)return b[t];b[t]=o}},internal:function(t,o){if(e.isPlainObject(t))e.extend(!0,v,t);else{if(o===n)return v[t];v[t]=o}},debug:function(){b.debug&&(b.performance?v.performance.log(arguments):(v.debug=Function.prototype.bind.call(console.info,console,b.name+":"),v.debug.apply(console,arguments)))},verbose:function(){b.verbose&&b.debug&&(b.performance?v.performance.log(arguments):(v.verbose=Function.prototype.bind.call(console.info,console,b.name+":"),v.verbose.apply(console,arguments)))},error:function(){v.error=Function.prototype.bind.call(console.error,console,b.name+":"),v.error.apply(console,arguments)},performance:{log:function(e){var t,o,n;b.performance&&(t=(new Date).getTime(),n=u||t,o=t-n,u=t,c.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:F,"Execution Time":o})),clearTimeout(v.performance.timer),v.performance.timer=setTimeout(v.performance.display,500)},display:function(){var t=b.name+":",o=0;u=!1,clearTimeout(v.performance.timer),e.each(c,function(e,t){o+=t["Execution Time"]}),t+=" "+o+"ms",p&&(t+=" '"+p+"'"),(console.group!==n||console.table!==n)&&c.length>0&&(console.groupCollapsed(t),console.table?console.table(c):e.each(c,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),c=[]}},invoke:function(t,o,i){var a,s,p,l=H;return o=o||g,i=F||i,"string"==typeof t&&l!==n&&(t=t.split(/[\. ]/),a=t.length-1,e.each(t,function(o,i){var r=o!=a?i+t[o+1].charAt(0).toUpperCase()+t[o+1].slice(1):t;if(e.isPlainObject(l[r])&&o!=a)l=l[r];else{if(l[r]!==n)return s=l[r],!1;if(!e.isPlainObject(l[i])||o==a)return l[i]!==n?(s=l[i],!1):!1;l=l[i]}})),e.isFunction(s)?p=s.apply(i,o):s!==n&&(p=s),e.isArray(r)?r.push(p):r!==n?r=[r,p]:p!==n&&(r=p),s}},f?(H===n&&v.initialize(),v.invoke(d)):(H!==n&&H.invoke("destroy"),v.initialize())}),r!==n?r:this},e.fn.popup.settings={name:"Popup",debug:!1,verbose:!1,performance:!0,namespace:"popup",onCreate:function(){},onRemove:function(){},onShow:function(){},onVisible:function(){},onHide:function(){},onHidden:function(){},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,offset:0,maxSearchDepth:20,error:{invalidPosition:"The position you specified is not a valid position",cannotPlace:"No visible position could be found for the popup",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(e){var t=/[&<>"'`]/g,o=/[&<>"'`]/,n={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},i=function(e){return n[e]};return o.test(e)?e.replace(t,i):e},popup:function(t){var o="",i=e.fn.popup.settings.templates.escape;return typeof t!==n&&(typeof t.title!==n&&t.title&&(t.title=i(t.title),o+='
'+t.title+"
"),typeof t.content!==n&&t.content&&(t.content=i(t.content),o+='
'+t.content+"
")),o}}},e.extend(e.easing,{easeOutQuad:function(e,t,o,n,i){return-n*(t/=i)*(t-2)+o}})}(jQuery,window,document);