11 lines
No EOL
8.5 KiB
JavaScript
11 lines
No EOL
8.5 KiB
JavaScript
/*
|
|
* # Fomantic UI - 2.8.8
|
|
* https://github.com/fomantic/Fomantic-UI
|
|
* http://fomantic-ui.com/
|
|
*
|
|
* Copyright 2022 Contributors
|
|
* Released under the MIT license
|
|
* http://opensource.org/licenses/MIT
|
|
*
|
|
*/
|
|
!function(T,e,F,D){"use strict";T.isFunction=T.isFunction||function(e){return"function"==typeof e&&"number"!=typeof e.nodeType},e=void 0!==e&&e.Math==Math?e:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")(),T.fn.dimmer=function(p){var h,b=T(this),v=(new Date).getTime(),y=[],C=p,w="string"==typeof C,x=[].slice.call(arguments,1);return b.each(function(){var o,i,a=T.isPlainObject(p)?T.extend(!0,{},T.fn.dimmer.settings,p):T.extend({},T.fn.dimmer.settings),n=a.selector,c=a.namespace,e=a.className,l=a.error,t="."+c,u="module-"+c,f=b.selector||"",g="ontouchstart"in F.documentElement?"touchstart":"click",r=T(this),s=this,d=r.data(u),m={preinitialize:function(){o=m.is.dimmer()?(i=r.parent(),r):(i=r,m.has.dimmer()?a.dimmerName?i.find(n.dimmer).filter("."+a.dimmerName):i.find(n.dimmer):m.create())},initialize:function(){m.debug("Initializing dimmer",a),m.bind.events(),m.set.dimmable(),m.instantiate()},instantiate:function(){m.verbose("Storing instance of module",m),d=m,r.data(u,d)},destroy:function(){m.verbose("Destroying previous module",o),m.unbind.events(),m.remove.variation(),i.off(t)},bind:{events:function(){"hover"==a.on?i.on("mouseenter"+t,m.show).on("mouseleave"+t,m.hide):"click"==a.on&&i.on(g+t,m.toggle),m.is.page()&&(m.debug("Setting as a page dimmer",i),m.set.pageDimmer()),m.is.closable()&&(m.verbose("Adding dimmer close event",o),i.on(g+t,n.dimmer,m.event.click))}},unbind:{events:function(){r.removeData(u),i.off(t)}},event:{click:function(e){m.verbose("Determining if event occurred on dimmer",e),0!==o.find(e.target).length&&!T(e.target).is(n.content)||(m.hide(),e.stopImmediatePropagation())}},addContent:function(e){e=T(e);m.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&&(m.debug("Creating named dimmer",a.dimmerName),e.addClass(a.dimmerName)),e.appendTo(i),e},show:function(e){e=T.isFunction(e)?e:function(){},m.debug("Showing dimmer",o,a),m.set.variation(),m.is.dimmed()&&!m.is.animating()||!m.is.enabled()?m.debug("Dimmer is already shown or disabled"):(m.animate.show(e),a.onShow.call(s),a.onChange.call(s))},hide:function(e){e=T.isFunction(e)?e:function(){},m.is.dimmed()||m.is.animating()?(m.debug("Hiding dimmer",o),m.animate.hide(e),a.onHide.call(s),a.onChange.call(s)):m.debug("Dimmer is not visible")},toggle:function(){m.verbose("Toggling dimmer visibility",o),m.is.dimmed()?m.is.closable()&&m.hide():m.show()},animate:{show:function(e){e=T.isFunction(e)?e:function(){},a.useCSS&&T.fn.transition!==D&&o.transition("is supported")?(a.useFlex?(m.debug("Using flex dimmer"),m.remove.legacy()):(m.debug("Using legacy non-flex dimmer"),m.set.legacy()),"auto"!==a.opacity&&m.set.opacity(),o.transition({displayType:a.useFlex?"flex":"block",animation:(a.transition.showMethod||a.transition)+" in",queue:!1,duration:m.get.duration(),useFailSafe:!0,onStart:function(){m.set.dimmed()},onComplete:function(){m.set.active(),e()}})):(m.verbose("Showing dimmer animation with javascript"),m.set.dimmed(),"auto"==a.opacity&&(a.opacity=.8),o.stop().css({opacity:0,width:"100%",height:"100%"}).fadeTo(m.get.duration(),a.opacity,function(){o.removeAttr("style"),m.set.active(),e()}))},hide:function(e){e=T.isFunction(e)?e:function(){},a.useCSS&&T.fn.transition!==D&&o.transition("is supported")?(m.verbose("Hiding dimmer with css"),o.transition({displayType:a.useFlex?"flex":"block",animation:(a.transition.hideMethod||a.transition)+" out",queue:!1,duration:m.get.duration(),useFailSafe:!0,onComplete:function(){m.remove.dimmed(),m.remove.variation(),m.remove.active(),e()}})):(m.verbose("Hiding dimmer with javascript"),o.stop().fadeOut(m.get.duration(),function(){m.remove.dimmed(),m.remove.active(),o.removeAttr("style"),e()}))}},get:{dimmer:function(){return o},duration:function(){return m.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<r.find(n.dimmer).filter("."+a.dimmerName).length:0<r.find(n.dimmer).length}},is:{active:function(){return o.hasClass(e.active)},animating:function(){return o.is(":animated")||o.hasClass(e.animating)},closable:function(){return"auto"==a.closable?"hover"!=a.on:a.closable},dimmer:function(){return r.hasClass(e.dimmer)},dimmable:function(){return r.hasClass(e.dimmable)},dimmed:function(){return i.hasClass(e.dimmed)},disabled:function(){return i.hasClass(e.disabled)},enabled:function(){return!m.is.disabled()},page:function(){return i.is("body")},pageDimmer:function(){return o.hasClass(e.pageDimmer)}},can:{show:function(){return!o.hasClass(e.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+")",m.debug("Setting opacity to",e),o.css("background-color",i)},legacy:function(){o.addClass(e.legacy)},active:function(){o.addClass(e.active)},dimmable:function(){i.addClass(e.dimmable)},dimmed:function(){i.addClass(e.dimmed)},pageDimmer:function(){o.addClass(e.pageDimmer)},disabled:function(){o.addClass(e.disabled)},variation:function(e){(e=e||a.variation)&&o.addClass(e)}},remove:{active:function(){o.removeClass(e.active)},legacy:function(){o.removeClass(e.legacy)},dimmed:function(){i.removeClass(e.dimmed)},disabled:function(){o.removeClass(e.disabled)},variation:function(e){(e=e||a.variation)&&o.removeClass(e)}},setting:function(e,i){if(m.debug("Changing setting",e,i),T.isPlainObject(e))T.extend(!0,a,e);else{if(i===D)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,m,e);else{if(i===D)return m[e];m[e]=i}},debug:function(){!a.silent&&a.debug&&(a.performance?m.performance.log(arguments):(m.debug=Function.prototype.bind.call(console.info,console,a.name+":"),m.debug.apply(console,arguments)))},verbose:function(){!a.silent&&a.verbose&&a.debug&&(a.performance?m.performance.log(arguments):(m.verbose=Function.prototype.bind.call(console.info,console,a.name+":"),m.verbose.apply(console,arguments)))},error:function(){a.silent||(m.error=Function.prototype.bind.call(console.error,console,a.name+":"),m.error.apply(console,arguments))},performance:{log:function(e){var i,n;a.performance&&(n=(i=(new Date).getTime())-(v||i),v=i,y.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:s,"Execution Time":n})),clearTimeout(m.performance.timer),m.performance.timer=setTimeout(m.performance.display,500)},display:function(){var e=a.name+":",n=0;v=!1,clearTimeout(m.performance.timer),T.each(y,function(e,i){n+=i["Execution Time"]}),e+=" "+n+"ms",f&&(e+=" '"+f+"'"),1<b.length&&(e+=" ("+b.length+")"),(console.group!==D||console.table!==D)&&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=d;return e=e||x,i=s||i,"string"==typeof t&&r!==D&&(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(r[n]!==D)return a=r[n],!1;{if(!T.isPlainObject(r[i])||e==o)return r[i]!==D?a=r[i]:m.error(l.method,t),!1;r=r[i]}}})),T.isFunction(a)?n=a.apply(i,e):a!==D&&(n=a),Array.isArray(h)?h.push(n):h!==D?h=[h,n]:n!==D&&(h=n),a}};m.preinitialize(),w?(d===D&&m.initialize(),m.invoke(C)):(d!==D&&d.invoke("destroy"),m.initialize())}),h!==D?h: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(){},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); |