|
|
!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=
|