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