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.6 KiB
1 lines
5.6 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 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,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:A,Name:a[0],Arguments:[].slice.call(a,1)||"","Execution Time":c})),clearTimeout(e.performance.timer),e.performance.timer=setTimeout(e.performance.display,100)},display:function(){var b=j.name+":",c=0;r=!1,clearTimeout(e.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,g){var h,i,j;return c=c||v,g=A||g,"string"==typeof b&&B!==d&&(b=b.split(/[\. ]/),h=b.length-1,a.each(b,function(c,f){var g=c!=h?f+b[c+1].charAt(0).toUpperCase()+b[c+1].slice(1):b;if(a.isPlainObject(B[f])&&c!=h)B=B[f];else{if(!a.isPlainObject(B[g])||c==h)return B[f]!==d?(i=B[f],!1):B[g]!==d?(i=B[g],!1):(e.error(n.method),!1);B=B[g]}})),a.isFunction(i)?j=i.apply(g,c):i!==d&&(j=i),a.isArray(f)?f.push(j):"string"==typeof f?f=[f,j]:j!==d&&(f=j),i}},u?(B===d&&e.initialize(),e.invoke(t)):(B!==d&&e.destroy(),e.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);
|