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.

0 lines
5.5 KiB

  1. !function(a,b,c,d){a.fn.nag=function(c){var e,f=a(this),g=a.extend(!0,{},a.fn.nag.settings,c),h=g.className,i=g.selector,j=g.error,k=g.namespace,l="."+k,m=k+"-module",n=f.selector||"",o=(new Date).getTime(),p=[],q=arguments[0],r="string"==typeof q,s=[].slice.call(arguments,1);return a(this).each(function(){var c,k,t,u,v,w,x,y,z,A=a(this),B=A.find(i.close),C=a(g.context),D=this,E=A.data(m),F=b.requestAnimationFrame||b.mozRequestAnimationFrame||b.webkitRequestAnimationFrame||b.msRequestAnimationFrame||function(a){setTimeout(a,0)};z={initialize:function(){z.verbose("Initializing element"),c=A.offset(),k=A.outerHeight(),t=C.outerWidth(),u=C.outerHeight(),v=C.offset(),A.data(m,z),B.on("click"+l,z.dismiss),g.context==b&&"fixed"==g.position&&A.addClass(h.fixed),g.sticky&&(z.verbose("Adding scroll events"),"absolute"==g.position?C.on("scroll"+l,z.event.scroll).on("resize"+l,z.event.scroll):a(b).on("scroll"+l,z.event.scroll).on("resize"+l,z.event.scroll),a.proxy(z.event.scroll,this)()),g.displayTime>0&&setTimeout(z.hide,g.displayTime),z.should.show()?A.is(":visible")||z.show():z.hide()},destroy:function(){z.verbose("Destroying instance"),A.removeData(m).off(l),g.sticky&&C.off(l)},refresh:function(){z.debug("Refreshing cached calculations"),c=A.offset(),k=A.outerHeight(),t=C.outerWidth(),u=C.outerHeight(),v=C.offset()},show:function(){z.debug("Showing nag",g.animation.show),"fade"==g.animation.show?A.fadeIn(g.duration,g.easing):A.slideDown(g.duration,g.easing)},hide:function(){z.debug("Showing nag",g.animation.hide),"fade"==g.animation.show?A.fadeIn(g.duration,g.easing):A.slideUp(g.duration,g.easing)},onHide:function(){z.debug("Removing nag",g.animation.hide),A.remove(),g.onHide&&g.onHide()},stick:function(){if(z.refresh(),"fixed"==g.position){var c=a(b).prop("pageYOffset")||a(b).scrollTop(),d=A.hasClass(h.bottom)?v.top+(u-k)-c:v.top-c;A.css({position:"fixed",top:d,left:v.left,width:t-g.scrollBarWidth})}else A.css({top:x})},unStick:function(){A.css({top:""})},dismiss:function(a){g.storageMethod&&z.storage.set(g.storedKey,g.storedValue),z.hide(),a.stopImmediatePropagation(),a.preventDefault()},should:{show:function(){return g.persist?(z.debug("Persistent nag is set, can show nag"),!0):z.storage.get(g.storedKey)!=g.storedValue?(z.debug("Stored value is not set, can show nag",z.storage.get(g.storedKey)),!0):(z.debug("Stored value is set, cannot show nag",z.storage.get(g.storedKey)),!1)},stick:function(){return w=C.prop("pageYOffset")||C.scrollTop(),x=A.hasClass(h.bottom)?u-A.outerHeight()+w:w,x>c.top?!0:"fixed"==g.position?!0:!1}},storage:{set:function(c,e){z.debug("Setting stored value",c,e,g.storageMethod),"local"==g.storageMethod&&b.store!==d?b.store.set(c,e):a.cookie!==d?a.cookie(c,e):z.error(j.noStorage)},get:function(c){return z.debug("Getting stored value",c,g.storageMethod),"local"==g.storageMethod&&b.store!==d?b.store.get(c):a.cookie!==d?a.cookie(c):(z.error(j.noStorage),void 0)}},event:{scroll:function(){y!==d&&clearTimeout(y),y=setTimeout(function(){z.should.stick()?F(z.stick):z.unStick()},g.lag)}},setting:function(b,c){return z.debug("Changing setting",b,c),c===d?g[b]:(a.isPlainObject(b)?a.extend(!0,g,b):g[b]=c,void 0)},internal:function(b,c){return z.debug("Changing internal",b,c),c===d?z[b]:(a.isPlainObject(b)?a.extend(!0,z,b):z[b]=c,void 0)},debug:function(){g.debug&&(g.performance?z.performance.log(arguments):(z.debug=Function.prototype.bind.call(console.info,console,g.name+":"),z.debug.apply(console,arguments)))},verbose:function(){g.verbose&&g.debug&&(g.performance?z.performance.log(arguments):(z.verbose=Function.prototype.bind.call(console.info,console,g.name+":"),z.verbose.apply(console,arguments)))},error:function(){z.error=Function.prototype.bind.call(console.error,console,g.name+":"),z.error.apply(console,arguments)},performance:{log:function(a){var b,c,d;g.performance&&(b=(new Date).getTime(),d=o||b,c=b-d,o=b,p.push({Element:D,Name:a[0],Arguments:[].slice.call(a,1)||"","Execution Time":c})),clearTimeout(z.performance.timer),z.performance.timer=setTimeout(z.performance.display,100)},display:function(){var b=g.