11 lines
No EOL
19 KiB
JavaScript
11 lines
No EOL
19 KiB
JavaScript
/*
|
|
* # Fomantic UI - 2.8.8
|
|
* https://github.com/fomantic/Fomantic-UI
|
|
* http://fomantic-ui.com/
|
|
*
|
|
* Copyright 2021 Contributors
|
|
* Released under the MIT license
|
|
* http://opensource.org/licenses/MIT
|
|
*
|
|
*/
|
|
!function(N,V,W,z){"use strict";N.isFunction=N.isFunction||function(t){return"function"==typeof t&&"number"!=typeof t.nodeType},V=void 0!==V&&V.Math==Math?V:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")(),N.fn.popup=function(x){var E,t=N(this),k=N(W),S=N(V),A=N("body"),F=t.selector||"",D="ontouchstart"in W.documentElement?"touchstart":"click",O=(new Date).getTime(),j=[],R=x,M="string"==typeof R,H=[].slice.call(arguments,1);return t.each(function(){var u,c,t,e,o,d,f=N.isPlainObject(x)?N.extend(!0,{},N.fn.popup.settings,x):N.extend({},N.fn.popup.settings),i=f.selector,h=f.className,g=f.error,m=f.metadata,n=f.namespace,r="."+f.namespace,a="module-"+n,v=N(this),s=N(f.context),p=N(f.scrollContext),b=N(f.boundary),w=f.target?N(f.target):v,y=0,l=!1,P=!1,C=this,T=v.data(a);d={initialize:function(){d.debug("Initializing",v),d.createID(),d.bind.events(),!d.exists()&&f.preserve&&d.create(),f.observeChanges&&d.observeChanges(),d.instantiate()},instantiate:function(){d.verbose("Storing instance",d),T=d,v.data(a,T)},observeChanges:function(){"MutationObserver"in V&&((t=new MutationObserver(d.event.documentChanged)).observe(W,{childList:!0,subtree:!0}),d.debug("Setting up mutation observer",t))},refresh:function(){f.popup?u=N(f.popup).eq(0):f.inline&&(u=w.nextAll(i.popup).eq(0),f.popup=u),f.popup?(u.addClass(h.loading),c=d.get.offsetParent(),u.removeClass(h.loading),f.movePopup&&d.has.popup()&&d.get.offsetParent(u)[0]!==c[0]&&(d.debug("Moving popup to the same offset parent as target"),u.detach().appendTo(c))):c=f.inline?d.get.offsetParent(w):d.has.popup()?d.get.offsetParent(u):A,c.is("html")&&c[0]!==A[0]&&(d.debug("Setting page as offset parent"),c=A),d.get.variation()&&d.set.variation()},reposition:function(){d.refresh(),d.set.position()},destroy:function(){d.debug("Destroying previous module"),t&&t.disconnect(),u&&!f.preserve&&d.removePopup(),clearTimeout(d.hideTimer),clearTimeout(d.showTimer),d.unbind.close(),d.unbind.events(),v.removeData(a)},event:{start:function(t){var e=N.isPlainObject(f.delay)?f.delay.show:f.delay;clearTimeout(d.hideTimer),(!P||P&&f.addTouchEvents)&&(d.showTimer=setTimeout(d.show,e))},end:function(){var t=N.isPlainObject(f.delay)?f.delay.hide:f.delay;clearTimeout(d.showTimer),d.hideTimer=setTimeout(d.hide,t)},touchstart:function(t){P=!0,f.addTouchEvents&&d.show()},resize:function(){d.is.visible()&&d.set.position()},documentChanged:function(t){[].forEach.call(t,function(t){t.removedNodes&&[].forEach.call(t.removedNodes,function(t){(t==C||0<N(t).find(C).length)&&(d.debug("Element removed from DOM, tearing down events"),d.destroy())})})},hideGracefully:function(t){var e=N(t.target),o=N.contains(W.documentElement,t.target),n=0<e.closest(i.popup).length;t&&!n&&o?(d.debug("Click occurred outside popup hiding popup"),d.hide()):d.debug("Click was inside popup, keeping popup open")}},create:function(){var t=d.get.html(),e=d.get.title(),o=d.get.content();t||o||e?(d.debug("Creating pop-up html"),t=t||f.templates.popup({title:e,content:o}),u=N("<div/>").addClass(h.popup).data(m.activator,v).html(t),f.inline?(d.verbose("Inserting popup element inline",u),u.insertAfter(v)):(d.verbose("Appending popup element to body",u),u.appendTo(s)),d.refresh(),d.set.variation(),f.hoverable&&d.bind.popup(),f.onCreate.call(u,C)):f.popup?(N(f.popup).data(m.activator,v),d.verbose("Used popup specified in settings"),d.refresh(),f.hoverable&&d.bind.popup()):0!==w.next(i.popup).length?(d.verbose("Pre-existing popup found"),f.inline=!0,f.popup=w.next(i.popup).data(m.activator,v),d.refresh(),f.hoverable&&d.bind.popup()):d.debug("No content specified skipping display",C)},createID:function(){o=(Math.random().toString(16)+"000000000").substr(2,8),e="."+o,d.verbose("Creating unique id for element",o)},toggle:function(){d.debug("Toggling pop-up"),d.is.hidden()?(d.debug("Popup is hidden, showing pop-up"),d.unbind.close(),d.show()):(d.debug("Popup is visible, hiding pop-up"),d.hide())},show:function(t){if(t=t||function(){},d.debug("Showing pop-up",f.transition),d.is.hidden()&&(!d.is.active()||!d.is.dropdown())){if(d.exists()||d.create(),!1===f.onShow.call(u,C))return void d.debug("onShow callback returned false, cancelling popup animation");f.preserve||f.popup||d.refresh(),u&&d.set.position()&&(d.save.conditions(),f.exclusive&&d.hideAll(),d.animate.show(t))}},hide:function(t){if(t=t||function(){},d.is.visible()||d.is.animating()){if(!1===f.onHide.call(u,C))return void d.debug("onHide callback returned false, cancelling popup animation");d.remove.visible(),d.unbind.close(),d.restore.conditions(),d.animate.hide(t)}},hideAll:function(){N(i.popup).filter("."+h.popupVisible).each(function(){N(this).data(m.activator).popup("hide")})},exists:function(){return!!u&&(f.inline||f.popup?d.has.popup():1<=u.closest(s).length)},removePopup:function(){d.has.popup()&&!f.popup&&(d.debug("Removing popup",u),u.remove(),u=z,f.onRemove.call(u,C))},save:{conditions:function(){d.cache={title:v.attr("title")},d.cache.title&&v.removeAttr("title"),d.verbose("Saving original attributes",d.cache.title)}},restore:{conditions:function(){return d.cache&&d.cache.title&&(v.attr("title",d.cache.title),d.verbose("Restoring original attributes",d.cache.title)),!0}},supports:{svg:function(){return"undefined"!=typeof SVGGraphicsElement}},animate:{show:function(t){t=N.isFunction(t)?t:function(){},f.transition&&N.fn.transition!==z&&v.transition("is supported")?(d.set.visible(),u.transition({animation:(f.transition.showMethod||f.transition)+" in",queue:!1,debug:f.debug,verbose:f.verbose,duration:f.transition.showDuration||f.duration,onComplete:function(){d.bind.close(),t.call(u,C),f.onVisible.call(u,C)}})):d.error(g.noTransition)},hide:function(t){t=N.isFunction(t)?t:function(){},d.debug("Hiding pop-up"),f.transition&&N.fn.transition!==z&&v.transition("is supported")?u.transition({animation:(f.transition.hideMethod||f.transition)+" out",queue:!1,duration:f.transition.hideDuration||f.duration,debug:f.debug,verbose:f.verbose,onComplete:function(){d.reset(),t.call(u,C),f.onHidden.call(u,C)}}):d.error(g.noTransition)}},change:{content:function(t){u.html(t)}},get:{html:function(){return v.removeData(m.html),v.data(m.html)||f.html},title:function(){return v.removeData(m.title),v.data(m.title)||f.title},content:function(){return v.removeData(m.content),v.data(m.content)||f.content||v.attr("title")},variation:function(){return v.removeData(m.variation),v.data(m.variation)||f.variation},popup:function(){return u},popupOffset:function(){return u.offset()},calculations:function(){var t,e=d.get.offsetParent(u),o=w[0],n=b[0]==V,i=w.offset(),r=f.inline||f.popup&&f.movePopup?w.offsetParent().offset():{top:0,left:0},a=n?{top:0,left:0}:b.offset(),s={},p=n?{top:S.scrollTop(),left:S.scrollLeft()}:{top:0,left:0};if(s={target:{element:w[0],width:w.outerWidth(),height:w.outerHeight(),top:i.top-r.top,left:i.left-r.left,margin:{}},popup:{width:u.outerWidth(),height:u.outerHeight()},parent:{width:c.outerWidth(),height:c.outerHeight()},screen:{top:a.top,left:a.left,scroll:{top:p.top,left:p.left},width:b.width(),height:b.height()}},e.get(0)!==c.get(0)){var l=e.offset();s.target.top-=l.top,s.target.left-=l.left,s.parent.width=e.outerWidth(),s.parent.height=e.outerHeight()}return f.setFluidWidth&&d.is.fluid()&&(s.container={width:u.parent().outerWidth()},s.popup.width=s.container.width),s.target.margin.top=f.inline?parseInt(V.getComputedStyle(o).getPropertyValue("margin-top"),10):0,s.target.margin.left=f.inline?d.is.rtl()?parseInt(V.getComputedStyle(o).getPropertyValue("margin-right"),10):parseInt(V.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 o},startEvent:function(){return"hover"==f.on?"mouseenter":"focus"==f.on&&"focus"},scrollEvent:function(){return"scroll"},endEvent:function(){return"hover"==f.on?"mouseleave":"focus"==f.on&&"blur"},distanceFromBoundary:function(t,e){var o,n,i={};return o=(e=e||d.get.calculations()).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)},d.verbose("Distance from boundaries determined",t,i)),i},offsetParent:function(t){var e=(t!==z?t[0]:w[0]).parentNode,o=N(e);if(e)for(var n="none"===o.css("transform"),i="static"===o.css("position"),r=o.is("body");e&&!r&&i&&n;)e=e.parentNode,n="none"===(o=N(e)).css("transform"),i="static"===o.css("position"),r=o.is("body");return o&&0<o.length?o:N()},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"==o||"bottom"==o,r=!1,a=!1,s=!1;return l||(d.verbose("All available positions available"),l=d.get.positions()),d.debug("Recording last position tried",t),l[t]=!0,"opposite"===f.prefer&&(s=(s=[{top:"bottom",bottom:"top",left:"right",right:"left"}[o],n]).join(" "),r=!0===l[s],d.debug("Trying opposite strategy",s)),"adjacent"===f.prefer&&i&&(s=(s=[o,{left:"center",center:"right",right:"left"}[n]]).join(" "),a=!0===l[s],d.debug("Trying adjacent strategy",s)),(a||r)&&(d.debug("Using backup position",s),s={"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"}[t]),s}},set:{position:function(t,e){if(0!==w.length&&0!==u.length){var o,n,i,r,a,s,p,l;if(e=e||d.get.calculations(),t=t||v.data(m.position)||f.position,o=v.data(m.offset)||f.offset,n=f.distanceAway,i=e.target,r=e.popup,a=e.parent,d.should.centerArrow(e)&&(d.verbose("Adjusting offset to center arrow on small target element"),"top left"!=t&&"bottom left"!=t||(o+=i.width/2,o-=f.arrowPixelsFromEdge),"top right"!=t&&"bottom right"!=t||(o-=i.width/2,o+=f.arrowPixelsFromEdge)),0===i.width&&0===i.height&&!d.is.svg(i.element))return d.debug("Popup target is hidden, no action taken"),!1;switch(f.inline&&(d.debug("Adding margin to calculation",i.margin),"left center"==t||"right center"==t?(o+=i.margin.top,n+=-i.margin.left):"top left"==t||"top center"==t||"top right"==t?(o+=i.margin.left,n-=i.margin.top):(o+=i.margin.left,n+=i.margin.top)),d.debug("Determining popup position from calculations",t,e),d.is.rtl()&&(t=t.replace(/left|right/g,function(t){return"left"==t?"right":"left"}),d.debug("RTL: Popup position updated",t)),y==f.maxSearchDepth&&"string"==typeof f.lastResort&&(t=f.lastResort),t){case"top left":s={top:"auto",bottom:a.height-i.top+n,left:i.left+o,right:"auto"};break;case"top center":s={bottom:a.height-i.top+n,left:i.left+i.width/2-r.width/2+o,top:"auto",right:"auto"};break;case"top right":s={bottom:a.height-i.top+n,right:a.width-i.left-i.width-o,top:"auto",left:"auto"};break;case"left center":s={top:i.top+i.height/2-r.height/2+o,right:a.width-i.left+n,left:"auto",bottom:"auto"};break;case"right center":s={top:i.top+i.height/2-r.height/2+o,left:i.left+i.width+n,bottom:"auto",right:"auto"};break;case"bottom left":s={top:i.top+i.height+n,left:i.left+o,bottom:"auto",right:"auto"};break;case"bottom center":s={top:i.top+i.height+n,left:i.left+i.width/2-r.width/2+o,bottom:"auto",right:"auto"};break;case"bottom right":s={top:i.top+i.height+n,right:a.width-i.left-i.width-o,left:"auto",bottom:"auto"}}if(s===z&&d.error(g.invalidPosition,t),d.debug("Calculated popup positioning values",s),u.css(s).removeClass(h.position).addClass(t).addClass(h.loading),p=d.get.popupOffset(),l=d.get.distanceFromBoundary(p,e),!f.forcePosition&&d.is.offstage(l,t)){if(d.debug("Position is outside viewport",t),y<f.maxSearchDepth)return y++,t=d.get.nextPosition(t),d.debug("Trying new position",t),!!u&&d.set.position(t,e);if(!f.lastResort)return d.debug("Popup could not find a position to display",u),d.error(g.cannotPlace,C),d.remove.attempts(),d.remove.loading(),d.reset(),f.onUnplaceable.call(u,C),!1;d.debug("No position found, showing with last position")}return d.debug("Position is on stage",t),d.remove.attempts(),d.remove.loading(),f.setFluidWidth&&d.is.fluid()&&d.set.fluidWidth(e),!0}d.error(g.notFound)},fluidWidth:function(t){t=t||d.get.calculations(),d.debug("Automatically setting element width to parent width",t.parent.width),u.css("width",t.container.width)},variation:function(t){(t=t||d.get.variation())&&d.has.popup()&&(d.verbose("Adding variation to popup",t),u.addClass(t))},visible:function(){v.addClass(h.visible)}},remove:{loading:function(){u.removeClass(h.loading)},variation:function(t){(t=t||d.get.variation())&&(d.verbose("Removing variation",t),u.removeClass(t))},visible:function(){v.removeClass(h.visible)},attempts:function(){d.verbose("Resetting all searched positions"),y=0,l=!1}},bind:{events:function(){d.debug("Binding popup events to module"),"click"==f.on&&v.on(D+r,d.toggle),"hover"==f.on&&v.on("touchstart"+r,d.event.touchstart),d.get.startEvent()&&v.on(d.get.startEvent()+r,d.event.start).on(d.get.endEvent()+r,d.event.end),f.target&&d.debug("Target set to element",w),S.on("resize"+e,d.event.resize)},popup:function(){d.verbose("Allowing hover events on popup to prevent closing"),u&&d.has.popup()&&u.on("mouseenter"+r,d.event.start).on("mouseleave"+r,d.event.end)},close:function(){(!0===f.hideOnScroll||"auto"==f.hideOnScroll&&"click"!=f.on)&&d.bind.closeOnScroll(),d.is.closable()?d.bind.clickaway():"hover"==f.on&&P&&d.bind.touchClose()},closeOnScroll:function(){d.verbose("Binding scroll close event to document"),p.one(d.get.scrollEvent()+e,d.event.hideGracefully)},touchClose:function(){d.verbose("Binding popup touchclose event to document"),k.on("touchstart"+e,function(t){d.verbose("Touched away from popup"),d.event.hideGracefully.call(C,t)})},clickaway:function(){d.verbose("Binding popup close event to document"),k.on(D+e,function(t){d.verbose("Clicked away from popup"),d.event.hideGracefully.call(C,t)})}},unbind:{events:function(){S.off(e),v.off(r)},close:function(){k.off(e),p.off(e)}},has:{popup:function(){return u&&0<u.length}},should:{centerArrow:function(t){return!d.is.basic()&&t.target.width<=2*f.arrowPixelsFromEdge}},is:{closable:function(){return"auto"==f.closable?"hover"!=f.on:f.closable},offstage:function(t,o){var n=[];return N.each(t,function(t,e){e<-f.jitter&&(d.debug("Position exceeds allowable distance from edge",t,e,o),n.push(t))}),0<n.length},svg:function(t){return d.supports.svg()&&t instanceof SVGGraphicsElement},basic:function(){return v.hasClass(h.basic)},active:function(){return v.hasClass(h.active)},animating:function(){return u!==z&&u.hasClass(h.animating)},fluid:function(){return u!==z&&u.hasClass(h.fluid)},visible:function(){return u!==z&&u.hasClass(h.popupVisible)},dropdown:function(){return v.hasClass(h.dropdown)},hidden:function(){return!d.is.visible()},rtl:function(){return"rtl"===v.attr("dir")||"rtl"===v.css("direction")}},reset:function(){d.remove.visible(),f.preserve?N.fn.transition!==z&&u.transition("remove transition"):d.removePopup()},setting:function(t,e){if(N.isPlainObject(t))N.extend(!0,f,t);else{if(e===z)return f[t];f[t]=e}},internal:function(t,e){if(N.isPlainObject(t))N.extend(!0,d,t);else{if(e===z)return d[t];d[t]=e}},debug:function(){!f.silent&&f.debug&&(f.performance?d.performance.log(arguments):(d.debug=Function.prototype.bind.call(console.info,console,f.name+":"),d.debug.apply(console,arguments)))},verbose:function(){!f.silent&&f.verbose&&f.debug&&(f.performance?d.performance.log(arguments):(d.verbose=Function.prototype.bind.call(console.info,console,f.name+":"),d.verbose.apply(console,arguments)))},error:function(){f.silent||(d.error=Function.prototype.bind.call(console.error,console,f.name+":"),d.error.apply(console,arguments))},performance:{log:function(t){var e,o;f.performance&&(o=(e=(new Date).getTime())-(O||e),O=e,j.push({Name:t[0],Arguments:[].slice.call(t,1)||"",Element:C,"Execution Time":o})),clearTimeout(d.performance.timer),d.performance.timer=setTimeout(d.performance.display,500)},display:function(){var t=f.name+":",o=0;O=!1,clearTimeout(d.performance.timer),N.each(j,function(t,e){o+=e["Execution Time"]}),t+=" "+o+"ms",F&&(t+=" '"+F+"'"),(console.group!==z||console.table!==z)&&0<j.length&&(console.groupCollapsed(t),console.table?console.table(j):N.each(j,function(t,e){console.log(e.Name+": "+e["Execution Time"]+"ms")}),console.groupEnd()),j=[]}},invoke:function(n,t,e){var i,r,o,a=T;return t=t||H,e=C||e,"string"==typeof n&&a!==z&&(n=n.split(/[\. ]/),i=n.length-1,N.each(n,function(t,e){var o=t!=i?e+n[t+1].charAt(0).toUpperCase()+n[t+1].slice(1):n;if(N.isPlainObject(a[o])&&t!=i)a=a[o];else{if(a[o]!==z)return r=a[o],!1;if(!N.isPlainObject(a[e])||t==i)return a[e]!==z&&(r=a[e]),!1;a=a[e]}})),N.isFunction(r)?o=r.apply(e,t):r!==z&&(o=r),Array.isArray(E)?E.push(o):E!==z?E=[E,o]:o!==z&&(E=o),r}},M?(T===z&&d.initialize(),d.invoke(R)):(T!==z&&T.invoke("destroy"),d.initialize())}),E!==z?E:this},N.fn.popup.settings={name:"Popup",silent:!1,debug:!1,verbose:!1,performance:!0,namespace:"popup",observeChanges:!0,onCreate:function(){},onRemove:function(){},onShow:function(){},onVisible:function(){},onHide:function(){},onUnplaceable:function(){},onHidden:function(){},on:"hover",boundary:V,addTouchEvents:!0,position:"top left",forcePosition:!1,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",scrollContext:V,prefer:"opposite",lastResort:!1,arrowPixelsFromEdge:20,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 <https://github.com/Semantic-Org/UI-Transition>",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",basic:"basic",animating:"animating",dropdown:"dropdown",fluid:"fluid",loading:"loading",popup:"ui popup",position:"top left center bottom right",visible:"visible",popupVisible:"visible"},selector:{popup:".ui.popup"},templates:{escape:function(t){var e={"<":"<",">":">",'"':""","'":"'","`":"`"};return/[&<>"'`]/.test(t)?(t=t.replace(/&(?![a-z0-9#]{1,6};)/,"&")).replace(/[<>"'`]/g,function(t){return e[t]}):t},popup:function(t){var e="",o=N.fn.popup.settings.templates.escape;return typeof t!==z&&(typeof t.title!==z&&t.title&&(t.title=o(t.title),e+='<div class="header">'+t.title+"</div>"),typeof t.content!==z&&t.content&&(t.content=o(t.content),e+='<div class="content">'+t.content+"</div>")),e}}}}(jQuery,window,document); |