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
3.2 KiB

(function(e,t,n,o){e.fn.nag=function(n){var i=e.extend(!0,{},e.fn.nag.settings,n),a=arguments||!1;return e(this).each(function(){var n,s,r,c,l,u,d,f,m,p=e(this),g=p.find(i.selector.close),h=e(i.context),v=p.data("module"),b=i.className,y=t.requestAnimationFrame||t.mozRequestAnimationFrame||t.webkitRequestAnimationFrame||t.msRequestAnimationFrame||function(e){setTimeout(e,0)};return m={initialize:function(){n=p.offset(),s=p.outerHeight(),r=h.outerWidth(),c=h.outerHeight(),l=h.offset(),p.data("module",m),g.on("mouseenter mouseleave",m.event.hover).on("click",m.dismiss),i.context==t&&"fixed"==i.position&&p.addClass(b.fixed),i.sticky&&("absolute"==i.position?h.on("scroll resize",m.event.scroll):e(t).on("scroll resize",m.event.scroll),e.proxy(m.event.scroll,this)()),i.followLink&&p.on("mouseenter mouseleave",m.event.hover).on("click",m.followLink),i.displayTime>0&&setTimeout(m.hide,i.displayTime),m.should.show()?p.is(":visible")||m.show():m.hide()},refresh:function(){n=p.offset(),s=p.outerHeight(),r=h.outerWidth(),c=h.outerHeight(),l=h.offset()},show:function(){e.fn.popIn!==o?p.popIn(i.duration):p.fadeIn(i.duration,i.easing)},hide:function(){p.fadeOut(i.duration,i.easing)},stick:function(){if(m.refresh(),"fixed"==i.position){var n=e(t).prop("pageYOffset")||e(t).scrollTop(),o=p.hasClass(b.bottom)?l.top+(c-s)-n:l.top-n;p.css({position:"fixed",top:o,left:l.left,width:r-i.scrollBarWidth})}else p.css({top:d})},unStick:function(){p.css({top:""})},dismiss:function(){i.storageMethod&&m.storage.set(i.storedKey,i.storedValue),m.hide()},should:{show:function(){return m.storage.get(i.storedKey)==i.storedValue?!1:!0},stick:function(){return u=h.prop("pageYOffset")||h.scrollTop(),d=p.hasClass(b.bottom)?c-p.outerHeight()+u:u,d>n.top?!0:"fixed"==i.position?!0:!1}},followLink:function(){e.fn.followLink!==o&&p.followLink()},storage:{set:function(t,n){"local"==i.storageMethod&&store!==o?store.set(t,n):e.cookie!==o?e.cookie(t,n):m.error(i.errors.noStorage)},get:function(t){return"local"==i.storageMethod&&store!==o?store.get(t):e.cookie!==o?e.cookie(t):(m.error(i.errors.noStorage),o)}},event:{hover:function(){e(this).toggleClass(b.hover)},scroll:function(){f!==o&&clearTimeout(f),f=setTimeout(function(){m.should.stick()?y(m.stick):m.unStick()},i.lag)}},error:function(e){console.log("Nag Module:"+e)},invoke:function(t,n,a){var s;return a=a||Array.prototype.slice.call(arguments,2),"string"==typeof t&&v!==o&&(t=t.split("."),e.each(t,function(t,n){return e.isPlainObject(v[n])?(v=v[n],!0):e.isFunction(v[n])?(s=v[n],!0):(m.error(i.errors.method),!1)})),e.isFunction(s)?s.apply(n,a):s}},v!==o&&a?("invoke"==a[0]&&(a=Array.prototype.slice.call(a,1)),m.invoke(a[0],this,Array.prototype.slice.call(a,1))):(m.initialize(),o)}),this},e.fn.nag.settings={displayTime:0,followLink:!0,position:"fixed",scrollBarWidth:18,storageMethod:"cookie",storedKey:"nag",storedValue:"dismiss",sticky:!0,lag:0,context:t,errors:{noStorage:"Neither $.cookie or store is defined. A storage solution is required for storing state",followLink:"Follow link is set but the plugin is not included"},className:{bottom:"bottom",hover:"hover",fixed:"fixed"},selector:{close:".icon.close"},speed:500,easing:"easeOutQuad"}})(jQuery,window,document);