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
8.3 KiB
1 lines
8.3 KiB
!function(a,b,c,d){a.fn.modal=function(e){var f,g=a(this),h=a(b),i=a(c),j=a("body"),k=(new Date).getTime(),l=[],m=arguments[0],n="string"==typeof m,o=[].slice.call(arguments,1);return g.each(function(){var p,q,r,s,t,u,v=a.isPlainObject(e)?a.extend(!0,{},a.fn.modal.settings,e):a.extend({},a.fn.modal.settings),w=v.selector,x=v.className,y=v.namespace,z=v.error,A="."+y,B="module-"+y,C=g.selector||"",D=a(this),E=a(v.context),F=D.find(w.close),G=this,H=D.data(B);u={initialize:function(){return u.verbose("Initializing dimmer",E),typeof a.fn.dimmer===d?void u.error(z.dimmer):(s=E.dimmer({closable:!1,useCSS:!0,duration:{show:.9*v.duration,hide:1.1*v.duration}}),v.detachable&&s.dimmer("add content",D),t=s.dimmer("get dimmer"),q=D.siblings(w.modal),p=q.add(D),u.verbose("Attaching close events",F),F.on("click"+A,u.event.close),h.on("resize"+A,function(){u.event.debounce(u.refresh,50)}),void u.instantiate())},instantiate:function(){u.verbose("Storing instance of modal"),H=u,D.data(B,H)},destroy:function(){u.verbose("Destroying previous modal"),D.removeData(B).off(A),F.off(A),E.dimmer("destroy")},refresh:function(){u.remove.scrolling(),u.cacheSizes(),u.set.screenHeight(),u.set.type(),u.set.position()},attachEvents:function(b,c){var d=a(b);c=a.isFunction(u[c])?u[c]:u.toggle,d.size()>0?(u.debug("Attaching modal events to element",b,c),d.off(A).on("click"+A,c)):u.error(z.notFound)},event:{close:function(){u.verbose("Closing element pressed"),a(this).is(w.approve)?a.proxy(v.onApprove,G)()!==!1?u.hide():u.verbose("Approve callback returned false cancelling hide"):a(this).is(w.deny)?a.proxy(v.onDeny,G)()!==!1?u.hide():u.verbose("Deny callback returned false cancelling hide"):u.hide()},click:function(b){0===a(b.target).closest(w.modal).size()&&(u.debug("Dimmer clicked, hiding all modals"),v.allowMultiple?u.hide():u.hideAll(),b.stopImmediatePropagation())},debounce:function(a,b){clearTimeout(u.timer),u.timer=setTimeout(a,b)},keyboard:function(a){var b=a.which,c=27;b==c&&(v.closable?(u.debug("Escape key pressed hiding modal"),u.hide()):u.debug("Escape key pressed, but closable is set to false"),a.preventDefault())},resize:function(){s.dimmer("is active")&&u.refresh()}},toggle:function(){u.is.active()?u.hide():u.show()},show:function(b){b=a.isFunction(b)?b:function(){},u.showDimmer(),u.showModal(b)},showModal:function(b){b=a.isFunction(b)?b:function(){},u.is.active()?u.debug("Modal is already visible"):(u.cacheSizes(),u.set.position(),u.set.screenHeight(),u.set.type(),q.filter(":visible").size()>0&&!v.allowMultiple?(u.debug("Other modals visible, queueing show animation"),u.hideOthers(u.showModal)):(v.transition&&a.fn.transition!==d&&D.transition("is supported")?(u.debug("Showing modal with css animations"),D.transition(v.transition+" in",v.duration,function(){u.set.active(),b()})):(u.debug("Showing modal with javascript"),D.fadeIn(v.duration,v.easing,function(){u.set.active(),b()})),a.proxy(v.onShow,G)()))},showDimmer:function(){s.dimmer("is active")?u.debug("Dimmer already visible"):(u.debug("Showing dimmer"),s.dimmer("show"))},hide:function(b){b=a.isFunction(b)?b:function(){},p.filter(":visible").size()<=1&&u.hideDimmer(),u.hideModal(b)},hideDimmer:function(){return u.is.active()?(u.debug("Hiding dimmer"),v.closable&&t.off("click"+A),void s.dimmer("hide",function(){v.transition&&a.fn.transition!==d&&D.transition("is supported")&&(D.transition("reset"),u.remove.screenHeight()),u.remove.active()})):void u.debug("Dimmer is not visible cannot hide")},hideModal:function(b){return b=a.isFunction(b)?b:function(){},u.is.active()?(u.debug("Hiding modal"),u.remove.keyboardShortcuts(),v.transition&&a.fn.transition!==d&&D.transition("is supported")?D.transition(v.transition+" out",v.duration,function(){u.remove.active(),u.restore.focus(),b()}):D.fadeOut(v.duration,v.easing,function(){u.remove.active(),u.restore.focus(),b()}),void a.proxy(v.onHide,G)()):void u.debug("Cannot hide modal it is not active")},hideAll:function(b){b=a.isFunction(b)?b:function(){},p.is(":visible")&&(u.debug("Hiding all visible modals"),u.hideDimmer(),p.filter(":visible").modal("hide modal",b))},hideOthers:function(b){b=a.isFunction(b)?b:function(){},q.is(":visible")&&(u.debug("Hiding other modals"),q.filter(":visible").modal("hide modal",b))},add:{keyboardShortcuts:function(){u.verbose("Adding keyboard shortcuts"),i.on("keyup"+A,u.event.keyboard)}},save:{focus:function(){r=a(c.activeElement).blur()}},restore:{focus:function(){r&&r.size()>0&&r.focus()}},remove:{active:function(){D.removeClass(x.active)},screenHeight:function(){u.cache.height>u.cache.pageHeight&&(u.debug("Removing page height"),j.css("height",""))},keyboardShortcuts:function(){u.verbose("Removing keyboard shortcuts"),i.off("keyup"+A)},scrolling:function(){s.removeClass(x.scrolling),D.removeClass(x.scrolling)}},cacheSizes:function(){u.cache={pageHeight:j.outerHeight(),height:D.outerHeight()+v.offset+parseInt(D.css("marginTop"),10),contextHeight:"body"==v.context?a(b).height():s.height()},u.debug("Caching modal and container sizes",u.cache)},can:{fit:function(){return u.cache.height<u.cache.contextHeight}},is:{active:function(){return D.hasClass(x.active)},modernBrowser:function(){return!(b.ActiveXObject||"ActiveXObject"in b)}},set:{screenHeight:function(){u.cache.height>u.cache.pageHeight&&(u.debug("Modal is taller than page content, resizing page height"),j.css("height",u.cache.height+v.padding))},active:function(){u.add.keyboardShortcuts(),u.save.focus(),D.addClass(x.active),v.closable&&t.off("click"+A).on("click"+A,u.event.click)},scrolling:function(){s.addClass(x.scrolling),D.addClass(x.scrolling)},type:function(){u.can.fit()?(u.verbose("Modal fits on screen"),u.remove.scrolling()):(u.verbose("Modal cannot fit on screen setting to scrolling"),u.set.scrolling())},position:function(){u.verbose("Centering modal on page",u.cache,u.cache.height/2),D.css(u.can.fit()?{top:"",marginTop:-(u.cache.height/2)}:{marginTop:"1em",top:i.scrollTop()})}},setting:function(b,c){if(a.isPlainObject(b))a.extend(!0,v,b);else{if(c===d)return v[b];v[b]=c}},internal:function(b,c){if(a.isPlainObject(b))a.extend(!0,u,b);else{if(c===d)return u[b];u[b]=c}},debug:function(){v.debug&&(v.performance?u.performance.log(arguments):(u.debug=Function.prototype.bind.call(console.info,console,v.name+":"),u.debug.apply(console,arguments)))},verbose:function(){v.verbose&&v.debug&&(v.performance?u.performance.log(arguments):(u.verbose=Function.prototype.bind.call(console.info,console,v.name+":"),u.verbose.apply(console,arguments)))},error:function(){u.error=Function.prototype.bind.call(console.error,console,v.name+":"),u.error.apply(console,arguments)},performance:{log:function(a){var b,c,d;v.performance&&(b=(new Date).getTime(),d=k||b,c=b-d,k=b,l.push({Element:G,Name:a[0],Arguments:[].slice.call(a,1)||"","Execution Time":c})),clearTimeout(u.performance.timer),u.performance.timer=setTimeout(u.performance.display,100)},display:function(){var b=v.name+":",c=0;k=!1,clearTimeout(u.performance.timer),a.each(l,function(a,b){c+=b["Execution Time"]}),b+=" "+c+"ms",C&&(b+=" '"+C+"'"),(console.group!==d||console.table!==d)&&l.length>0&&(console.groupCollapsed(b),console.table?console.table(l):a.each(l,function(a,b){console.log(b.Name+": "+b["Execution Time"]+"ms")}),console.groupEnd()),l=[]}},invoke:function(b,c,e){var g,h,i,j=H;return c=c||o,e=G||e,"string"==typeof b&&j!==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(j[f])&&c!=g)j=j[f];else{if(j[f]!==d)return h=j[f],!1;if(!a.isPlainObject(j[e])||c==g)return j[e]!==d?(h=j[e],!1):!1;j=j[e]}})),a.isFunction(h)?i=h.apply(e,c):h!==d&&(i=h),a.isArray(f)?f.push(i):f!==d?f=[f,i]:i!==d&&(f=i),h}},n?(H===d&&u.initialize(),u.invoke(m)):(H!==d&&u.destroy(),u.initialize())}),f!==d?f:this},a.fn.modal.settings={name:"Modal",namespace:"modal",debug:!0,verbose:!0,performance:!0,allowMultiple:!0,detachable:!0,closable:!0,context:"body",duration:500,easing:"easeOutExpo",offset:0,transition:"scale",padding:30,onShow:function(){},onHide:function(){},onApprove:function(){return!0},onDeny:function(){return!0},selector:{close:".close, .actions .button",approve:".actions .positive, .actions .approve, .actions .ok",deny:".actions .negative, .actions .deny, .actions .cancel",modal:".ui.modal"},error:{dimmer:"UI Dimmer, a required component is not included in this page",method:"The method you called is not defined."},className:{active:"active",scrolling:"scrolling"}}}(jQuery,window,document);
|