|
|
!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=a.isPlainObject(e)?a.extend(!0,{},a.fn.modal.settings,e):a.fn.modal.settings,s=r.selector,t=r.className,u=r.namespace,v=r.error,w="."+u,x="module-"+u,y=g.selector||"",z=a(this),A=a(r.context),B=g.not(z),C=z.find(s.close),D=this,E=z.data(x);q={initialize:function(){q.verbose("Initializing dimmer",A),p=A.dimmer("add content",z),q.verbose("Attaching close events",C),C.on("click"+w,q.event.close),h.on("resize",function(){q.event.debounce(q.refresh,50)}),q.instantiate()},instantiate:function(){q.verbose("Storing instance of modal"),E=q,z.data(x,E)},destroy:function(){q.verbose("Destroying previous modal"),z.off(w)},refresh:function(){q.remove.scrolling(),q.cacheSizes(),q.set.type(),q.set.position()},attachEvents:function(b,c){var d=a(b);c=a.isFunction(q[c])?q[c]:q.toggle,d.size()>0?(q.debug("Attaching modal events to element",b,c),d.off(w).on("click"+w,c)):q.error(v.notFound)},event:{close:function(){q.verbose("Close button pressed"),q.hide()},debounce:function(a,b){clearTimeout(q.timer),q.timer=setTimeout(a,b)},keyboard:function(a){var b=a.which,c=27;b==c&&(q.debug("Escape key pressed hiding modal"),q.hide(),a.preventDefault())},resize:function(){p.dimmer("is active")&&q.refresh()}},toggle:function(){q.is.active()?q.hide():q.show()},show:function(){q.showDimmer(),q.cacheSizes(),q.set.position(),q.hideAll(),r.transition&&a.fn.transition!==d?z.transition(r.transition+" in",r.duration,q.set.active):z.fadeIn(r.duration,r.easing,q.set.active),q.debug("Triggering dimmer"),a.proxy(r.onShow,D)()},showDimmer:function(){q.debug("Showing modal"),q.set.dimmerSettings(),p.dimmer("show")},hide:function(){p.dimmer("is active")&&p.dimmer("hide"),q.is.active()?(q.hideModal(),a.proxy(r.onHide,D)()):q.debug("Cannot hide modal, modal is not visible")},hideDimmer:function(){q.debug("Hiding dimmer"),p.dimmer("hide")},hideModal:function(){q.debug("Hiding modal"),q.remove.keyboardShortcuts(),r.transition&&a.fn.transition!==d?z.transition(r.transition+" out",r.duration,function(){q.remove.active(),q.restore.focus()}):z.fadeOut(r.duration,r.easing,function(){q.remove.active(),q.restore.focus()})},hideAll:function(){B.filter(":visible").modal("hide")},add:{keyboardShortcuts:function(){q.verbose("Adding keyboard shortcuts"),i.on("keyup"+w,q.event.keyboard)}},save:{focus:function(){o=a(c.activeElement).blur()}},restore:{focus:function(){o.size()>0&&o.focus()}},remove:{active:function(){z.removeClass(t.active)},keyboardShortcuts:function(){q.verbose("Removing keyboard shortcuts"),i.off("keyup"+w)},scrolling:function(){p.removeClass(t.scrolling),z.removeClass(t.scrolling)}},cacheSizes:function(){q.cache={height:z.outerHeight()+r.offset,contextHeight:"body"==r.context?a(b).height():p.height()},q.debug("Caching modal and container sizes",q.cache)},can:{fit:function(){return q.cache.height<q.cache.contextHeight}},is:{active:function(){return z.hasClass(t.active)}},set:{active:function(){q.save.focus(),q.set.type(),z.addClass(t.active),r.closable&&p.dimmer("get dimmer").on("click",q.hide)},dimmerSettings:function(){q.debug("Setting dimmer settings",p),p.dimmer("setting","closable",!1).dimmer("setting","duration",{show:.95*r.duration,hide:1.05*r.duration}).dimmer("setting","onShow",q.add.keyboardShortcuts).dimmer("destroy").dimmer("initialize")},scrolling:function(){p.addClass(t.scrolling),z.addClass(t.scrolling)},type:function(){q.can.fit()?(q.verbose("Modal fits on screen"),q.remove.scrolling()):(q.verbose("Modal cannot fit on screen setting to scrolling"),q.set.scrolling())},position:function(){q.verbose("Centering modal on page",q.cache,q.cache.height/2),q.can.fit()?z.css({top:"",marginTop:-(q.cache.height/2)}):z.css({marginTop:"1em",top:i.scrollTop()})}},setting:function(b,c){return c===d?r[b]:(a.isPlainObject(b)?a.extend(!0,r,b):r[b]=c,void 0)},internal:function(b,c){return c===d?q[b]:(a.isPlainObject(b)?a.extend(!0,q,b):q[b]=c,void 0)},debug:function(){r
|