wishthis/node_modules/fomantic-ui/dist/components/dimmer.min.js

11 lines
No EOL
8.6 KiB
JavaScript

/*
* # Fomantic UI - 2.9.3
* https://github.com/fomantic/Fomantic-UI
* https://fomantic-ui.com/
*
* Copyright 2023 Contributors
* Released under the MIT license
* https://opensource.org/licenses/MIT
*
*/
!function(x,e,T){"use strict";function S(e){return"function"==typeof e&&"number"!=typeof e.nodeType}e=void 0!==e&&e.Math===Math?e:globalThis,x.fn.dimmer=function(g){var v,b=x(this),p=Date.now(),h=[],y=g,C="string"==typeof y,w=[].slice.call(arguments,1);return b.each(function(){var o,i,a=x.isPlainObject(g)?x.extend(!0,{},x.fn.dimmer.settings,g):x.extend({},x.fn.dimmer.settings),n=a.selector,e=a.namespace,t=a.className,d=a.error,r="."+e,s="module-"+e,m="ontouchstart"in T.documentElement?"touchstart":"click",l=x(this),c=this,u=l.data(s),f={preinitialize:function(){o=f.is.dimmer()?(i=l.parent(),l):(i=l,f.has.dimmer()?a.dimmerName?i.find(n.dimmer).filter("."+a.dimmerName):i.find(n.dimmer):f.create())},initialize:function(){f.debug("Initializing dimmer",a),f.bind.events(),f.set.dimmable(),f.instantiate()},instantiate:function(){f.verbose("Storing instance of module",f),u=f,l.data(s,u)},destroy:function(){f.verbose("Destroying previous module",o),f.unbind.events(),f.remove.variation(),i.off(r)},bind:{events:function(){"hover"===a.on?i.on("mouseenter"+r,f.show).on("mouseleave"+r,f.hide):"click"===a.on&&i.on(m+r,f.toggle),f.is.page()&&(f.debug("Setting as a page dimmer",i),f.set.pageDimmer()),f.is.closable()&&(f.verbose("Adding dimmer close event",o),i.on(m+r,n.dimmer,f.event.click))}},unbind:{events:function(){l.removeData(s),i.off(r)}},event:{click:function(e){f.verbose("Determining if event occurred on dimmer",e),0!==o.find(e.target).length&&!x(e.target).is(n.content)||(f.hide(),e.stopImmediatePropagation())}},addContent:function(e){e=x(e);f.debug("Add content to dimmer",e),e.parent()[0]!==o[0]&&e.detach().appendTo(o)},create:function(){var e=x(a.template.dimmer(a));return a.dimmerName&&(f.debug("Creating named dimmer",a.dimmerName),e.addClass(a.dimmerName)),e.appendTo(i),e},show:function(e){e=S(e)?e:function(){},f.is.dimmed()&&!f.is.animating()||!f.is.enabled()?f.debug("Dimmer is already shown or disabled"):!1===a.onShow.call(c)?f.verbose("Show callback returned false cancelling dimmer show"):(f.debug("Showing dimmer",o,a),f.set.variation(),f.animate.show(e),a.onChange.call(c))},hide:function(e){e=S(e)?e:function(){},f.is.dimmed()||f.is.animating()?!1===a.onHide.call(c)?f.verbose("Hide callback returned false cancelling dimmer hide"):(f.debug("Hiding dimmer",o),f.animate.hide(e),a.onChange.call(c)):f.debug("Dimmer is not visible")},toggle:function(){f.verbose("Toggling dimmer visibility",o),f.is.dimmed()?f.is.closable()&&f.hide():f.show()},animate:{show:function(e){e=S(e)?e:function(){},a.useCSS&&void 0!==x.fn.transition?(a.useFlex?(f.debug("Using flex dimmer"),f.remove.legacy()):(f.debug("Using legacy non-flex dimmer"),f.set.legacy()),"auto"!==a.opacity&&f.set.opacity(),o.transition({debug:a.debug,verbose:a.verbose,silent:a.silent,displayType:a.useFlex?"flex":"block",animation:(a.transition.showMethod||a.transition)+" in",queue:!1,duration:f.get.duration(),useFailSafe:!0,onStart:function(){f.set.dimmed()},onComplete:function(){f.set.active(),a.onVisible.call(o),e()}})):(f.verbose("Showing dimmer animation with javascript"),f.set.dimmed(),"auto"===a.opacity&&(a.opacity=.8),o.stop().css({opacity:0,width:"100%",height:"100%"}).fadeTo(f.get.duration(),a.opacity,function(){o.removeAttr("style"),f.set.active(),a.onVisible.call(o),e()}))},hide:function(e){e=S(e)?e:function(){},a.useCSS&&void 0!==x.fn.transition?(f.verbose("Hiding dimmer with css"),o.transition({debug:a.debug,verbose:a.verbose,silent:a.silent,displayType:a.useFlex?"flex":"block",animation:(a.transition.hideMethod||a.transition)+" out",queue:!1,duration:f.get.duration(),useFailSafe:!0,onComplete:function(){f.remove.dimmed(),f.remove.variation(),f.remove.active(),a.onHidden.call(o),e()}})):(f.verbose("Hiding dimmer with javascript"),o.stop().fadeOut(f.get.duration(),function(){f.remove.dimmed(),f.remove.active(),o.removeAttr("style"),a.onHidden.call(o),e()}))}},get:{dimmer:function(){return o},duration:function(){return f.is.active()?a.transition.hideDuration||a.duration.hide||a.duration:a.transition.showDuration||a.duration.show||a.duration}},has:{dimmer:function(){return a.dimmerName?0<l.find(n.dimmer).filter("."+a.dimmerName).length:0<l.find(n.dimmer).length}},is:{active:function(){return o.hasClass(t.active)},animating:function(){return o.is(":animated")||o.hasClass(t.animating)},closable:function(){return"auto"===a.closable?"hover"!==a.on:a.closable},dimmer:function(){return l.hasClass(t.dimmer)},dimmable:function(){return l.hasClass(t.dimmable)},dimmed:function(){return i.hasClass(t.dimmed)},disabled:function(){return i.hasClass(t.disabled)},enabled:function(){return!f.is.disabled()},page:function(){return i.is("body")},pageDimmer:function(){return o.hasClass(t.pageDimmer)}},can:{show:function(){return!o.hasClass(t.disabled)}},set:{opacity:function(e){var i=o.css("background-color"),n=i.split(","),t=n&&3<=n.length;e=0===a.opacity?0:a.opacity||e,i=t?(n[2]=n[2].replace(")",""),n[3]=e+")",n.join(",")):"rgba(0, 0, 0, "+e+")",f.debug("Setting opacity to",e),o.css("background-color",i)},legacy:function(){o.addClass(t.legacy)},active:function(){o.addClass(t.active)},dimmable:function(){i.addClass(t.dimmable)},dimmed:function(){i.addClass(t.dimmed)},pageDimmer:function(){o.addClass(t.pageDimmer)},disabled:function(){o.addClass(t.disabled)},variation:function(e){(e=e||a.variation)&&o.addClass(e)}},remove:{active:function(){o.removeClass(t.active)},legacy:function(){o.removeClass(t.legacy)},dimmed:function(){i.removeClass(t.dimmed)},disabled:function(){o.removeClass(t.disabled)},variation:function(e){(e=e||a.variation)&&o.removeClass(e)}},setting:function(e,i){if(f.debug("Changing setting",e,i),x.isPlainObject(e))x.extend(!0,a,e);else{if(void 0===i)return a[e];x.isPlainObject(a[e])?x.extend(!0,a[e],i):a[e]=i}},internal:function(e,i){if(x.isPlainObject(e))x.extend(!0,f,e);else{if(void 0===i)return f[e];f[e]=i}},debug:function(){!a.silent&&a.debug&&(a.performance?f.performance.log(arguments):(f.debug=Function.prototype.bind.call(console.info,console,a.name+":"),f.debug.apply(console,arguments)))},verbose:function(){!a.silent&&a.verbose&&a.debug&&(a.performance?f.performance.log(arguments):(f.verbose=Function.prototype.bind.call(console.info,console,a.name+":"),f.verbose.apply(console,arguments)))},error:function(){a.silent||(f.error=Function.prototype.bind.call(console.error,console,a.name+":"),f.error.apply(console,arguments))},performance:{log:function(e){var i,n;a.performance&&(n=(i=Date.now())-(p||i),p=i,h.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:c,"Execution Time":n})),clearTimeout(f.performance.timer),f.performance.timer=setTimeout(function(){f.performance.display()},500)},display:function(){var e=a.name+":",n=0;p=!1,clearTimeout(f.performance.timer),x.each(h,function(e,i){n+=i["Execution Time"]}),e+=" "+n+"ms",1<b.length&&(e+=" ("+b.length+")"),0<h.length&&(console.groupCollapsed(e),console.table?console.table(h):x.each(h,function(e,i){console.log(i.Name+": "+i["Execution Time"]+"ms")}),console.groupEnd()),h=[]}},invoke:function(t,e,i){var o,a,n,r=u;return e=e||w,i=i||c,"string"==typeof t&&void 0!==r&&(t=t.split(/[ .]/),o=t.length-1,x.each(t,function(e,i){var n=e!==o?i+t[e+1].charAt(0).toUpperCase()+t[e+1].slice(1):t;if(x.isPlainObject(r[n])&&e!==o)r=r[n];else{if(void 0!==r[n])return a=r[n],!1;{if(!x.isPlainObject(r[i])||e===o)return void 0!==r[i]?a=r[i]:f.error(d.method,t),!1;r=r[i]}}})),S(a)?n=a.apply(i,e):void 0!==a&&(n=a),Array.isArray(v)?v.push(n):void 0!==v?v=[v,n]:void 0!==n&&(v=n),a}};f.preinitialize(),C?(void 0===u&&f.initialize(),f.invoke(y)):(void 0!==u&&u.invoke("destroy"),f.initialize())}),void 0!==v?v:this},x.fn.dimmer.settings={name:"Dimmer",namespace:"dimmer",silent:!1,debug:!1,verbose:!1,performance:!0,useFlex:!0,dimmerName:!1,variation:!1,closable:"auto",useCSS:!0,transition:"fade",on:!1,opacity:"auto",duration:{show:500,hide:500},displayLoader:!1,loaderText:!1,loaderVariation:"",onChange:function(){},onShow:function(){},onHide:function(){},onVisible:function(){},onHidden:function(){},error:{method:"The method you called is not defined."},className:{active:"active",animating:"animating",dimmable:"dimmable",dimmed:"dimmed",dimmer:"dimmer",disabled:"disabled",hide:"hide",legacy:"legacy",pageDimmer:"page",show:"show",loader:"ui loader"},selector:{dimmer:"> .ui.dimmer",content:".ui.dimmer > .content, .ui.dimmer > .content > .center"},template:{dimmer:function(e){var i,n=x("<div/>").addClass("ui dimmer");return e.displayLoader&&(i=x("<div/>").addClass(e.className.loader).addClass(e.loaderVariation),e.loaderText&&(i.text(e.loaderText),i.addClass("text")),n.append(i)),n}}}}(jQuery,window,document);