You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openpower.foundation/themes/openpowerfoundation/static/lib/semantic-ui/components/modal.min.js

1 line
11 KiB
JavaScript

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