wishthis/semantic/dist/components/dimmer.min.js
2023-08-17 11:47:40 +02:00

11 lines
No EOL
8.7 KiB
JavaScript

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