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