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

11 lines
21 KiB
JavaScript
Raw Normal View History

2022-01-13 13:00:31 +00:00
/*
2022-04-08 10:55:35 +00:00
* # Fomantic UI - 2.9.0-beta.275+3f2aae7
2022-01-13 13:00:31 +00:00
* https://github.com/fomantic/Fomantic-UI
* http://fomantic-ui.com/
*
2022-04-07 07:06:43 +00:00
* Copyright 2022 Contributors
2022-01-13 13:00:31 +00:00
* Released under the MIT license
* http://opensource.org/licenses/MIT
*
*/
2022-04-07 07:06:43 +00:00
!function(R,P,K,W){"use strict";R.isFunction=R.isFunction||function(e){return"function"==typeof e&&"number"!=typeof e.nodeType},P=void 0!==P&&P.Math==Math?P:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")(),R.fn.modal=function(T){var D,e=R(this),H=R(P),O=R(K),E=R("body"),L=e.selector||"",I=(new Date).getTime(),N=[],z=T,j="string"==typeof z,q=[].slice.call(arguments,1),B=P.requestAnimationFrame||P.mozRequestAnimationFrame||P.webkitRequestAnimationFrame||P.msRequestAnimationFrame||function(e){setTimeout(e,0)};return e.each(function(){var t,o,s,e,i,n,a,c,r,l,d,u=R.isPlainObject(T)?R.extend(!0,{},R.fn.modal.settings,T):R.extend({},R.fn.modal.settings),f=u.selector,m=u.className,h=u.namespace,g=u.fields,p=u.error,v="."+h,b="module-"+h,y=R(this),k=R(u.context),x=y.find(f.closeIcon),w=this,C=y.hasClass("modal")?y.data(b):W,S=!1,F="",M="",A={initialize:function(){var s;A.create.id(),y.hasClass("modal")||(A.create.modal(),R.isFunction(u.onHidden)||(u.onHidden=function(){A.destroy(),y.remove()})),y.addClass(u.class),""!==u.title&&y.find(f.title).html(A.helpers.escape(u.title,u.preserveHTML)).addClass(u.classTitle),""!==u.content&&y.find(f.content).html(A.helpers.escape(u.content,u.preserveHTML)).addClass(u.classContent),A.has.configActions()&&(0===(s=y.find(f.actions).addClass(u.classActions)).length?s=R("<div/>",{class:m.actions+" "+(u.classActions||"")}).appendTo(y):s.empty(),u.actions.forEach(function(e){var t=e[g.icon]?"<i "+(e[g.text]?'aria-hidden="true"':"")+' class="'+A.helpers.deQuote(e[g.icon])+' icon"></i>':"",n=A.helpers.escape(e[g.text]||"",u.preserveHTML),i=A.helpers.deQuote(e[g.class]||""),o=e[g.click]&&R.isFunction(e[g.click])?e[g.click]:function(){};s.append(R("<button/>",{html:t+n,"aria-label":R("<div>"+(e[g.text]||e[g.icon]||"")+"</div>").text(),class:m.button+" "+i,click:function(){var e=R(this);e.is(f.approve)||e.is(f.deny)||!1===o.call(w,y)||A.hide()}}))})),A.cache={},A.verbose("Initializing dimmer",k),A.create.dimmer(),u.allowMultiple&&A.create.innerDimmer(),u.centered||y.addClass("top aligned"),A.refreshModals(),A.refreshInputs(),A.bind.events(),A.observeChanges(),A.instantiate(),u.autoShow&&A.show()},instantiate:function(){A.verbose("Storing instance of modal"),C=A,y.data(b,C)},create:{modal:function(){var e;y=R("<div/>",{class:m.modal,role:"dialog","aria-modal":!0}),u.closeIcon&&(x=R("<i/>",{class:m.close,role:"button",tabindex:0,"aria-label":u.text.close}),y.append(x)),""!==u.title&&(e="_"+A.get.id()+"title",y.attr("aria-labelledby",e),R("<div/>",{class:m.title,id:e}).appendTo(y)),""!==u.content&&(e="_"+A.get.id()+"desc",y.attr("aria-describedby",e),R("<div/>",{class:m.content,id:e}).appendTo(y)),A.has.configActions()&&R("<div/>",{class:m.actions}).appendTo(y),k.append(y)},dimmer:function(){var e={debug:u.debug,dimmerName:"modals"},e=R.extend(!0,e,u.dimmerSettings);R.fn.dimmer===W?A.error(p.dimmer):(A.debug("Creating dimmer"),i=k.dimmer(e),u.detachable?(A.verbose("Modal is detachable, moving content into dimmer"),i.dimmer("add content",y)):A.set.undetached(),n=i.dimmer("get dimmer"))},id:function(){l=(Math.random().toString(16)+"000000000").slice(2,10),r="."+l,A.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(),A.verbose("Destroying previous modal"),y.removeData(b).off(v),H.off(r),n.off(r),x.off(r),t&&t.off(r),k.dimmer("destroy")},observeChanges:function(){"MutationObserver"in P&&((d=new MutationObserver(function(e){u.observeChanges&&(A.debug("DOM tree modified, refreshing"),A.refresh()),A.refreshInputs()})).observe(w,{childList:!0,subtree:!0}),A.debug("Setting up mutation observer",d))},refresh:function(){A.remove.scrolling(),A.cacheSizes(),A.can.useFlex()||A.set.modalOffset(),A.set.screenHeight(),A.set.type()},refreshModals:function(){s=y.siblings(f.modal),o=s.add(y)},refreshInputs:function(){t&&t.off("keydown"+r),(t=y.find("[tabindex], :input").filter(":visible").filter(function(){return 0===R(this).closest(".disabled").length})).first().on("keydow