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
6.0 KiB
1 lines
6.0 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,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=Function.prototype.bind.call(console.info,console,j.name+":"),w.debug.apply(console,arguments)))},verbose:function(){j.verbose&&j.debug&&(j.performance?w.performance.log(arguments):(w.verbose=Function.prototype.bind.call(console.info,console,j.name+":"),w.verbose.apply(console,arguments)))},error:function(){w.error=Function.prototype.bind.call(console.error,console,j.name+":"),w.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:B,Name:a[0],Arguments:[].slice.call(a,1)||"","Execution Time":c})),clearTimeout(w.performance.timer),w.performance.timer=setTimeout(w.performance.display,100)},display:function(){var b=j.name+":",c=0;r=!1,clearTimeout(w.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=B||e,"string"==typeof b&&C!==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(C[e])&&c!=g)C=C[e];else{if(!a.isPlainObject(C[f])||c==g)return C[e]!==d?(h=C[e],!1):C[f]!==d?(h=C[f],!1):(w.error(n.method),!1);C=C[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?(C===d&&w.initialize(),w.invoke(t)):(C!==d&&w.destroy(),w.initialize())}),f!==d?f:this},a.fn.modal.settings={name:"Modal",namespace:"modal",verbose:!0,debug:!0,performance:!0,closable:!0,context:"body",duration:500,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);
|