wishthis/semantic/dist/components/nag.min.js

11 lines
6.8 KiB
JavaScript
Raw Normal View History

2022-01-13 13:00:31 +00:00
/*
* # Fomantic UI - 2.8.8
* https://github.com/fomantic/Fomantic-UI
* http://fomantic-ui.com/
*
* Copyright 2022 Contributors
* Released under the MIT license
* http://opensource.org/licenses/MIT
*
*/
2022-02-23 21:46:34 +00:00
!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),r=i.selector,s=i.error,e=i.namespace,n="."+e,t=e+"-module",a=x(this),g=i.context?x(i.context):x("body"),c=this,l=a.data(t),u={initialize:function(){u.verbose("Initializing element"),o=u.get.storage(),a.on("click"+n,r.close,u.dismiss).data(t,u),i.detachable&&a.parent()[0]!==g[0]&&a.detach().prependTo(g),0<i.displayTime&&setTimeout(u.hide,i.displayTime),u.show()},destroy:function(){u.verbose("Destroying instance"),a.removeData(t).off(n)},show:function(){if(u.should.show()&&!a.is(":visible")){if(!1===i.onShow.call(c))return u.debug("onShow callback returned false, cancelling nag animation"),!1;u.debug("Showing nag",i.animation.show),"fade"===i.animation.show?a.fadeIn(i.duration,i.easing,i.onVisible):a.slideDown(i.duration,i.easing,i.onVisible)}},hide:function(){if(!1===i.onHide.call(c))return u.debug("onHide callback returned false, cancelling nag animation"),!1;u.debug("Hiding nag",i.animation.hide),"fade"===i.animation.hide?a.fadeOut(i.duration,i.easing,i.onHidden):a.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(s.expiresFormat)},storage:function(){return"localstorage"===i.storageMethod&&w.localStorage!==I?(u.debug("Using local storage"),w.localStorage):"sessionstorage"===i.storageMethod&&w.sessionStorage!==I?(u.debug("Using session storage"),w.sessionStorage):"cookie"in D?(u.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 u.error(s.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 t=u.get.storageOptions();o===w.localStorage&&t.expires&&(u.debug("Storing expiration value in localStorage",e,t.expires),o.setItem(e+i.expirationKey,t.expires)),u.debug("Value stored",e,n);try{o.setItem(e,n,t)}catch(e){u.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&&(u.debug("Value in localStorage has expired. Deleting key",e),u.storage.remove(e),t=null),t="undefined"!=t&&"null"!=t&&t!==I&&null!==t?t:I},remove:function(e){var n=u.get.storageOptions();n.expires=u.get.expirationDate(-1),o===w.localStorage&&o.removeItem(e+i.expirationKey),o.removeItem(e,n)}},setting:function(e,n){if(u.debug("Changing setting",e,n),x.isPlainObject(e))x.extend(!0,i,e);else{if(n===I)re