(function(){var a=[].slice;(function(a,b){if(typeof define==='function'&&define.amd)return define('waypoints',['jquery'],function(c){return b(c,a);});else return b(a.jQuery,a);})(this,function(b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s;d=b(c);k='ontouchstart' in c;g={horizontal:{},vertical:{}};h=1;j={};i='waypoints-context-id';n='resize.waypoints';o='scroll.waypoints';p=1;q='waypoints-waypoint-ids';r='waypoint';s='waypoints';e=(function(){function a(a){var d=this;this.$element=a;this.element=a[0];this.didResize=false;this.didScroll=false;this.id='context'+h++;this.oldScroll={x:a.scrollLeft(),y:a.scrollTop()};this.waypoints={horizontal:{},vertical:{}};this.element[i]=this.id;j[this.id]=this;a.bind(o,function(){var a;if(!(d.didScroll||k)){d.didScroll=true;a=function(){d.doScroll();return d.didScroll=false;};return c.setTimeout(a,b[s].settings.scrollThrottle);}});a.bind(n,function(){var a;if(!d.didResize){d.didResize=true;a=function(){b[s]('refresh');return d.didResize=false;};return setTimeout(a,b[s].settings.resizeThrottle);}});}a.prototype.doScroll=function(){var a,c=this;a={horizontal:{newScroll:this.$element.scrollLeft(),oldScroll:this.oldScroll.x,forward:'right',backward:'left'},vertical:{newScroll:this.$element.scrollTop(),oldScroll:this.oldScroll.y,forward:'down',backward:'up'}};b.each(a,function(a,d){var e,f,g;g=[];f=d.newScroll>d.oldScroll;e=f?d.forward:d.backward;b.each(c.waypoints[a],function(a,b){var c,e;if((d.oldScroll<(c=b.offset)&&c<=d.newScroll))return g.push(b);else if((d.newScroll<(e=b.offset)&&e<=d.oldScroll))return g.push(b);});g.sort(function(a,b){return a.offset-b.offset;});if(!f)g.reverse();return b.each(g,function(a,b){if(b.options.continuous||a===g.length-1)return b.trigger([e]);});});return this.oldScroll={x:a.horizontal.newScroll,y:a.vertical.newScroll};};a.prototype.refresh=function(){var a,c,d,e=this;d=b.isWindow(this.element);c=this.$element.offset();this.doScroll();a={horizontal:{contextOffset:d?0:c.left,contextScroll:d?0:this.oldScroll.x,contextDimension:this.$element.width(),oldScroll:this.oldScroll.x,forward:'right',backward:'left',offsetProp:'left'},vertical:{contextOffset:d?0:c.top,contextScroll:d?0:this.oldScroll.y,contextDimension:d?b[s]('viewportHeight'):this.$element.height(),oldScroll:this.oldScroll.y,forward:'down',backward:'up',offsetProp:'top'}};return b.each(a,function(a,c){return b.each(e.waypoints[a],function(a,d){var e,f,g,h,i;e=d.options.offset;g=d.offset;f=b.isWindow(d.element)?0:d.$element.offset()[c.offsetProp];if(b.isFunction(e))e=e.apply(d.element);else if(typeof e==='string'){e=parseFloat(e);if(d.options.offset.indexOf('%')>-1)e=Math.ceil(c.contextDimension*e/100);}d.offset=f-c.contextOffset+c.contextScroll-e;if((d.options.onlyOnScroll&&(g!=null))||!d.enabled)return;if(g!==null&&(g<(h=c.oldScroll)&&h<=d.offset))return d.trigger([c.backward]);else if(g!==null&&(g>(i=c.oldScroll)&&i>=d.offset))return d.trigger([c.forward]);else if(g===null&&c.oldScroll>=d.offset)return d.trigger([c.forward]);});});};a.prototype.checkEmpty=function(){if(b.isEmptyObject(this.waypoints.horizontal)&&b.isEmptyObject(this.waypoints.vertical)){this.$element.unbind([n,o].join(' '));return delete j[this.id];}};return a;})();f=(function(){function a(a,c,d){var e,f;d=b.extend({},b.fn[r].defaults,d);if(d.offset==='bottom-in-view')d.offset=function(){var a;a=b[s]('viewportHeight');if(!b.isWindow(c.element))a=c.$element.height();return a-b(this).outerHeight();};this.$element=a;this.element=a[0];this.axis=d.horizontal?'horizontal':'vertical';this.callback=d.handler;this.context=c;this.enabled=d.enabled;this.id='waypoints'+p++;this.offset=null;this.options=d;c.waypoints[this.axis][this.id]=this;g[this.axis][this.id]=this;e=(f=this.element[q])!=null?f:[];e.push(this.id);this.element[q]=e;}a.prototype.trigger=function(a){if(!this.enabled)return;if(this.callback!=null)this.callback.apply(this.element,a);if(this.options.triggerOnce)return this.destroy();};a.prototype.disable=function(){return this.enabled=false;};a.prototype.enable=function(){this.context.refresh();return this.enabled=true;};a.prototype.destroy=function(){delete g[this.axis][this.id];delete this.context.waypoints[this.axis][this.id];return this.context.checkEmpty();};a.getWaypointsByElement=function(a){var c,d;d=a[q];if(!d)return [];c=b.extend({},g.horizontal,g.vertical);return b.map(d,function(a){return c[a];});};return a;})();m={init:function(a,c){var d;if(c==null)c={};if((d=c.handler)==null)c.handler=a;this.each(function(){var a,d,g,h;a=b(this);g=(h=c.context)!=null?h:b.fn[r].defaults.context;if(!b.isWindow(g))g=a.closest(g);g=b(g);d=j[g[0][i]];if(!d)d=new e(g);return new f(a,d,c);});b[s]('refresh');return this;},disable:function(){return m._invoke.call(this,'disable');},enable:function(){return m._invoke.call(this,'enable');},destroy:function(){return m._invoke.call(this,'destroy');},prev:function(a,b){return m._traverse.call(this,a,b,function(a,b,c){if(b>0)return a.push(c[b-1]);});},next:function(a,b){return m._traverse.call(this,a,b,function(a,b,c){if(ba.oldScroll.y;});},left:function(a){if(a==null)a=c;return l._filter(a,'horizontal',function(a,b){return b.offset<=a.oldScroll.x;});},right:function(a){if(a==null)a=c;return l._filter(a,'horizontal',function(a,b){return b.offset>a.oldScroll.x;});},enable:function(){return l._invoke('enable');},disable:function(){return l._invoke('disable');},destroy:function(){return l._invoke('destroy');},extendFn:function(a,b){return m[a]=b;},_invoke:function(a){var c;c=b.extend({},g.vertical,g.horizontal);return b.each(c,function(b,c){c[a]();return true;});},_filter:function(a,c,d){var e,f;e=j[b(a)[0][i]];if(!e)return [];f=[];b.each(e.waypoints[c],function(a,b){if(d(e,b))return f.push(b);});f.sort(function(a,b){return a.offset-b.offset;});return b.map(f,function(a){return a.element;});}};b[s]=function(){var b,c;c=arguments[0],b=2<=arguments.length?a.call(arguments,1):[];if(l[c])return l[c].apply(null,b);else return l.aggregate.call(null,c);};b[s].settings={resizeThrottle:100,scrollThrottle:30};return d.load(function(){return b[s]('refresh');});});}).call(this);