wishthis/node_modules/fomantic-ui/dist/components/nag.min.js

11 lines
6.8 KiB
JavaScript
Raw Normal View History

2022-01-13 13:00:31 +00:00
/*
2023-08-17 09:47:40 +00:00
* # Fomantic UI - 2.9.2
2022-01-13 13:00:31 +00:00
* https://github.com/fomantic/Fomantic-UI
2023-08-17 09:47:40 +00:00
* https://fomantic-ui.com/
2022-01-13 13:00:31 +00:00
*
2023-08-17 09:47:40 +00:00
* Copyright 2023 Contributors
2022-01-13 13:00:31 +00:00
* Released under the MIT license
2023-08-17 09:47:40 +00:00
* https://opensource.org/licenses/MIT
2022-01-13 13:00:31 +00:00
*
*/
2023-08-17 09:47:40 +00:00
!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