1234567891011 |
- /*
- * # Fomantic UI - 2.8.4
- * https://github.com/fomantic/Fomantic-UI
- * http://fomantic-ui.com/
- *
- * Copyright 2014 Contributors
- * Released under the MIT license
- * http://opensource.org/licenses/MIT
- *
- */
- !function(I,R,N,P){"use strict";I.isFunction=I.isFunction||function(e){return"function"==typeof e&&"number"!=typeof e.nodeType},R=void 0!==R&&R.Math==Math?R:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")(),I.fn.modal=function(M){var H,e=I(this),T=I(R),D=I(N),A=I("body"),E=e.selector||"",O=(new Date).getTime(),L=[],z=M,j="string"==typeof z,q=[].slice.call(arguments,1),B=R.requestAnimationFrame||R.mozRequestAnimationFrame||R.webkitRequestAnimationFrame||R.msRequestAnimationFrame||function(e){setTimeout(e,0)};return e.each(function(){var o,r,e,t,n,a,s,i,c,l,d=I.isPlainObject(M)?I.extend(!0,{},I.fn.modal.settings,M):I.extend({},I.fn.modal.settings),u=d.selector,m=d.className,f=d.namespace,g=d.error,h="."+f,v="module-"+f,b=I(this),p=I(d.context),y=b.find(u.close),w=this,S=b.data(v),C=!1,x="",k="",F={initialize:function(){F.cache={},F.verbose("Initializing dimmer",p),F.create.id(),F.create.dimmer(),d.allowMultiple&&F.create.innerDimmer(),d.centered||b.addClass("top aligned"),F.refreshModals(),F.bind.events(),d.observeChanges&&F.observeChanges(),F.instantiate()},instantiate:function(){F.verbose("Storing instance of modal"),S=F,b.data(v,S)},create:{dimmer:function(){var e={debug:d.debug,dimmerName:"modals"},i=I.extend(!0,e,d.dimmerSettings);I.fn.dimmer!==P?(F.debug("Creating dimmer"),t=p.dimmer(i),d.detachable?(F.verbose("Modal is detachable, moving content into dimmer"),t.dimmer("add content",b)):F.set.undetached(),n=t.dimmer("get dimmer")):F.error(g.dimmer)},id:function(){c=(Math.random().toString(16)+"000000000").substr(2,8),i="."+c,F.verbose("Creating unique id for element",c)},innerDimmer:function(){0==b.find(u.dimmer).length&&b.prepend('<div class="ui inverted dimmer"></div>')}},destroy:function(){l&&l.disconnect(),F.verbose("Destroying previous modal"),b.removeData(v).off(h),T.off(i),n.off(i),y.off(h),p.dimmer("destroy")},observeChanges:function(){"MutationObserver"in R&&((l=new MutationObserver(function(e){F.debug("DOM tree modified, refreshing"),F.refresh()})).observe(w,{childList:!0,subtree:!0}),F.debug("Setting up mutation observer",l))},refresh:function(){F.remove.scrolling(),F.cacheSizes(),F.can.useFlex()||F.set.modalOffset(),F.set.screenHeight(),F.set.type()},refreshModals:function(){r=b.siblings(u.modal),o=r.add(b)},attachEvents:function(e,i){var n=I(e);i=I.isFunction(F[i])?F[i]:F.toggle,0<n.length?(F.debug("Attaching modal events to element",e,i),n.off(h).on("click"+h,i)):F.error(g.notFound,e)},bind:{events:function(){F.verbose("Attaching events"),b.on("click"+h,u.close,F.event.close).on("click"+h,u.approve,F.event.approve).on("click"+h,u.deny,F.event.deny),T.on("resize"+i,F.event.resize)},scrollLock:function(){t.get(0).addEventListener("touchmove",F.event.preventScroll,{passive:!1})}},unbind:{scrollLock:function(){t.get(0).removeEventListener("touchmove",F.event.preventScroll,{passive:!1})}},get:{id:function(){return(Math.random().toString(16)+"000000000").substr(2,8)}},event:{approve:function(){C||!1===d.onApprove.call(w,I(this))?F.verbose("Approve callback returned false cancelling hide"):(C=!0,F.hide(function(){C=!1}))},preventScroll:function(e){-1!==e.target.className.indexOf("dimmer")&&e.preventDefault()},deny:function(){C||!1===d.onDeny.call(w,I(this))?F.verbose("Deny callback returned false cancelling hide"):(C=!0,F.hide(function(){C=!1}))},close:function(){F.hide()},mousedown:function(e){var i=I(e.target),n=F.is.rtl();(a=0<i.closest(u.modal).length)&&F.verbose("Mouse down event registered inside the modal"),(s=F.is.scrolling()&&(!n&&I(R).outerWidth()-d.scrollbarWidth<=e.clientX||n&&d.scrollbarWidth>=e.clientX))&&F.verbose("Mouse down event registered inside the scrollbar")},mouseup:function(e){if(d.closable)if(a)F.debug("Dimmer clicked but mouse down was initially registered inside the modal");else if(s)F.debug("Dimmer clicked but mouse down was initially registered inside the scrollbar");else{var i=0<I(e.target).closest(u.modal).length,n=I.contains(N.documentElement,e.target);if(!i&&n&&F.is.active()&&b.hasClass(m.front)){if(F.debug("Dimmer clicked, hiding all modals"),d.allowMultiple){if(!F.hideAll())return}else if(!F.hide())return;F.remove.clickaway()}}else F.verbose("Dimmer clicked but closable setting is disabled")},debounce:function(e,i){clearTimeout(F.timer),F.timer=setTimeout(e,i)},keyboard:function(e){27==e.which&&(d.closable?(F.debug("Escape key pressed hiding modal"),b.hasClass(m.front)&&F.hide()):F.debug("Escape key pressed, but closable is set to false"),e.preventDefault())},resize:function(){t.dimmer("is active")&&(F.is.animating()||F.is.active())&&B(F.refresh)}},toggle:function(){F.is.active()||F.is.animating()?F.hide():F.show()},show:function(e){e=I.isFunction(e)?e:function(){},F.refreshModals(),F.set.dimmerSettings(),F.set.dimmerStyles(),F.showModal(e)},hide:function(e){return e=I.isFunction(e)?e:function(){},F.refreshModals(),F.hideModal(e)},showModal:function(e){e=I.isFunction(e)?e:function(){},F.is.animating()||!F.is.active()?(F.showDimmer(),F.cacheSizes(),F.set.bodyMargin(),F.can.useFlex()?F.remove.legacy():(F.set.legacy(),F.set.modalOffset(),F.debug("Using non-flex legacy modal positioning.")),F.set.screenHeight(),F.set.type(),F.set.clickaway(),!d.allowMultiple&&F.others.active()?F.hideOthers(F.showModal):(C=!1,d.allowMultiple&&(F.others.active()&&r.filter("."+m.active).find(u.dimmer).addClass("active"),d.detachable&&b.detach().appendTo(n)),d.onShow.call(w),d.transition&&I.fn.transition!==P&&b.transition("is supported")?(F.debug("Showing modal with css animations"),b.transition({debug:d.debug,animation:d.transition+" in",queue:d.queue,duration:d.duration,useFailSafe:!0,onComplete:function(){d.onVisible.apply(w),d.keyboardShortcuts&&F.add.keyboardShortcuts(),F.save.focus(),F.set.active(),d.autofocus&&F.set.autofocus(),e()}})):F.error(g.noTransition))):F.debug("Modal is already visible")},hideModal:function(e,i,n){var t=r.filter("."+m.active).last();if(e=I.isFunction(e)?e:function(){},F.debug("Hiding modal"),!1===d.onHide.call(w,I(this)))return F.verbose("Hide callback returned false cancelling hide"),C=!1;(F.is.animating()||F.is.active())&&(d.transition&&I.fn.transition!==P&&b.transition("is supported")?(F.remove.active(),b.transition({debug:d.debug,animation:d.transition+" out",queue:d.queue,duration:d.duration,useFailSafe:!0,onStart:function(){F.others.active()||F.others.animating()||i||F.hideDimmer(),d.keyboardShortcuts&&!F.others.active()&&F.remove.keyboardShortcuts()},onComplete:function(){F.unbind.scrollLock(),d.allowMultiple&&(t.addClass(m.front),b.removeClass(m.front),n?o.find(u.dimmer).removeClass("active"):t.find(u.dimmer).removeClass("active")),d.onHidden.call(w),F.remove.dimmerStyles(),F.restore.focus(),e()}})):F.error(g.noTransition))},showDimmer:function(){t.dimmer("is animating")||!t.dimmer("is active")?(F.save.bodyMargin(),F.debug("Showing dimmer"),t.dimmer("show")):F.debug("Dimmer already visible")},hideDimmer:function(){t.dimmer("is animating")||t.dimmer("is active")?(F.unbind.scrollLock(),t.dimmer("hide",function(){F.restore.bodyMargin(),F.remove.clickaway(),F.remove.screenHeight()})):F.debug("Dimmer is not visible cannot hide")},hideAll:function(n){var e=o.filter("."+m.active+", ."+m.animating);if(n=I.isFunction(n)?n:function(){},0<e.length){F.debug("Hiding all visible modals");var t=!0;return I(e.get().reverse()).each(function(e,i){t=t&&I(i).modal("hide modal",n,!1,!0)}),t&&F.hideDimmer(),t}},hideOthers:function(e){var i=r.filter("."+m.active+", ."+m.animating);e=I.isFunction(e)?e:function(){},0<i.length&&(F.debug("Hiding other modals",r),i.modal("hide modal",e,!0))},others:{active:function(){return 0<r.filter("."+m.active).length},animating:function(){return 0<r.filter("."+m.animating).length}},add:{keyboardShortcuts:function(){F.verbose("Adding keyboard shortcuts"),D.on("keyup"+h,F.event.keyboard)}},save:{focus:function(){0<I(N.activeElement).closest(b).length||(e=I(N.activeElement).blur())},bodyMargin:function(){x=A.css("margin-"+(F.can.leftBodyScrollbar()?"left":"right"));var e=parseInt(x.replace(/[^\d.]/g,"")),i=R.innerWidth-N.documentElement.clientWidth;k=e+i}},restore:{focus:function(){e&&0<e.length&&d.restoreFocus&&e.focus()},bodyMargin:function(){var e=F.can.leftBodyScrollbar()?"left":"right";A.css("margin-"+e,x),A.find(u.bodyFixed.replace("right",e)).css("padding-"+e,x)}},remove:{active:function(){b.removeClass(m.active)},legacy:function(){b.removeClass(m.legacy)},clickaway:function(){d.detachable||b.off("mousedown"+i),n.off("mousedown"+i),n.off("mouseup"+i)},dimmerStyles:function(){n.removeClass(m.inverted),t.removeClass(m.blurring)},bodyStyle:function(){""===A.attr("style")&&(F.verbose("Removing style attribute"),A.removeAttr("style"))},screenHeight:function(){F.debug("Removing page height"),A.css("height","")},keyboardShortcuts:function(){F.verbose("Removing keyboard shortcuts"),D.off("keyup"+h)},scrolling:function(){t.removeClass(m.scrolling),b.removeClass(m.scrolling)}},cacheSizes:function(){b.addClass(m.loading);var e=b.prop("scrollHeight"),i=b.outerWidth(),n=b.outerHeight();F.cache.pageHeight!==P&&0===n||(I.extend(F.cache,{pageHeight:I(N).outerHeight(),width:i,height:n+d.offset,scrollHeight:e+d.offset,contextHeight:"body"==d.context?I(R).height():t.height()}),F.cache.topOffset=-F.cache.height/2),b.removeClass(m.loading),F.debug("Caching modal and container sizes",F.cache)},can:{leftBodyScrollbar:function(){return F.cache.leftBodyScrollbar===P&&(F.cache.leftBodyScrollbar=F.is.rtl()&&(F.is.iframe&&!F.is.firefox()||F.is.safari()||F.is.edge()||F.is.ie())),F.cache.leftBodyScrollbar},useFlex:function(){return"auto"===d.useFlex?d.detachable&&!F.is.ie():(d.useFlex&&F.is.ie()?F.debug("useFlex true is not supported in IE"):d.useFlex&&!d.detachable&&F.debug("useFlex true in combination with detachable false is not supported"),d.useFlex)},fit:function(){var e=F.cache.contextHeight,i=F.cache.contextHeight/2,n=F.cache.topOffset,t=F.cache.scrollHeight,o=F.cache.height,r=d.padding;return o<t?i+n+t+r<e:o+2*r<e}},is:{active:function(){return b.hasClass(m.active)},ie:function(){var e,i;return F.cache.isIE===P&&(e=!R.ActiveXObject&&"ActiveXObject"in R,i="ActiveXObject"in R,F.cache.isIE=e||i),F.cache.isIE},animating:function(){return b.transition("is supported")?b.transition("is animating"):b.is(":visible")},scrolling:function(){return t.hasClass(m.scrolling)},modernBrowser:function(){return!(R.ActiveXObject||"ActiveXObject"in R)},rtl:function(){return F.cache.isRTL===P&&(F.cache.isRTL="rtl"===A.attr("dir")||"rtl"===A.css("direction")),F.cache.isRTL},safari:function(){return F.cache.isSafari===P&&(F.cache.isSafari=/constructor/i.test(R.HTMLElement)||!!R.ApplePaySession),F.cache.isSafari},edge:function(){return F.cache.isEdge===P&&(F.cache.isEdge=!!R.setImmediate&&!F.is.ie()),F.cache.isEdge},firefox:function(){return F.cache.isFirefox===P&&(F.cache.isFirefox=!!R.InstallTrigger),F.cache.isFirefox},iframe:function(){return!(self===top)}},set:{autofocus:function(){var e=b.find("[tabindex], :input").filter(":visible").filter(function(){return 0===I(this).closest(".disabled").length}),i=e.filter("[autofocus]"),n=0<i.length?i.first():e.first();0<n.length&&n.focus()},bodyMargin:function(){var e=F.can.leftBodyScrollbar()?"left":"right";(d.detachable||F.can.fit())&&A.css("margin-"+e,k+"px"),A.find(u.bodyFixed.replace("right",e)).css("padding-"+e,k+"px")},clickaway:function(){d.detachable||b.on("mousedown"+i,F.event.mousedown),n.on("mousedown"+i,F.event.mousedown),n.on("mouseup"+i,F.event.mouseup)},dimmerSettings:function(){var e,i;I.fn.dimmer!==P?(e={debug:d.debug,dimmerName:"modals",closable:"auto",useFlex:F.can.useFlex(),duration:{show:d.duration,hide:d.duration}},i=I.extend(!0,e,d.dimmerSettings),d.inverted&&(i.variation=i.variation!==P?i.variation+" inverted":"inverted"),p.dimmer("setting",i)):F.error(g.dimmer)},dimmerStyles:function(){d.inverted?n.addClass(m.inverted):n.removeClass(m.inverted),d.blurring?t.addClass(m.blurring):t.removeClass(m.blurring)},modalOffset:function(){var e;d.detachable?b.css({marginTop:!b.hasClass("aligned")&&F.can.fit()?-F.cache.height/2:d.padding/2,marginLeft:-F.cache.width/2}):(e=F.can.fit(),b.css({top:!b.hasClass("aligned")&&e?I(N).scrollTop()+(F.cache.contextHeight-F.cache.height)/2:!e||b.hasClass("top")?I(N).scrollTop()+d.padding:I(N).scrollTop()+(F.cache.contextHeight-F.cache.height-d.padding),marginLeft:-F.cache.width/2})),F.verbose("Setting modal offset for legacy mode")},screenHeight:function(){F.can.fit()?A.css("height",""):b.hasClass("bottom")||(F.debug("Modal is taller than page content, resizing page height"),A.css("height",F.cache.height+2*d.padding))},active:function(){b.addClass(m.active+" "+m.front),r.filter("."+m.active).removeClass(m.front)},scrolling:function(){t.addClass(m.scrolling),b.addClass(m.scrolling),F.unbind.scrollLock()},legacy:function(){b.addClass(m.legacy)},type:function(){F.can.fit()?(F.verbose("Modal fits on screen"),F.others.active()||F.others.animating()||(F.remove.scrolling(),F.bind.scrollLock())):b.hasClass("bottom")?F.verbose("Bottom aligned modal not fitting on screen is unsupported for scrolling"):(F.verbose("Modal cannot fit on screen setting to scrolling"),F.set.scrolling())},undetached:function(){t.addClass(m.undetached)}},setting:function(e,i){if(F.debug("Changing setting",e,i),I.isPlainObject(e))I.extend(!0,d,e);else{if(i===P)return d[e];I.isPlainObject(d[e])?I.extend(!0,d[e],i):d[e]=i}},internal:function(e,i){if(I.isPlainObject(e))I.extend(!0,F,e);else{if(i===P)return F[e];F[e]=i}},debug:function(){!d.silent&&d.debug&&(d.performance?F.performance.log(arguments):(F.debug=Function.prototype.bind.call(console.info,console,d.name+":"),F.debug.apply(console,arguments)))},verbose:function(){!d.silent&&d.verbose&&d.debug&&(d.performance?F.performance.log(arguments):(F.verbose=Function.prototype.bind.call(console.info,console,d.name+":"),F.verbose.apply(console,arguments)))},error:function(){d.silent||(F.error=Function.prototype.bind.call(console.error,console,d.name+":"),F.error.apply(console,arguments))},performance:{log:function(e){var i,n;d.performance&&(n=(i=(new Date).getTime())-(O||i),O=i,L.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:w,"Execution Time":n})),clearTimeout(F.performance.timer),F.performance.timer=setTimeout(F.performance.display,500)},display:function(){var e=d.name+":",n=0;O=!1,clearTimeout(F.performance.timer),I.each(L,function(e,i){n+=i["Execution Time"]}),e+=" "+n+"ms",E&&(e+=" '"+E+"'"),(console.group!==P||console.table!==P)&&0<L.length&&(console.groupCollapsed(e),console.table?console.table(L):I.each(L,function(e,i){console.log(i.Name+": "+i["Execution Time"]+"ms")}),console.groupEnd()),L=[]}},invoke:function(t,e,i){var o,r,n,a=S;return e=e||q,i=w||i,"string"==typeof t&&a!==P&&(t=t.split(/[\. ]/),o=t.length-1,I.each(t,function(e,i){var n=e!=o?i+t[e+1].charAt(0).toUpperCase()+t[e+1].slice(1):t;if(I.isPlainObject(a[n])&&e!=o)a=a[n];else{if(a[n]!==P)return r=a[n],!1;if(!I.isPlainObject(a[i])||e==o)return a[i]!==P&&(r=a[i]),!1;a=a[i]}})),I.isFunction(r)?n=r.apply(i,e):r!==P&&(n=r),Array.isArray(H)?H.push(n):H!==P?H=[H,n]:n!==P&&(H=n),r}};j?(S===P&&F.initialize(),F.invoke(z)):(S!==P&&S.invoke("destroy"),F.initialize())}),H!==P?H:this},I.fn.modal.settings={name:"Modal",namespace:"modal",useFlex:"auto",offset:0,silent:!1,debug:!1,verbose:!1,performance:!0,observeChanges:!1,allowMultiple:!1,detachable:!0,closable:!0,autofocus:!0,restoreFocus:!0,inverted:!1,blurring:!1,centered:!0,dimmerSettings:{closable:!1,useCSS:!0},keyboardShortcuts:!0,context:"body",queue:!1,duration:500,transition:"scale",padding:50,scrollbarWidth:10,onShow:function(){},onVisible:function(){},onHide:function(){return!0},onHidden:function(){},onApprove:function(){return!0},onDeny:function(){return!0},selector:{close:"> .close",approve:".actions .positive, .actions .approve, .actions .ok",deny:".actions .negative, .actions .deny, .actions .cancel",modal:".ui.modal",dimmer:"> .ui.dimmer",bodyFixed:"> .ui.fixed.menu, > .ui.right.toast-container, > .ui.right.sidebar"},error:{dimmer:"UI Dimmer, a required component is not included in this page",method:"The method you called is not defined.",notFound:"The element you specified could not be found"},className:{active:"active",animating:"animating",blurring:"blurring",inverted:"inverted",legacy:"legacy",loading:"loading",scrolling:"scrolling",undetached:"undetached",front:"front"}}}(jQuery,window,document);
|