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

11 lines
6.9 KiB
JavaScript
Raw Normal View History

2022-01-13 13:00:31 +00:00
/*
* # Fomantic UI - 2.9.3
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
*
*/
!function(w,S,D){"use strict";S=void 0!==S&&S.Math===Math?S:globalThis,w.fn.nag=function(g){var p,e=w(this),m=w("body"),f=Date.now(),h=[],v=g,b="string"==typeof v,y=[].slice.call(arguments,1),x=function(e,n){var o;return 0<=[S,D].indexOf(e)?o=w(e):0===(o=w(n.document).find(e)).length&&(o=n.frameElement?x(e,n.parent):m),o};return e.each(function(){var t,i=w.isPlainObject(g)?w.extend(!0,{},w.fn.nag.settings,g):w.extend({},w.fn.nag.settings),e=i.selector,c=i.error,n=i.namespace,o="."+n,a=n+"-module",r=w(this),s=i.context?x(i.context,S):m,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"+o,e.close,u.dismiss).data(a,u),i.detachable&&r.parent()[0]!==s[0]&&r.detach().prependTo(s),0<i.displayTime&&setTimeout(function(){u.hide()},i.displayTime),u.show()},destroy:function(){u.verbose("Destroying instance"),r.removeData(a).off(o)},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!==S.localStorage?(u.debug("Using local storage"),S.localStorage):"sessionstorage"===i.storageMethod&&void 0!==S.sessionStorage?(u.debug("Using session storage"),S.sessionStorage):"cookie"in D?(u.debug("Using cookie"),{setItem:function(e,n,o){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[B-D])/g,decodeURIComponent);var t,i="";for(t in o)Object.prototype.hasOwnProperty.call(o,t)&&(i+="; "+t,"string"==typeof o[t]&&(i+="="+o[t].split(";")[0]));D.cookie=e+"="+n+i},getItem:function(e){for(var n=D.cookie.split("; "),o=0,t=n.length;o<t;o++){var i=n[o].split("=");if(e===i[0].replace(/(%[\da-f]{2})+/gi,decodeURIComponent))return i[1]||""}},removeItem:function(e,n){t.setItem(e,"",n)}}):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,n){var o=u.get.storageOptions();t===S.localStorage&&o.expires&&(u.debug("Storing expiration value in localStorage",e,o.expires),t.setItem(e+i.expirationKey,o.expires)),u.debug("Value stored",e,n);try{t.setItem(e,n,o)}catch(e){u.error(c.setItem,e)}},get:function(e){var n,o=t.getItem(e);return t===S.localStorage&&null!=(n=t.getItem(e+i.expirationKey))&&new Date(n)<new Date&&(u.debug("Value in localStorage has expired. Deleting key",e),u.storage.remove(e),o=null),o="undefined"!==o&&"null"!==o&&null!=o?o:void 0},remove:function(e){var n=u.get.storageOptions();n.expires=u.get.expirationDate(-1),t===S.localStorage&&t.removeItem(e+i.expirationKey),t.removeItem(e,n)}},setting:function(e,n){if(u.debug("Changing setting",e,n),w.i