You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

0 lines
7.5 KiB

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