wishthis/semantic/dist/components/modal.min.js

11 lines
22 KiB
JavaScript
Raw Normal View History

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