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