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.
 
 
 

1 lines
5.9 KiB

!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.call(console.info,console,j.name+":"),x.debug.apply(console,arguments)))},verbose:function(){j.verbose&&j.debug&&(j.performance?x.performance.log(arguments):(x.verbose=Function.prototype.bind.call(console.info,console,j.name+":"),x.verbose.apply(console,arguments)))},error:function(){x.error=Function.prototype.bind.call(console.error,console,j.name+":"),x.error.apply(console,arguments)},performance:{log:function(a){var b,c,d;j.performance&&(b=(new Date).getTime(),d=r||b,c=b-d,r=b,s.push({Element:C,Name:a[0],Arguments:[].slice.call(a,1)||"","Execution Time":c})),clearTimeout(x.performance.timer),x.performance.timer=setTimeout(x.performance.display,100)},display:function(){var b=j.name+":",c=0;r=!1,clearTimeout(x.performance.timer),a.each(s,function(a,b){c+=b["Execution Time"]}),b+=" "+c+"ms",q&&(b+=" '"+q+"'"),(console.group!==d||console.table!==d)&&s.length>0&&(console.groupCollapsed(b),console.table?console.table(s):a.each(s,function(a,b){console.log(b.Name+": "+b["Execution Time"]+"ms")}),console.groupEnd()),s=[]}},invoke:function(b,c,e){var g,h,i;return c=c||v,e=C||e,"string"==typeof b&&D!==d&&(b=b.split(/[\. ]/),g=b.length-1,a.each(b,function(c,e){var f=c!=g?e+b[c+1].charAt(0).toUpperCase()+b[c+1].slice(1):b;if(a.isPlainObject(D[e])&&c!=g)D=D[e];else{if(!a.isPlainObject(D[f])||c==g)return D[e]!==d?(h=D[e],!1):D[f]!==d?(h=D[f],!1):(x.error(n.method),!1);D=D[f]}})),a.isFunction(h)?i=h.apply(e,c):h!==d&&(i=h),a.isArray(f)?f.push(i):"string"==typeof f?f=[f,i]:i!==d&&(f=i),h}},u?(D===d&&x.initialize(),x.invoke(t)):(D!==d&&x.destroy(),x.initialize())}),f!==d?f:this},a.fn.modal.settings={name:"Modal",namespace:"modal",verbose:!0,debug:!0,performance:!0,closable:!0,context:"body",duration:600,easing:"easeOutExpo",offset:0,transition:"scale",onShow:function(){},onHide:function(){},selector:{close:".close, .actions .button"},error:{method:"The method you called is not defined."},className:{active:"active",scrolling:"scrolling"}}}(jQuery,window,document);