11 lines
No EOL
6.8 KiB
JavaScript
11 lines
No EOL
6.8 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(x,w,S){"use strict";w=void 0!==w&&w.Math===Math?w:globalThis,x.fn.nag=function(g){var p,e=x(this),m=e.selector||"",f=Date.now(),h=[],v=g,b="string"==typeof v,y=[].slice.call(arguments,1);return e.each(function(){var t,i=x.isPlainObject(g)?x.extend(!0,{},x.fn.nag.settings,g):x.extend({},x.fn.nag.settings),e=i.selector,c=i.error,o=i.namespace,n="."+o,a=o+"-module",r=x(this),s=i.context?[w,S].indexOf(i.context)<0?x(S).find(i.context):x(i.context):x("body"),l=this,d=r.data(a),u={initialize:function(){u.verbose("Initializing element"),"string"!=typeof i.value&&(i.value=JSON.stringify(i.value)),t=u.get.storage(),r.on("click"+n,e.close,u.dismiss).data(a,u),i.detachable&&r.parent()[0]!==s[0]&&r.detach().prependTo(s),0<i.displayTime&&setTimeout(u.hide,i.displayTime),u.show()},destroy:function(){u.verbose("Destroying instance"),r.removeData(a).off(n)},show:function(){if(u.should.show()&&!r.is(":visible")){if(!1===i.onShow.call(l))return u.debug("onShow callback returned false, cancelling nag animation"),!1;u.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 u.debug("onHide callback returned false, cancelling nag animation"),!1;u.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!==u.hide()&&i.storageMethod&&(u.debug("Dismissing nag",i.storageMethod,i.key,i.value,i.expires),u.storage.set(i.key,i.value)),e.stopImmediatePropagation(),e.preventDefault()},should:{show:function(){return i.persist?(u.debug("Persistent nag is set, can show nag"),!0):u.storage.get(i.key)!=i.value.toString()?(u.debug("Stored value is not set, can show nag",u.storage.get(i.key)),!0):(u.debug("Stored value is set, cannot show nag",u.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();u.error(c.expiresFormat)},storage:function(){return"localstorage"===i.storageMethod&&void 0!==w.localStorage?(u.debug("Using local storage"),w.localStorage):"sessionstorage"===i.storageMethod&&void 0!==w.sessionStorage?(u.debug("Using session storage"),w.sessionStorage):"cookie"in S?(u.debug("Using cookie"),{setItem:function(e,o,n){e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape),o=encodeURIComponent(o).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[B-D])/g,decodeURIComponent);var t,i="";for(t in n)Object.prototype.hasOwnProperty.call(n,t)&&(i+="; "+t,"string"==typeof n[t]&&(i+="="+n[t].split(";")[0]));S.cookie=e+"="+o+i},getItem:function(e){for(var o=S.cookie.split("; "),n=0,t=o.length;n<t;n++){var i=o[n].split("=");if(e===i[0].replace(/(%[\da-f]{2})+/gi,decodeURIComponent))return i[1]||""}},removeItem:function(e,o){t.setItem(e,"",o)}}):void u.error(c.noStorage)},storageOptions:function(){var e={};return i.expires&&(e.expires=u.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(){u.storage.remove(i.key)},storage:{set:function(e,o){var n=u.get.storageOptions();t===w.localStorage&&n.expires&&(u.debug("Storing expiration value in localStorage",e,n.expires),t.setItem(e+i.expirationKey,n.expires)),u.debug("Value stored",e,o);try{t.setItem(e,o,n)}catch(e){u.error(c.setItem,e)}},get:function(e){var o,n=t.getItem(e);return t===w.localStorage&&null!=(o=t.getItem(e+i.expirationKey))&&new Date(o)<new Date&&(u.debug("Value in localStorage has expired. Deleting key",e),u.storage.remove(e),n=null),n="undefined"!==n&&"null"!==n&&null!=n?n:void 0},remove:function(e){var o=u.get.storageOptions();o.expires=u.get.expirationDate(-1),t===w.localStorage&&t.removeItem(e+i.expirationKey),t.removeItem(e,o)}},setting:function(e,o){if(u.debug("Changing setting",e,o),x.isPlainObject(e))x.extend(!0,i,e);else{if(void 0===o)return i[e];x.isPlainObject(i[e])?x.extend(!0,i[e],o):i[e]=o}},internal:function(e,o){if(x.isPlainObject(e))x.extend(!0,u,e);else{if(void 0===o)return u[e];u[e]=o}},debug:function(){!i.silent&&i.debug&&(i.performance?u.performance.log(arguments):(u.debug=Function.prototype.bind.call(console.info,console,i.name+":"),u.debug.apply(console,arguments)))},verbose:function(){!i.silent&&i.verbose&&i.debug&&(i.performance?u.performance.log(arguments):(u.verbose=Function.prototype.bind.call(console.info,console,i.name+":"),u.verbose.apply(console,arguments)))},error:function(){i.silent||(u.error=Function.prototype.bind.call(console.error,console,i.name+":"),u.error.apply(console,arguments))},performance:{log:function(e){var o,n;i.performance&&(n=(o=Date.now())-(f||o),f=o,h.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:l,"Execution Time":n})),clearTimeout(u.performance.timer),u.performance.timer=setTimeout(u.performance.display,500)},display:function(){var e=i.name+":",n=0;f=!1,clearTimeout(u.performance.timer),x.each(h,function(e,o){n+=o["Execution Time"]}),e+=" "+n+"ms",m&&(e+=" '"+m+"'"),0<h.length&&(console.groupCollapsed(e),console.table?console.table(h):x.each(h,function(e,o){console.log(o.Name+": "+o["Execution Time"]+"ms")}),console.groupEnd()),h=[]}},invoke:function(t,e,o){var i,a,n,r,s=d;return e=e||y,o=o||l,"string"==typeof t&&void 0!==s&&(t=t.split(/[ .]/),i=t.length-1,x.each(t,function(e,o){var n=e!==i?o+t[e+1].charAt(0).toUpperCase()+t[e+1].slice(1):t;if(x.isPlainObject(s[n])&&e!==i)s=s[n];else{if(void 0!==s[n])return a=s[n],!1;{if(!x.isPlainObject(s[o])||e===i)return void 0!==s[o]?a=s[o]:u.error(c.method,t),!1;s=s[o]}}})),"function"==typeof(r=a)&&"number"!=typeof r.nodeType?n=a.apply(o,e):void 0!==a&&(n=a),Array.isArray(p)?p.push(n):void 0!==p?p=[p,n]:void 0!==n&&(p=n),a}};b?(void 0===d&&u.initialize(),u.invoke(v)):(void 0!==d&&d.invoke("destroy"),u.initialize())}),void 0!==p?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){return 1-(1-e)*(1-e)}})}(jQuery,window,document); |