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