wishthis/node_modules/fomantic-ui/dist/components/modal.min.js

11 lines
23 KiB
JavaScript
Raw Normal View History

2022-01-13 13:00:31 +00:00
/*
* # Fomantic UI - 2.9.3
2022-01-13 13:00:31 +00:00
* https://github.com/fomantic/Fomantic-UI
2023-08-17 09:47:40 +00:00
* https://fomantic-ui.com/
2022-01-13 13:00:31 +00:00
*
2023-08-17 09:47:40 +00:00
* Copyright 2023 Contributors
2022-01-13 13:00:31 +00:00
* Released under the MIT license
2023-08-17 09:47:40 +00:00
* https://opensource.org/licenses/MIT
2022-01-13 13:00:31 +00:00
*
*/
!function(R,U,V){"use strict";function _(e){return"function"==typeof e&&"number"!=typeof e.nodeType}U=void 0!==U&&U.Math===Math?U:globalThis,R.fn.modal=function(N){var I,e=R(this),j=R(U),z=R(V),q=R("body"),B=Date.now(),W=[],P=N,K="string"==typeof P,Q=[].slice.call(arguments,1),X=function(e,t){var i;return 0<=[U,V].indexOf(e)?i=q:0===(i=R(t.document).find(e)).length&&(i=t.frameElement?X(e,t.parent):q),i};return e.each(function(){var i,o,a,e,n,t,s,r,c,l,d,u=R.isPlainObject(N)?R.extend(!0,{},R.fn.modal.settings,N):R.extend({},R.fn.modal.settings),f=u.selector,m=u.className,h=u.namespace,g=u.fields,v=u.error,p="."+h,b="module-"+h,y=R(this),x=X(u.context,U),k=x[0]===q[0],w=y.find(f.closeIcon),C=y.hasClass("modal"),S=this,M=C?y.data(b):void 0,A=!1,D="",T="",H=!1,F=!1,E=!1,O=!1,L={initialize:function(){var a;L.create.id(),C||(L.create.modal(),_(u.onHidden)||(u.onHidden=function(){L.destroy(),y.remove()})),y.addClass(u.class),""!==u.title&&y.find(f.title).html(L.helpers.escape(u.title,u.preserveHTML)).addClass(u.classTitle),""!==u.content&&y.find(f.content).html(L.helpers.escape(u.content,u.preserveHTML)).addClass(u.classContent),L.has.configActions()&&(0===(a=y.find(f.actions).addClass(u.classActions)).length?a=R("<div/>",{class:m.actions+" "+(u.classActions||"")}).appendTo(y):a.empty(),u.actions.forEach(function(e){var t=e[g.icon]?"<i "+(e[g.text]?'aria-hidden="true"':"")+' class="'+L.helpers.deQuote(e[g.icon])+' icon"></i>':"",i=L.helpers.escape(e[g.text]||"",u.preserveHTML),n=L.helpers.deQuote(e[g.class]||""),o=e[g.click]&&_(e[g.click])?e[g.click]:function(){};a.append(R("<button/>",{html:t+i,"aria-label":(e[g.text]||e[g.icon]||"").replace(/<[^>]+(>|$)/g,""),class:m.button+" "+n,on:{click:function(){var e=R(this);e.is(f.approve)||e.is(f.deny)||!1===o.call(S,y)||L.hide()}}}))})),L.cache={},L.verbose("Initializing dimmer",x),L.create.dimmer(),u.allowMultiple&&L.create.innerDimmer(),u.centered||y.addClass("top aligned"),L.refreshModals(),L.bind.events(),L.observeChanges(),L.instantiate(),u.autoShow&&L.show()},instantiate:function(){L.verbose("Storing instance of modal"),M=L,y.data(b,M)},create:{modal:function(){var e;y=R("<div/>",{class:m.modal,role:"dialog","aria-modal":!0}),u.closeIcon&&(w=R("<i/>",{class:m.close,role:"button",tabindex:0,"aria-label":u.text.close}),y.append(w)),""!==u.title&&(e="_"+L.get.id()+"title",y.attr("aria-labelledby",e),R("<div/>",{class:m.title,id:e}).appendTo(y)),""!==u.content&&(e="_"+L.get.id()+"desc",y.attr("aria-describedby",e),R("<div/>",{class:m.content,id:e}).appendTo(y)),L.has.configActions()&&R("<div/>",{class:m.actions}).appendTo(y),x.append(y),S=y[0]},dimmer:function(){var e={debug:u.debug,dimmerName:"modals"},e=R.extend(!0,e,u.dimmerSettings);void 0===R.fn.dimmer?L.error(v.dimmer):(L.debug("Creating dimmer"),n=x.dimmer(e),H=L.is.scrolling(),u.detachable?(L.verbose("Modal is detachable, moving content into dimmer"),n.dimmer("add content",y)):L.set.undetached(),t=n.dimmer("get dimmer"))},id:function(){l=(Math.random().toString(16)+"000000000").slice(2,10),c="."+l,L.verbose("Creating unique id for element",l)},innerDimmer:function(){0===y.find(f.dimmer).length&&R("<div/>",{class:m.innerDimmer}).prependTo(y)}},destroy:function(){d&&d.disconnect(),L.verbose("Destroying previous modal"),y.removeData(b).off(p),j.off(c),x.off(c),t.off(c),w.off(c),i&&i.off(c),x.dimmer("destroy")},observeChanges:function(){"MutationObserver"in U&&((d=new MutationObserver(function(e){function o(e){for(var t=[],i=0,n=e.length;i<n;i++)Array.prototype.push.apply(t,o(e[i].childNodes)),t.push(e[i]);return t}var i=!1,n=!1,a=!0;e.every(function(e){var t;return"attributes"===e.type?O&&("disabled"===e.attributeName||0<R(e.target).find(":input").addBack(":input").filter(":visible").length)&&(n=!0):(i=!0,t=R(o(e.addedNodes)).filter("a[href], [tabindex], :input:enabled").filter(":visible"),e=R(o(e.removedNodes)).filter("a[href], [tabindex], :input"),(0<t.length||0<e.length)&&(n=!0,(0<t.filter(":input").length||0<e.filter(":input").length)&&(a=!1))),!n}),i&&u.observeChanges&&(L.debug("DOM tree modified, refreshing"),L.refresh(