LocalCDN-Firefox-Chrome-Brave/resources/semantic-ui/2.5.0/components/modal.min.jsm

1 line
12 KiB
JavaScript
Raw Permalink Normal View History

2022-10-07 06:16:13 +02:00
!function(j,q,L,N){"use strict";q=void 0!==q&&q.Math==Math?q:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")(),j.fn.modal=function(w){var C,e=j(this),F=j(q),M=j(L),x=j("body"),H=e.selector||"",A=(new Date).getTime(),O=[],D=w,T="string"==typeof D,z=[].slice.call(arguments,1),E=q.requestAnimationFrame||q.mozRequestAnimationFrame||q.webkitRequestAnimationFrame||q.msRequestAnimationFrame||function(e){setTimeout(e,0)};return e.each(function(){var i,t,e,o,a,n,r,s,c=j.isPlainObject(w)?j.extend(!0,{},j.fn.modal.settings,w):j.extend({},j.fn.modal.settings),l=c.selector,d=c.className,u=c.namespace,m=c.error,f="."+u,g="module-"+u,h=j(this),v=j(c.context),b=h.find(l.close),p=this,y=h.data(g),k=!1,S={initialize:function(){S.verbose("Initializing dimmer",v),S.create.id(),S.create.dimmer(),S.refreshModals(),S.bind.events(),c.observeChanges&&S.observeChanges(),S.instantiate()},instantiate:function(){S.verbose("Storing instance of modal"),y=S,h.data(g,y)},create:{dimmer:function(){var e={debug:c.debug,variation:!c.centered&&"top aligned",dimmerName:"modals"},n=j.extend(!0,e,c.dimmerSettings);j.fn.dimmer!==N?(S.debug("Creating dimmer"),o=v.dimmer(n),c.detachable?(S.verbose("Modal is detachable, moving content into dimmer"),o.dimmer("add content",h)):S.set.undetached(),a=o.dimmer("get dimmer")):S.error(m.dimmer)},id:function(){r=(Math.random().toString(16)+"000000000").substr(2,8),n="."+r,S.verbose("Creating unique id for element",r)}},destroy:function(){s&&s.disconnect(),S.verbose("Destroying previous modal"),h.removeData(g).off(f),F.off(n),a.off(n),b.off(f),v.dimmer("destroy")},observeChanges:function(){"MutationObserver"in q&&((s=new MutationObserver(function(e){S.debug("DOM tree modified, refreshing"),S.refresh()})).observe(p,{childList:!0,subtree:!0}),S.debug("Setting up mutation observer",s))},refresh:function(){S.remove.scrolling(),S.cacheSizes(),S.can.useFlex()||S.set.modalOffset(),S.set.screenHeight(),S.set.type()},refreshModals:function(){t=h.siblings(l.modal),i=t.add(h)},attachEvents:function(e,n){var i=j(e);n=j.isFunction(S[n])?S[n]:S.toggle,0<i.length?(S.debug("Attaching modal events to element",e,n),i.off(f).on("click"+f,n)):S.error(m.notFound,e)},bind:{events:function(){S.verbose("Attaching events"),h.on("click"+f,l.close,S.event.close).on("click"+f,l.approve,S.event.approve).on("click"+f,l.deny,S.event.deny),F.on("resize"+n,S.event.resize)},scrollLock:function(){o.get(0).addEventListener("touchmove",S.event.preventScroll,{passive:!1})}},unbind:{scrollLock:function(){o.get(0).removeEventListener("touchmove",S.event.preventScroll,{passive:!1})}},get:{id:function(){return(Math.random().toString(16)+"000000000").substr(2,8)}},event:{approve:function(){k||!1===c.onApprove.call(p,j(this))?S.verbose("Approve callback returned false cancelling hide"):(k=!0,S.hide(function(){k=!1}))},preventScroll:function(e){e.preventDefault()},deny:function(){k||!1===c.onDeny.call(p,j(this))?S.verbose("Deny callback returned false cancelling hide"):(k=!0,S.hide(function(){k=!1}))},close:function(){S.hide()},click:function(e){var n,i;c.closable?(n=0<j(e.target).closest(l.modal).length,i=j.contains(L.documentElement,e.target),!n&&i&&S.is.active()&&(S.debug("Dimmer clicked, hiding all modals"),S.remove.clickaway(),c.allowMultiple?S.hide():S.hideAll())):S.verbose("Dimmer clicked but closable setting is disabled")},debounce:function(e,n){clearTimeout(S.timer),S.timer=setTimeout(e,n)},keyboard:function(e){27==e.which&&(c.closable?(S.debug("Escape key pressed hiding modal"),S.hide()):S.debug("Escape key pressed, but closable is set to false"),e.preventDefault())},resize:function(){o.dimmer("is active")&&(S.is.animating()||S.is.active())&&E(S.refresh)}},toggle:function(){S.is.active()||S.is.animating()?S.hide():S.show()},show:function(e){e=j.isFunction(e)?e:function(){},S.refreshModals(),S.set.dimmerSettings(),S.set.dimmerStyles(),S.showModal(e)},hide:function(e){e=j.isFunction(e)?e:function(){},S.refreshModals(),S.hideModal(e)},showModal:function(e){e=j.isFunction(e)?e:function(){},S.is.animating()||!S.is.active()?(S.showDimmer(),