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.1 KiB

  1. !function(a,b,c,d){a.fn.modal=function(e){var f,g=a(this),h=a(c),i=a.isPlainObject(e)?a.extend(!0,{},a.fn.modal.settings,e):a.fn.modal.settings,j=i.selector,k=i.className,l=i.namespace,m=i.error,n="."+l,o="module-"+l,p=g.selector||"",q=(new Date).getTime(),r=[],s=arguments[0],t="string"==typeof s,u=[].slice.call(arguments,1);return g.each(function(){var c,e,v=a(this),w=a(i.context),x=g.not(v),y=v.find(j.closeButton),z=this,A=v.data(o);e={initialize:function(){e.verbose("Attaching events"),y.on("click",e.event.close),e.cache.sizes(),e.verbose("Creating dimmer"),w.dimmer({closable:i.closable,duration:i.duration,onShow:function(){e.add.keyboardShortcuts(),a.proxy(i.onShow,this)()},onHide:function(){v.is(":visible")&&(w.off(".dimmer"),e.hide(),a.proxy(i.onHide,this)()),e.remove.keyboardShortcuts()}}),c=w.children(j.dimmer),v.parent()[0]!==c[0]&&(e.debug("Moving element inside dimmer",w),v=v.detach().appendTo(c)),e.instantiate()},instantiate:function(){e.verbose("Storing instance of modal"),A=e,v.data(o,A)},destroy:function(){e.verbose("Destroying previous modal"),v.off(n)},event:{close:function(){e.verbose("Close button pressed"),w.dimmer("hide")},keyboard:function(a){var b=a.which,c=27;b==c&&(e.debug("Escape key pressed hiding modal"),w.dimmer("hide"),a.preventDefault())},resize:function(){e.cache.sizes(),v.is(":visible")&&(e.set.type(),e.set.position())}},toggle:function(){e.is.active()?e.hide():e.show()},show:function(){e.debug("Showing modal"),e.set.type(),e.set.position(),e.hideAll(),i.transition&&a.fn.transition!==d?v.transition(i.transition+" in",i.duration,e.set.active):v.fadeIn(i.duration,i.easing,e.set.active),e.debug("Triggering dimmer"),w.dimmer("show")},hide:function(){e.debug("Hiding modal"),h.off("keyup."+l),i.transition&&a.fn.transition!==d?v.transition(i.transition+" out",i.duration,e.remove.active):v.fadeOut(i.duration,i.easing,e.remove.active)},hideAll:function(){x.filter(":visible").modal("hide")},add:{keyboardShortcuts:function(){e.verbose("Adding keyboard shortcuts"),h.on("keyup"+n,e.event.keyboard)}},remove:{active:function(){v.removeClass(k.active)},keyboardShortcuts:function(){e.verbose("Removing keyboard shortcuts"),h.off("keyup"+n)}},cache:{sizes:function(){e.cache={height:v.outerHeight()+i.offset,contextHeight:"body"==i.context?a(b).height():w.height()},console.log(v),e.debug("Caching modal and container sizes",e.cache)}},can:{fit:function(){return e.cache.height<e.cache.contextHeight}},is:{active:function(){return v.hasClass(k.active)}},set:{active:function(){v.addClass("active")},type:function(){e.can.fit()?(e.verbose("Modal fits on screen"),v.removeClass(k.scrolling)):(e.verbose("Modal cannot fit on screen setting to scrolling"),v.addClass(k.scrolling))},position:function(){e.verbose("Centering modal on page",e.cache.height/2),e.can.fit()?v.css({marginTop:-(e.cache.height/2)}):v.css({top:w.prop("scrollTop")})}},setting:function(b,c){return c===d?i[b]:(a.isPlainObject(b)?a.extend(!0,i,b):i[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(){i.debug&&(i.performance?e.performance.log(arguments):(e.debug=Function.prototype.bind.call(console.info,console,i.name+":"),e.debug.apply(console,arguments)))},verbose:function(){i.verbose&&i.debug&&(i.performance?e.performance.log(arguments):(e.verbose=Function.prototype.bind.call(console.info,console,i.name+":"),e.verbose.apply(console,arguments)))},error:function(){e.error=Function.prototype.bind.call(console.error,console,i.name+":"),e.error.apply(console,arguments)},performance:{log:function(a){var b,c,d;i.performance&&(b=(new Date).getTime(),d=q||b,c=b-d,q=b,r.push({Element:z,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=i.name+":",c=0;q=!1,clearTimeout(e.performance.timer),a.each(r,function(a,b){c+=b["Execution Time"]}),b+=" "+c+"ms",p&&(b+=" '"+p+"'"),(console.group!==d||console.table!==d)&&r.length>0&&(console.groupCollapsed(b),console.table?c