|
|
!function(a,b,c,d){a.fn.modal=function(e){var f,g=a(this),h=a(b),i=a(c),j=a("body"),k=(new Date).getTime(),l=[],m=arguments[0],n="string"==typeof m,o=[].slice.call(arguments,1);return g.each(function(){var p,q,r,s,t,u,v=a.isPlainObject(e)?a.extend(!0,{},a.fn.modal.settings,e):a.extend({},a.fn.modal.settings),w=v.selector,x=v.className,y=v.namespace,z=v.error,A="."+y,B="module-"+y,C=g.selector||"",D=a(this),E=a(v.context),F=D.find(w.close),G=this,H=D.data(B);u={initialize:function(){return u.verbose("Initializing dimmer",E),typeof a.fn.dimmer===d?void u.error(z.dimmer):(s=E.dimmer({closable:!1,useCSS:!0,duration:{show:.9*v.duration,hide:1.1*v.duration}}),v.detachable&&s.dimmer("add content",D),t=s.dimmer("get dimmer"),q=D.siblings(w.modal),p=q.add(D),u.verbose("Attaching close events",F),F.on("click"+A,u.event.close),h.on("resize"+A,function(){u.event.debounce(u.refresh,50)}),void u.instantiate())},instantiate:function(){u.verbose("Storing instance of modal"),H=u,D.data(B,H)},destroy:function(){u.verbose("Destroying previous modal"),D.removeData(B).off(A),F.off(A),E.dimmer("destroy")},refresh:function(){u.remove.scrolling(),u.cacheSizes(),u.set.screenHeight(),u.set.type(),u.set.position()},attachEvents:function(b,c){var d=a(b);c=a.isFunction(u[c])?u[c]:u.toggle,d.size()>0?(u.debug("Attaching modal events to element",b,c),d.off(A).on("click"+A,c)):u.error(z.notFound)},event:{close:function(){u.verbose("Closing element pressed"),a(this).is(w.approve)?a.proxy(v.onApprove,G)()!==!1?u.hide():u.verbose("Approve callback returned false cancelling hide"):a(this).is(w.deny)?a.proxy(v.onDeny,G)()!==!1?u.hide():u.verbose("Deny callback returned false cancelling hide"):u.hide()},click:function(b){0===a(b.target).closest(w.modal).size()&&(u.debug("Dimmer clicked, hiding all modals"),v.allowMultiple?u.hide():u.hideAll(),b.stopImmediatePropagation())},debounce:function(a,b){clearTimeout(u.timer),u.timer=setTimeout(a,b)},keyboard:function(a){var b=a.which,c=27;b==c&&(v.closable?(u.debug("Escape key pressed hiding modal"),u.hide()):u.debug("Escape key pressed, but closable is set to false"),a.preventDefault())},resize:function(){s.dimmer("is active")&&u.refresh()}},toggle:function(){u.is.active()?u.hide():u.show()},show:function(b){b=a.isFunction(b)?b:function(){},u.showDimmer(),u.showModal(b)},showModal:function(b){b=a.isFunction(b)?b:function(){},u.is.active()?u.debug("Modal is already visible"):(u.cacheSizes(),u.set.position(),u.set.screenHeight(),u.set.type(),q.filter(":visible").size()>0&&!v.allowMultiple?(u.debug("Other modals visible, queueing show animation"),u.hideOthers(u.showModal)):(v.transition&&a.fn.transition!==d&&D.transition("is supported")?(u.debug("Showing modal with css animations"),D.transition(v.transition+" in",v.duration,function(){u.set.active(),b()})):(u.debug("Showing modal with javascript"),D.fadeIn(v.duration,v.easing,function(){u.set.active(),b()})),a.proxy(v.onShow,G)()))},showDimmer:function(){s.dimmer("is active")?u.debug("Dimmer already visible"):(u.debug("Showing dimmer"),s.dimmer("show"))},hide:function(b){b=a.isFunction(b)?b:function(){},p.filter(":visible").size()<=1&&u.hideDimmer(),u.hideModal(b)},hideDimmer:function(){return u.is.active()?(u.debug("Hiding dimmer"),v.closable&&t.off("click"+A),void s.dimmer("hide",function(){v.transition&&a.fn.transition!==d&&D.transition("is supported")&&(D.transition("reset"),u.remove.screenHeight()),u.remove.active()})):void u.debug("Dimmer is not visible cannot hide")},hideModal:function(b){return b=a.isFunction(b)?b:function(){},u.is.active()?(u.debug("Hiding modal"),u.remove.keyboardShortcuts(),v.transition&&a.fn.transition!==d&&D.transition("is supported")?D.transition(v.transition+" out",v.duration,function(){u.remove.active(),u.restore.focus(),b()}):D.fadeOut(v.duration,v.easing,function(){u.remove.active(),u.restore.focus(),b()}),void a.proxy(v.onHide,G)()):void u.debug("Cannot hide modal it is not active")},hideAll:function(b){b=a.isFunction(b)?b:function(){},p.is(":visible")&&(u.debug("Hiding all visible modals"),u.hideDimmer(),p.filter(":visible").modal
|