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