You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
bazarr/static/semantic/components/nag.min.js

1 line
5.7 KiB

!function(e,o,t,i){"use strict";o=void 0!==o&&o.Math==Math?o:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")(),e.fn.nag=function(t){var i,n=e(this),s=n.selector||"",a=(new Date).getTime(),r=[],d=arguments[0],l="string"==typeof d,c=[].slice.call(arguments,1);return n.each(function(){var n,g=e.isPlainObject(t)?e.extend(!0,{},e.fn.nag.settings,t):e.extend({},e.fn.nag.settings),u=(g.className,g.selector),m=g.error,f=g.namespace,p="."+f,v=f+"-module",h=e(this),b=(h.find(u.close),e(g.context?g.context:"body")),y=this,k=h.data(v);o.requestAnimationFrame||o.mozRequestAnimationFrame||o.webkitRequestAnimationFrame||o.msRequestAnimationFrame;n={initialize:function(){n.verbose("Initializing element"),h.on("click"+p,u.close,n.dismiss).data(v,n),g.detachable&&h.parent()[0]!==b[0]&&h.detach().prependTo(b),g.displayTime>0&&setTimeout(n.hide,g.displayTime),n.show()},destroy:function(){n.verbose("Destroying instance"),h.removeData(v).off(p)},show:function(){n.should.show()&&!h.is(":visible")&&(n.debug("Showing nag",g.animation.show),"fade"==g.animation.show?h.fadeIn(g.duration,g.easing):h.slideDown(g.duration,g.easing))},hide:function(){n.debug("Showing nag",g.animation.hide),"fade"==g.animation.show?h.fadeIn(g.duration,g.easing):h.slideUp(g.duration,g.easing)},onHide:function(){n.debug("Removing nag",g.animation.hide),h.remove(),g.onHide&&g.onHide()},dismiss:function(e){g.storageMethod&&n.storage.set(g.key,g.value),n.hide(),e.stopImmediatePropagation(),e.preventDefault()},should:{show:function(){return g.persist?(n.debug("Persistent nag is set, can show nag"),!0):n.storage.get(g.key)!=g.value.toString()?(n.debug("Stored value is not set, can show nag",n.storage.get(g.key)),!0):(n.debug("Stored value is set, cannot show nag",n.storage.get(g.key)),!1)}},get:{storageOptions:function(){var e={};return g.expires&&(e.expires=g.expires),g.domain&&(e.domain=g.domain),g.path&&(e.path=g.path),e}},clear:function(){n.storage.remove(g.key)},storage:{set:function(t,i){var s=n.get.storageOptions();if("localstorage"==g.storageMethod&&void 0!==o.localStorage)o.localStorage.setItem(t,i),n.debug("Value stored using local storage",t,i);else if("sessionstorage"==g.storageMethod&&void 0!==o.sessionStorage)o.sessionStorage.setItem(t,i),n.debug("Value stored using session storage",t,i);else{if(void 0===e.cookie)return void n.error(m.noCookieStorage);e.cookie(t,i,s),n.debug("Value stored using cookie",t,i,s)}},get:function(t,i){var s;return"localstorage"==g.storageMethod&&void 0!==o.localStorage?s=o.localStorage.getItem(t):"sessionstorage"==g.storageMethod&&void 0!==o.sessionStorage?s=o.sessionStorage.getItem(t):void 0!==e.cookie?s=e.cookie(t):n.error(m.noCookieStorage),"undefined"!=s&&"null"!=s&&void 0!==s&&null!==s||(s=void 0),s},remove:function(t){var i=n.get.storageOptions();"localstorage"==g.storageMethod&&void 0!==o.localStorage?o.localStorage.removeItem(t):"sessionstorage"==g.storageMethod&&void 0!==o.sessionStorage?o.sessionStorage.removeItem(t):void 0!==e.cookie?e.removeCookie(t,i):n.error(m.noStorage)}},setting:function(o,t){if(n.debug("Changing setting",o,t),e.isPlainObject(o))e.extend(!0,g,o);else{if(void 0===t)return g[o];e.isPlainObject(g[o])?e.extend(!0,g[o],t):g[o]=t}},internal:function(o,t){if(e.isPlainObject(o))e.extend(!0,n,o);else{if(void 0===t)return n[o];n[o]=t}},debug:function(){!g.silent&&g.debug&&(g.performance?n.performance.log(arguments):(n.debug=Function.prototype.bind.call(console.info,console,g.name+":"),n.debug.apply(console,arguments)))},verbose:function(){!g.silent&&g.verbose&&g.debug&&(g.performance?n.performance.log(arguments):(n.verbose=Function.prototype.bind.call(console.info,console,g.name+":"),n.verbose.apply(console,arguments)))},error:function(){g.silent||(n.error=Function.prototype.bind.call(console.error,console,g.name+":"),n.error.apply(console,arguments))},performance:{log:function(e){var o,t,i;g.performance&&(o=(new Date).getTime(),i=a||o,t=o-i,a=o,r.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:y,"Execution Time":t})),clearTimeout(n.performance.timer),n.performance.timer=setTimeou