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 2021 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,s,a=T.isPlainObject(p)?T.extend(!0,{},T.fn.dimmer.settings,p):T.extend({},T.fn.dimmer.settings),n=a.selector,e=a.namespace,t=a.className,d=a.error,r="."+e,m="module-"+e,c=b.selector||"",l="ontouchstart"in F.documentElement?"touchstart":"click",u=T(this),f=this,g=u.data(m);(s={preinitialize:function(){o=s.is.dimmer()?(i=u.parent(),u):(i=u,s.has.dimmer()?a.dimmerName?i.find(n.dimmer).filter("."+a.dimmerName):i.find(n.dimmer):s.create())},initialize:function(){s.debug("Initializing dimmer",a),s.bind.events(),s.set.dimmable(),s.instantiate()},instantiate:function(){s.verbose("Storing instance of module",s),g=s,u.data(m,g)},destroy:function(){s.verbose("Destroying previous module",o),s.unbind.events(),s.remove.variation(),i.off(r)},bind:{events:function(){"hover"==a.on?i.on("mouseenter"+r,s.show).on("mouseleave"+r,s.hide):"click"==a.on&&i.on(l+r,s.toggle),s.is.page()&&(s.debug("Setting as a page dimmer",i),s.set.pageDimmer()),s.is.closable()&&(s.verbose("Adding dimmer close event",o),i.on(l+r,n.dimmer,s.event.click))}},unbind:{events:function(){u.removeData(m),i.off(r)}},event:{click:function(e){s.verbose("Determining if event occurred on dimmer",e),0!==o.find(e.target).length&&!T(e.target).is(n.content)||(s.hide(),e.stopImmediatePropagation())}},addContent:function(e){var i=T(e);s.debug("Add content to dimmer",i),i.parent()[0]!==o[0]&&i.detach().appendTo(o)},create:function(){var e=T(a.template.dimmer(a));return a.dimmerName&&(s.debug("Creating named dimmer",a.dimmerName),e.addClass(a.dimmerName)),e.appendTo(i),e},show:function(e){e=T.isFunction(e)?e:function(){},s.debug("Showing dimmer",o,a),s.set.variation(),s.is.dimmed()&&!s.is.animating()||!s.is.enabled()?s.debug("Dimmer is already shown or disabled"):(s.animate.show(e),a.onShow.call(f),a.onChange.call(f))},hide:function(e){e=T.isFunction(e)?e:function(){},s.is.dimmed()||s.is.animating()?(s.debug("Hiding dimmer",o),s.animate.hide(e),a.onHide.call(f),a.onChange.call(f)):s.debug("Dimmer is not visible")},toggle:function(){s.verbose("Toggling dimmer visibility",o),s.is.dimmed()?s.is.closable()&&s.hide():s.show()},animate:{show:function(e){e=T.isFunction(e)?e:function(){},a.useCSS&&T.fn.transition!==D&&o.transition("is supported")?(a.useFlex?(s.debug("Using flex dimmer"),s.remove.legacy()):(s.debug("Using legacy non-flex dimmer"),s.set.legacy()),"auto"!==a.opacity&&s.set.opacity(),o.transition({displayType:a.useFlex?"flex":"block",animation:(a.transition.showMethod||a.transition)+" in",queue:!1,duration:s.get.duration(),useFailSafe:!0,onStart:function(){s.set.dimmed()},onComplete:function(){s.set.active(),e()}})):(s.verbose("Showing dimmer animation with javascript"),s.set.dimmed(),"auto"==a.opacity&&(a.opacity=.8),o.stop().css({opacity:0,width:"100%",height:"100%"}).fadeTo(s.get.duration(),a.opacity,function(){o.removeAttr("style"),s.set.active(),e()}))},hide:function(e){e=T.isFunction(e)?e:function(){},a.useCSS&&T.fn.transition!==D&&o.transition("is supported")?(s.verbose("Hiding dimmer with css"),o.transition({displayType:a.useFlex?"flex":"block",animation:(a.transition.hideMethod||a.transition)+" out",queue:!1,duration:s.get.duration(),useFailSafe:!0,onComplete:function(){s.remove.dimmed(),s.remove.variation(),s.remove.active(),e()}})):(s.verbose("Hiding dimmer with javascript"),o.stop().fadeOut(s.get.duration(),function(){s.remove.dimmed(),s.remove.active(),o.removeAttr("style"),e()}))}},get:{dimmer:function(){return o},duration:function(){return s.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<u.find(n.dimmer).filter("."+a.dimmerName).length:0<u.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 u.hasClass(t.dimmer)},dimmable:function(){return u.hasClass(t.dimmable)},dimmed:function(){return i.hasClass(t.dimmed)},disabled:function(){return i.hasClass(t.disabled)},enabled:function(){return!s.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+")",s.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(s.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,s,e);else{if(i===D)return s[e];s[e]=i}},debug:function(){!a.silent&&a.debug&&(a.performance?s.performance.log(arguments):(s.debug=Function.prototype.bind.call(console.info,console,a.name+":"),s.debug.apply(console,arguments)))},verbose:function(){!a.silent&&a.verbose&&a.debug&&(a.performance?s.performance.log(arguments):(s.verbose=Function.prototype.bind.call(console.info,console,a.name+":"),s.verbose.apply(console,arguments)))},error:function(){a.silent||(s.error=Function.prototype.bind.call(console.error,console,a.name+":"),s.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:f,"Execution Time":n})),clearTimeout(s.performance.timer),s.performance.timer=setTimeout(s.performance.display,500)},display:function(){var e=a.name+":",n=0;v=!1,clearTimeout(s.performance.timer),T.each(y,function(e,i){n+=i["Execution Time"]}),e+=" "+n+"ms",c&&(e+=" '"+c+"'"),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=g;return e=e||x,i=f||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]:s.error(d.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}}).preinitialize(),w?(g===D&&s.initialize(),s.invoke(C)):(g!==D&&g.invoke("destroy"),s.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); |