wishthis/node_modules/fomantic-ui/dist/components/nag.min.js
2022-04-08 12:55:35 +02:00

11 lines
No EOL
6.9 KiB
JavaScript

/*
* # Fomantic UI - 2.9.0-beta.275+3f2aae7
* https://github.com/fomantic/Fomantic-UI
* http://fomantic-ui.com/
*
* Copyright 2022 Contributors
* Released under the MIT license
* http://opensource.org/licenses/MIT
*
*/
!function(x,w,D,I){"use strict";x.isFunction=x.isFunction||function(e){return"function"==typeof e&&"number"!=typeof e.nodeType},w=void 0!==w&&w.Math==Math?w:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")(),x.fn.nag=function(d){var p,e=x(this),m=e.selector||"",f=(new Date).getTime(),h=[],b=d,y="string"==typeof b,v=[].slice.call(arguments,1);return e.each(function(){var o,i=x.isPlainObject(d)?x.extend(!0,{},x.fn.nag.settings,d):x.extend({},x.fn.nag.settings),e=i.selector,s=i.error,n=i.namespace,t="."+n,a=n+"-module",r=x(this),c=i.context?x(i.context):x("body"),l=this,u=r.data(a),g={initialize:function(){g.verbose("Initializing element"),o=g.get.storage(),r.on("click"+t,e.close,g.dismiss).data(a,g),i.detachable&&r.parent()[0]!==c[0]&&r.detach().prependTo(c),0<i.displayTime&&setTimeout(g.hide,i.displayTime),g.show()},destroy:function(){g.verbose("Destroying instance"),r.removeData(a).off(t)},show:function(){if(g.should.show()&&!r.is(":visible")){if(!1===i.onShow.call(l))return g.debug("onShow callback returned false, cancelling nag animation"),!1;g.debug("Showing nag",i.animation.show),"fade"===i.animation.show?r.fadeIn(i.duration,i.easing,i.onVisible):r.slideDown(i.duration,i.easing,i.onVisible)}},hide:function(){if(!1===i.onHide.call(l))return g.debug("onHide callback returned false, cancelling nag animation"),!1;g.debug("Hiding nag",i.animation.hide),"fade"===i.animation.hide?r.fadeOut(i.duration,i.easing,i.onHidden):r.slideUp(i.duration,i.easing,i.onHidden)},dismiss:function(e){!1!==g.hide()&&i.storageMethod&&(g.debug("Dismissing nag",i.storageMethod,i.key,i.value,i.expires),g.storage.set(i.key,i.value)),e.stopImmediatePropagation(),e.preventDefault()},should:{show:function(){return i.persist?(g.debug("Persistent nag is set, can show nag"),!0):g.storage.get(i.key)!=i.value.toString()?(g.debug("Stored value is not set, can show nag",g.storage.get(i.key)),!0):(g.debug("Stored value is set, cannot show nag",g.storage.get(i.key)),!1)}},get:{expirationDate:function(e){if((e="number"==typeof e?new Date(Date.now()+864e5*e):e)instanceof Date&&e.getTime())return e.toUTCString();g.error(s.expiresFormat)},storage:function(){return"localstorage"===i.storageMethod&&w.localStorage!==I?(g.debug("Using local storage"),w.localStorage):"sessionstorage"===i.storageMethod&&w.sessionStorage!==I?(g.debug("Using session storage"),w.sessionStorage):"cookie"in D?(g.debug("Using cookie"),{setItem:function(e,n,t){e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape),n=encodeURIComponent(n).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent);var o,i="";for(o in t)t.hasOwnProperty(o)&&(i+="; "+o,"string"==typeof t[o]&&(i+="="+t[o].split(";")[0]));D.cookie=e+"="+n+i},getItem:function(e){for(var n=D.cookie.split("; "),t=0,o=n.length;t<o;t++){var i=n[t].split("=");if(e===i[0].replace(/(%[\dA-F]{2})+/gi,decodeURIComponent))return i[1]||""}},removeItem:function(e,n){o.setItem(e,"",n)}}):void g.error(s.noStorage)},storageOptions:function(){var e={};return i.expires&&(e.expires=g.get.expirationDate(i.expires)),i.domain&&(e.domain=i.domain),i.path&&(e.path=i.path),i.secure&&(e.secure=i.secure),i.samesite&&(e.samesite=i.samesite),e}},clear:function(){g.storage.remove(i.key)},storage:{set:function(e,n){var t=g.get.storageOptions();o===w.localStorage&&t.expires&&(g.debug("Storing expiration value in localStorage",e,t.expires),o.setItem(e+i.expirationKey,t.expires)),g.debug("Value stored",e,n);try{o.setItem(e,n,t)}catch(e){g.error(s.setItem,e)}},get:function(e){var n,t=o.getItem(e);return o===w.localStorage&&null!==(n=o.getItem(e+i.expirationKey))&&n!==I&&new Date(n)<new Date&&(g.debug("Value in localStorage has expired. Deleting key",e),g.storage.remove(e),t=null),t="undefined"!=t&&"null"!=t&&t!==I&&null!==t?t:I},remove:function(e){var n=g.get.storageOptions();n.expires=g.get.expirationDate(-1),o===w.localStorage&&o.removeItem(e+i.expirationKey),o.removeItem(e,n)}},setting:function(e,n){if(g.debug("Changing setting",e,n),x.isPlainObject(e))x.extend(!0,i,e);else{if(n===I)return i[e];x.isPlainObject(i[e])?x.extend(!0,i[e],n):i[e]=n}},internal:function(e,n){if(x.isPlainObject(e))x.extend(!0,g,e);else{if(n===I)return g[e];g[e]=n}},debug:function(){!i.silent&&i.debug&&(i.performance?g.performance.log(arguments):(g.debug=Function.prototype.bind.call(console.info,console,i.name+":"),g.debug.apply(console,arguments)))},verbose:function(){!i.silent&&i.verbose&&i.debug&&(i.performance?g.performance.log(arguments):(g.verbose=Function.prototype.bind.call(console.info,console,i.name+":"),g.verbose.apply(console,arguments)))},error:function(){i.silent||(g.error=Function.prototype.bind.call(console.error,console,i.name+":"),g.error.apply(console,arguments))},performance:{log:function(e){var n,t;i.performance&&(t=(n=(new Date).getTime())-(f||n),f=n,h.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:l,"Execution Time":t})),clearTimeout(g.performance.timer),g.performance.timer=setTimeout(g.performance.display,500)},display:function(){var e=i.name+":",t=0;f=!1,clearTimeout(g.performance.timer),x.each(h,function(e,n){t+=n["Execution Time"]}),e+=" "+t+"ms",m&&(e+=" '"+m+"'"),(console.group!==I||console.table!==I)&&0<h.length&&(console.groupCollapsed(e),console.table?console.table(h):x.each(h,function(e,n){console.log(n.Name+": "+n["Execution Time"]+"ms")}),console.groupEnd()),h=[]}},invoke:function(o,e,n){var i,a,t,r=u;return e=e||v,n=l||n,"string"==typeof o&&r!==I&&(o=o.split(/[\. ]/),i=o.length-1,x.each(o,function(e,n){var t=e!=i?n+o[e+1].charAt(0).toUpperCase()+o[e+1].slice(1):o;if(x.isPlainObject(r[t])&&e!=i)r=r[t];else{if(r[t]!==I)return a=r[t],!1;{if(!x.isPlainObject(r[n])||e==i)return r[n]!==I?a=r[n]:g.error(s.method,o),!1;r=r[n]}}})),x.isFunction(a)?t=a.apply(n,e):a!==I&&(t=a),Array.isArray(p)?p.push(t):p!==I?p=[p,t]:t!==I&&(p=t),a}};y?(u===I&&g.initialize(),g.invoke(b)):(u!==I&&u.invoke("destroy"),g.initialize())}),p!==I?p:this},x.fn.nag.settings={name:"Nag",silent:!1,debug:!1,verbose:!1,performance:!0,namespace:"Nag",persist:!1,displayTime:0,animation:{show:"slide",hide:"slide"},context:!1,detachable:!1,expires:30,domain:!1,path:"/",secure:!1,samesite:!1,storageMethod:"cookie",key:"nag",value:"dismiss",expirationKey:"ExpirationDate",error:{noStorage:"Unsupported storage method",method:"The method you called is not defined.",setItem:"Unexpected error while setting value",expiresFormat:'"expires" must be a number of days or a Date Object'},className:{bottom:"bottom",fixed:"fixed"},selector:{close:"> .close.icon"},duration:500,easing:"easeOutQuad",onShow:function(){},onVisible:function(){},onHide:function(){},onHidden:function(){}},x.extend(x.easing,{easeOutQuad:function(e,n,t,o,i){return-o*(n/=i)*(n-2)+t}})}(jQuery,window,document);