2022-03-15 09:43:53 +00:00
|
|
|
!function(B,R,P,W){"use strict";B.isFunction=B.isFunction||function(e){return"function"==typeof e&&"number"!=typeof e.nodeType},R=void 0!==R&&R.Math==Math?R:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")(),B.fn.modal=function(T){var A,e=B(this),H=B(R),D=B(P),O=B("body"),E=e.selector||"",L=(new Date).getTime(),N=[],z=T,j="string"==typeof z,q=[].slice.call(arguments,1),I=R.requestAnimationFrame||R.mozRequestAnimationFrame||R.webkitRequestAnimationFrame||R.msRequestAnimationFrame||function(e){setTimeout(e,0)};return e.each(function(){var o,s,e,i,t,a,c,n,r,l,d=B.isPlainObject(T)?B.extend(!0,{},B.fn.modal.settings,T):B.extend({},B.fn.modal.settings),u=d.selector,m=d.className,f=d.namespace,h=d.fields,g=d.error,p="."+f,v="module-"+f,b=B(this),y=B(d.context),x=b.find(u.close),k=this,w=b.hasClass("modal")?b.data(v):W,C=!1,S="",F="",M={initialize:function(){var s;b.hasClass("modal")||(M.create.modal(),B.isFunction(d.onHidden)||(d.onHidden=function(){M.destroy(),b.remove()})),b.addClass(d.class),""!==d.title&&b.find(u.title).html(M.helpers.escape(d.title,d.preserveHTML)).addClass(d.classTitle),""!==d.content&&b.find(u.content).html(M.helpers.escape(d.content,d.preserveHTML)).addClass(d.classContent),M.has.configActions()&&(0===(s=b.find(u.actions).addClass(d.classActions)).length?s=B("<div/>",{class:m.actions+" "+(d.classActions||"")}).appendTo(b):s.empty(),d.actions.forEach(function(e){var t=e[h.icon]?'<i class="'+M.helpers.deQuote(e[h.icon])+' icon"></i>':"",n=M.helpers.escape(e[h.text]||"",d.preserveHTML),i=M.helpers.deQuote(e[h.class]||""),o=e[h.click]&&B.isFunction(e[h.click])?e[h.click]:function(){};s.append(B("<button/>",{html:t+n,class:m.button+" "+i,click:function(){!1!==o.call(k,b)&&M.hide()}}))})),M.cache={},M.verbose("Initializing dimmer",y),M.create.id(),M.create.dimmer(),d.allowMultiple&&M.create.innerDimmer(),d.centered||b.addClass("top aligned"),M.refreshModals(),M.bind.events(),d.observeChanges&&M.observeChanges(),M.instantiate(),d.autoShow&&M.show()},instantiate:function(){M.verbose("Storing instance of modal"),w=M,b.data(v,w)},create:{modal:function(){b=B("<div/>",{class:m.modal}),d.closeIcon&&(x=B("<i/>",{class:m.close}),b.append(x)),""!==d.title&&B("<div/>",{class:m.title}).appendTo(b),""!==d.content&&B("<div/>",{class:m.content}).appendTo(b),M.has.configActions()&&B("<div/>",{class:m.actions}).appendTo(b),y.append(b)},dimmer:function(){var e={debug:d.debug,dimmerName:"modals"},e=B.extend(!0,e,d.dimmerSettings);B.fn.dimmer===W?M.error(g.dimmer):(M.debug("Creating dimmer"),i=y.dimmer(e),d.detachable?(M.verbose("Modal is detachable, moving content into dimmer"),i.dimmer("add content",b)):M.set.undetached(),t=i.dimmer("get dimmer"))},id:function(){r=(Math.random().toString(16)+"000000000").substr(2,8),n="."+r,M.verbose("Creating unique id for element",r)},innerDimmer:function(){0==b.find(u.dimmer).length&&b.prepend('<div class="ui inverted dimmer"></div>')}},destroy:function(){l&&l.disconnect(),M.verbose("Destroying previous modal"),b.removeData(v).off(p),H.off(n),t.off(n),x.off(p),y.dimmer("destroy")},observeChanges:function(){"MutationObserver"in R&&((l=new MutationObserver(function(e){M.debug("DOM tree modified, refreshing"),M.refresh()})).observe(k,{childList:!0,subtree:!0}),M.debug("Setting up mutation observer",l))},refresh:function(){M.remove.scrolling(),M.cacheSizes(),M.can.useFlex()||M.set.modalOffset(),M.set.screenHeight(),M.set.type()},refreshModals:function(){s=b.siblings(u.modal),o=s.add(b)},attachEvents:function(e,t){var n=B(e);t=B.isFunction(M[t])?M[t]:M.toggle,0<n.length?(M.debug("Attaching modal events to element",e,t),n.off(p).on("click"+p,t)):M.error(g.notFound,e)},bind:{events:function(){M.verbose("Attaching events"),b.on("click"+p,u.close,M.event.close).on("click"+p,u.approve,M.event.approve).on("click"+p,u.deny,M.event.deny),H.on("resize"+n,M.event.resize)},scrollLock:function(){i.get(0).addEventListener("touchmove",M.event.preventScroll,{passive:!1})}},unbind:{scrollLock:function(){i.get(0).removeEventListener("touchmove",M.event.preventScroll,{passive:!1})}},get:{i
|