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
5.6 KiB

  1. !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 c,e,w=a(this),x=a(j.context),y=g.not(w),z=w.find(k.close),A=this,B=w.data(p);e={initialize:function(){e.verbose("Initializing dimmer",x),c=x.dimmer("add content",w).dimmer("get dimmer"),e.verbose("Attaching close events",z),z.on("click"+o,e.event.close),h.on("resize",function(){e.event.debounce(e.refresh,50)}),e.instantiate()},instantiate:function(){e.verbose("Storing instance of modal"),B=e,w.data(p,B)},destroy:function(){e.verbose("Destroying previous modal"),w.off(o)},refresh:function(){e.remove.scrolling(),e.cacheSizes(),e.set.type(),e.set.position()},event:{close:function(){e.verbose("Close button pressed"),x.dimmer("hide")},debounce:function(a,b){clearTimeout(e.timer),e.timer=setTimeout(a,b)},keyboard:function(a){var b=a.which,c=27;b==c&&(e.debug("Escape key pressed hiding modal"),x.dimmer("hide"),a.preventDefault())},resize:function(){x.dimmer("is active")&&e.refresh()}},toggle:function(){e.is.active()?e.hide():e.show()},show:function(){e.showDimmer(),e.cacheSizes(),e.set.position(),e.hideAll(),j.transition&&a.fn.transition!==d?w.transition(j.transition+" in",j.duration,function(){e.set.active(),e.set.type()}):w.fadeIn(j.duration,j.easing,e.set.active),e.debug("Triggering dimmer"),a.proxy(j.onShow,A)()},showDimmer:function(){e.debug("Showing modal"),e.set.dimmerSettings(),x.dimmer("show")},hideDimmer:function(){x.dimmer("hide")},hide:function(){e.debug("Hiding modal"),i.off("keyup."+m),j.transition&&a.fn.transition!==d?w.transition(j.transition+" out",j.duration,function(){e.remove.active()}):w.fadeOut(j.duration,j.easing,e.remove.active),a.proxy(j.onHide,A)()},hideAll:function(){y.filter(":visible").modal("hide")},add:{keyboardShortcuts:function(){e.verbose("Adding keyboard shortcuts"),i.on("keyup"+o,e.event.keyboard)}},remove:{active:function(){w.removeClass(l.active)},keyboardShortcuts:function(){e.verbose("Removing keyboard shortcuts"),i.off("keyup"+o)},scrolling:function(){c.removeClass(l.scrolling),w.removeClass(l.scrolling)}},cacheSizes:function(){e.cache={height:w.outerHeight()+j.offset,contextHeight:"body"==j.context?a(b).height():x.height()},e.debug("Caching modal and container sizes",e.cache)},can:{fit:function(){return e.cache.height<e.cache.contextHeight}},is:{active:function(){return w.hasClass(l.active)}},set:{active:function(){w.addClass(l.active)},dimmerSettings:function(){e.debug("Setting dimmer settings",j.closable),x.dimmer("setting","closable",j.closable).dimmer("setting","duration",j.duration).dimmer("setting","onShow",e.add.keyboardShortcuts).dimmer("setting","onHide",function(){e.hide(),e.remove.keyboardShortcuts()}).dimmer("destroy").dimmer("initialize")},scrolling:function(){c.addClass(l.scrolling),w.addClass(l.scrolling)},type:function(){e.can.fit()?(e.verbose("Modal fits on screen"),e.remove.scrolling()):(e.verbose("Modal cannot fit on screen setting to scrolling"),e.set.scrolling())},position:function(){e.verbose("Centering modal on page",e.cache,e.cache.height/2),e.can.fit()?w.css({top:"",marginTop:-(e.cache.height/2)}):w.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?e[b]:(a.isPlainObject(b)?a.extend(!0,e,b):e[b]=c,void 0)},debug:function(){j.debug&&(j.performance?e.performance.log(arguments):(e.debug=Function.prototype.bind.call(console.info,console,j.name+":"),e.debug.apply(console,arguments)))},verbose:function(){j.verbose&&j.debug&&(j.performance?e.performance.log(arguments):(e.verbose=Function.prototype.bind.call(console.info,console,j.name+":"),e.verbose.apply(console,arguments)))},error:function(){e.error=Function.prototype.bind.call(console.error,console,j.name+":"),e.error.apply(console,argument