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=(new Date).getTime(),k=[],l=arguments[0],m="string"==typeof l,n=[].slice.call(arguments,1);return g.each(function(){var o,p,q,r=a.isPlainObject(e)?a.extend(!0,{},a.fn.modal.settings,e):a.fn.modal.settings,s=r.selector,t=r.className,u=r.namespace,v=r.error,w="."+u,x="module-"+u,y=g.selector||"",z=a(this),A=a(r.context),B=g.not(z),C=z.find(s.close),D=this,E=z.data(x);q={initialize:function(){q.verbose("Initializing dimmer",A),p=A.dimmer("add content",z),q.verbose("Attaching close events",C),C.on("click"+w,q.event.close),h.on("resize",function(){q.event.debounce(q.refresh,50)}),q.instantiate()},instantiate:function(){q.verbose("Storing instance of modal"),E=q,z.data(x,E)},destroy:function(){q.verbose("Destroying previous modal"),z.off(w)},refresh:function(){q.remove.scrolling(),q.cacheSizes(),q.set.type(),q.set.position()},attachEvents:function(b,c){var d=a(b);c=a.isFunction(q[c])?q[c]:q.toggle,d.size()>0?(q.debug("Attaching modal events to element",b,c),d.off(w).on("click"+w,c)):q.error(v.notFound)},event:{close:function(){q.verbose("Close button pressed"),q.hide()},debounce:function(a,b){clearTimeout(q.timer),q.timer=setTimeout(a,b)},keyboard:function(a){var b=a.which,c=27;b==c&&(q.debug("Escape key pressed hiding modal"),q.hide(),a.preventDefault())},resize:function(){p.dimmer("is active")&&q.refresh()}},toggle:function(){q.is.active()?q.hide():q.show()},show:function(){q.showDimmer(),q.cacheSizes(),q.set.position(),q.hideAll(),r.transition&&a.fn.transition!==d?z.transition(r.transition+" in",r.duration,q.set.active):z.fadeIn(r.duration,r.easing,q.set.active),q.debug("Triggering dimmer"),a.proxy(r.onShow,D)()},showDimmer:function(){q.debug("Showing modal"),q.set.dimmerSettings(),p.dimmer("show")},hide:function(){p.dimmer("is active")&&p.dimmer("hide"),q.is.active()?(q.hideModal(),a.proxy(r.onHide,D)()):q.debug("Cannot hide modal, modal is not visible")},hideDimmer:function(){q.debug("Hiding dimmer"),p.dimmer("hide")},hideModal:function(){q.debug("Hiding modal"),q.remove.keyboardShortcuts(),r.transition&&a.fn.transition!==d?z.transition(r.transition+" out",r.duration,function(){q.remove.active(),q.restore.focus()}):z.fadeOut(r.duration,r.easing,function(){q.remove.active(),q.restore.focus()})},hideAll:function(){B.filter(":visible").modal("hide")},add:{keyboardShortcuts:function(){q.verbose("Adding keyboard shortcuts"),i.on("keyup"+w,q.event.keyboard)}},save:{focus:function(){o=a(c.activeElement).blur()}},restore:{focus:function(){o.size()>0&&o.focus()}},remove:{active:function(){z.removeClass(t.active)},keyboardShortcuts:function(){q.verbose("Removing keyboard shortcuts"),i.off("keyup"+w)},scrolling:function(){p.removeClass(t.scrolling),z.removeClass(t.scrolling)}},cacheSizes:function(){q.cache={height:z.outerHeight()+r.offset,contextHeight:"body"==r.context?a(b).height():p.height()},q.debug("Caching modal and container sizes",q.cache)},can:{fit:function(){return q.cache.height<q.cache.contextHeight}},is:{active:function(){return z.hasClass(t.active)}},set:{active:function(){q.save.focus(),q.set.type(),z.addClass(t.active),r.closable&&p.dimmer("get dimmer").on("click",q.hide)},dimmerSettings:function(){q.debug("Setting dimmer settings",p),p.dimmer("setting","closable",!1).dimmer("setting","duration",{show:.95*r.duration,hide:1.05*r.duration}).dimmer("setting","onShow",q.add.keyboardShortcuts).dimmer("destroy").dimmer("initialize")},scrolling:function(){p.addClass(t.scrolling),z.addClass(t.scrolling)},type:function(){q.can.fit()?(q.verbose("Modal fits on screen"),q.remove.scrolling()):(q.verbose("Modal cannot fit on screen setting to scrolling"),q.set.scrolling())},position:function(){q.verbose("Centering modal on page",q.cache,q.cache.height/2),q.can.fit()?z.css({top:"",marginTop:-(q.cache.height/2)}):z.css({marginTop:"1em",top:i.scrollTop()})}},setting:function(b,c){return c===d?r[b]:(a.isPlainObject(b)?a.extend(!0,r,b):r[b]=c,void 0)},internal:function(b,c){return c===d?q[b]:(a.isPlainObject(b)?a.extend(!0,q,b):q[b]=c,void 0)},debug:function(){r.debug&&(r.performance?q.performance.log(arguments):(q.debug=Function.prototype.bind.call(console.info,console,r.name+":"),q.debug.apply(console,arguments)))},verbose:function(){r.verbose&&r.debug&&(r.performance?q.performance.log(arguments):(q.verbose=Function.prototype.bind.call(console.info,console,r.name+":"),q.verbose.apply(console,arguments)))},error:function(){q.error=Function.prototype.bind.call(console.error,console,r.name+":"),q.error.apply(console,arguments)},performance:{log:function(a){var b,c,d;r.performance&&(b=(new Date).getTime(),d=j||b,c=b-d,j=b,k.push({Element:D,Name:a[0],Arguments:[].slice.call(a,1)||"","Execution Time":c})),clearTimeout(q.performance.timer),q.performance.timer=setTimeout(q.performance.display,100)},display:function(){var b=r.name+":",c=0;j=!1,clearTimeout(q.performance.timer),a.each(k,function(a,b){c+=b["Execution Time"]}),b+=" "+c+"ms",y&&(b+=" '"+y+"'"),(console.group!==d||console.table!==d)&&k.length>0&&(console.groupCollapsed(b),console.table?console.table(k):a.each(k,function(a,b){console.log(b.Name+": "+b["Execution Time"]+"ms")}),console.groupEnd()),k=[]}},invoke:function(b,c,e){var g,h,i;return c=c||n,e=D||e,"string"==typeof b&&E!==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(E[e])&&c!=g)E=E[e];else{if(!a.isPlainObject(E[f])||c==g)return E[e]!==d?(h=E[e],!1):E[f]!==d?(h=E[f],!1):(q.error(v.method),!1);E=E[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}},m?(E===d&&q.initialize(),q.invoke(l)):(E!==d&&q.destroy(),q.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);
|