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