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.
1 lines
6.2 KiB
1 lines
6.2 KiB
!function(a,b,c,d){"use strict";a.fn.nag=function(c){var e,f=a(this),g=f.selector||"",h=(new Date).getTime(),i=[],j=arguments[0],k="string"==typeof j,l=[].slice.call(arguments,1);return f.each(function(){{var f,m=a.isPlainObject(c)?a.extend(!0,{},a.fn.nag.settings,c):a.extend({},a.fn.nag.settings),n=(m.className,m.selector),o=m.error,p=m.namespace,q="."+p,r=p+"-module",s=a(this),t=s.find(n.close),u=a(m.context?m.context:"body"),v=this,w=s.data(r);b.requestAnimationFrame||b.mozRequestAnimationFrame||b.webkitRequestAnimationFrame||b.msRequestAnimationFrame||function(a){setTimeout(a,0)}}f={initialize:function(){f.verbose("Initializing element"),s.data(r,f),t.on("click"+q,f.dismiss),m.detachable&&s.parent()[0]!==u[0]&&s.detach().prependTo(u),m.displayTime>0&&setTimeout(f.hide,m.displayTime),f.show()},destroy:function(){f.verbose("Destroying instance"),s.removeData(r).off(q)},show:function(){f.should.show()&&!s.is(":visible")&&(f.debug("Showing nag",m.animation.show),"fade"==m.animation.show?s.fadeIn(m.duration,m.easing):s.slideDown(m.duration,m.easing))},hide:function(){f.debug("Showing nag",m.animation.hide),"fade"==m.animation.show?s.fadeIn(m.duration,m.easing):s.slideUp(m.duration,m.easing)},onHide:function(){f.debug("Removing nag",m.animation.hide),s.remove(),m.onHide&&m.onHide()},dismiss:function(a){m.storageMethod&&f.storage.set(m.key,m.value),f.hide(),a.stopImmediatePropagation(),a.preventDefault()},should:{show:function(){return m.persist?(f.debug("Persistent nag is set, can show nag"),!0):f.storage.get(m.key)!=m.value.toString()?(f.debug("Stored value is not set, can show nag",f.storage.get(m.key)),!0):(f.debug("Stored value is set, cannot show nag",f.storage.get(m.key)),!1)}},get:{storageOptions:function(){var a={};return m.expires&&(a.expires=m.expires),m.domain&&(a.domain=m.domain),m.path&&(a.path=m.path),a}},clear:function(){f.storage.remove(m.key)},storage:{set:function(c,e){var g=f.get.storageOptions();if("localstorage"==m.storageMethod&&b.localStorage!==d)b.localStorage.setItem(c,e),f.debug("Value stored using local storage",c,e);else{if(a.cookie===d)return void f.error(o.noCookieStorage);a.cookie(c,e,g),f.debug("Value stored using cookie",c,e,g)}},get:function(c){var e;return"localstorage"==m.storageMethod&&b.localStorage!==d?e=b.localStorage.getItem(c):a.cookie!==d?e=a.cookie(c):f.error(o.noCookieStorage),("undefined"==e||"null"==e||e===d||null===e)&&(e=d),e},remove:function(c){var e=f.get.storageOptions();"local"==m.storageMethod&&b.store!==d?b.localStorage.removeItem(c):a.cookie!==d?a.removeCookie(c,e):f.error(o.noStorage)}},setting:function(b,c){if(f.debug("Changing setting",b,c),a.isPlainObject(b))a.extend(!0,m,b);else{if(c===d)return m[b];m[b]=c}},internal:function(b,c){if(a.isPlainObject(b))a.extend(!0,f,b);else{if(c===d)return f[b];f[b]=c}},debug:function(){m.debug&&(m.performance?f.performance.log(arguments):(f.debug=Function.prototype.bind.call(console.info,console,m.name+":"),f.debug.apply(console,arguments)))},verbose:function(){m.verbose&&m.debug&&(m.performance?f.performance.log(arguments):(f.verbose=Function.prototype.bind.call(console.info,console,m.name+":"),f.verbose.apply(console,arguments)))},error:function(){f.error=Function.prototype.bind.call(console.error,console,m.name+":"),f.error.apply(console,arguments)},performance:{log:function(a){var b,c,d;m.performance&&(b=(new Date).getTime(),d=h||b,c=b-d,h=b,i.push({Element:v,Name:a[0],Arguments:[].slice.call(a,1)||"","Execution Time":c})),clearTimeout(f.performance.timer),f.performance.timer=setTimeout(f.performance.display,100)},display:function(){var b=m.name+":",c=0;h=!1,clearTimeout(f.performance.timer),a.each(i,function(a,b){c+=b["Execution Time"]}),b+=" "+c+"ms",g&&(b+=" '"+g+"'"),(console.group!==d||console.table!==d)&&i.length>0&&(console.groupCollapsed(b),console.table?console.table(i):a.each(i,function(a,b){console.log(b.Name+": "+b["Execution Time"]+"ms")}),console.groupEnd()),i=[]}},invoke:function(b,c,g){var h,i,j,k=w;return c=c||l,g=v||g,"string"==typeof b&&k!==d&&(b=b.split(/[\. ]/),h=b.length-1,a.each(b,function(c,e){var g=c!=h?e+b[c+1].charAt(0).toUpperCase()+b[c+1].slice(1):b;if(a.isPlainObject(k[g])&&c!=h)k=k[g];else{if(k[g]!==d)return i=k[g],!1;if(!a.isPlainObject(k[e])||c==h)return k[e]!==d?(i=k[e],!1):(f.error(o.method,b),!1);k=k[e]}})),a.isFunction(i)?j=i.apply(g,c):i!==d&&(j=i),a.isArray(e)?e.push(j):e!==d?e=[e,j]:j!==d&&(e=j),i}},k?(w===d&&f.initialize(),f.invoke(j)):(w!==d&&f.destroy(),f.initialize())}),e!==d?e:this},a.fn.nag.settings={name:"Nag",debug:!1,verbose:!0,performance:!0,namespace:"Nag",persist:!1,displayTime:0,animation:{show:"slide",hide:"slide"},context:!1,detachable:!1,expires:30,domain:!1,path:"/",storageMethod:"cookie",key:"nag",value:"dismiss",error:{noStorage:"Neither $.cookie or store is defined. A storage solution is required for storing state",method:"The method you called is not defined."},className:{bottom:"bottom",fixed:"fixed"},selector:{close:".close.icon"},speed:500,easing:"easeOutQuad",onHide:function(){}}}(jQuery,window,document),!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){function b(a){return h.raw?a:encodeURIComponent(a)}function c(a){return h.raw?a:decodeURIComponent(a)}function d(a){return b(h.json?JSON.stringify(a):String(a))}function e(a){0===a.indexOf('"')&&(a=a.slice(1,-1).replace(/\\"/g,'"').replace(/\\\\/g,"\\"));try{return a=decodeURIComponent(a.replace(g," ")),h.json?JSON.parse(a):a}catch(b){}}function f(b,c){var d=h.raw?b:e(b);return a.isFunction(c)?c(d):d}var g=/\+/g,h=a.cookie=function(e,g,i){if(void 0!==g&&!a.isFunction(g)){if(i=a.extend({},h.defaults,i),"number"==typeof i.expires){var j=i.expires,k=i.expires=new Date;k.setTime(+k+864e5*j)}return document.cookie=[b(e),"=",d(g),i.expires?"; expires="+i.expires.toUTCString():"",i.path?"; path="+i.path:"",i.domain?"; domain="+i.domain:"",i.secure?"; secure":""].join("")}for(var l=e?void 0:{},m=document.cookie?document.cookie.split("; "):[],n=0,o=m.length;o>n;n++){var p=m[n].split("="),q=c(p.shift()),r=p.join("=");if(e&&e===q){l=f(r,g);break}e||void 0===(r=f(r))||(l[q]=r)}return l};h.defaults={},a.removeCookie=function(b,c){return void 0===a.cookie(b)?!1:(a.cookie(b,"",a.extend({},c,{expires:-1})),!a.cookie(b))}});
|