// generated by coffeescript 1.6.2 /*! jquery waypoints - v2.0.5 copyright (c) 2011-2014 caleb troughton licensed under the mit license. https://github.com/imakewebthings/jquery-waypoints/blob/master/licenses.txt index advantage */ (function(){var t=[].indexof||function(t){for(var e=0,n=this.length;e=0;s={horizontal:{},vertical:{}};f=1;c={};u="waypoints-context-id";p="resize.waypoints";y="scroll.waypoints";v=1;w="waypoints-waypoint-ids";g="waypoint";m="waypoints";o=function(){function t(t){var e=this;this.$element=t;this.element=t[0];this.didresize=false;this.didscroll=false;this.id="context"+f++;this.oldscroll={x:t.scrollleft(),y:t.scrolltop()};this.waypoints={horizontal:{},vertical:{}};this.element[u]=this.id;c[this.id]=this;t.bind(y,function(){var t;if(!(e.didscroll||a)){e.didscroll=true;t=function(){e.doscroll();return e.didscroll=false};return r.settimeout(t,n[m].settings.scrollthrottle)}});t.bind(p,function(){var t;if(!e.didresize){e.didresize=true;t=function(){n[m]("refresh");return e.didresize=false};return r.settimeout(t,n[m].settings.resizethrottle)}})}t.prototype.doscroll=function(){var t,e=this;t={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"}};if(a&&(!t.vertical.oldscroll||!t.vertical.newscroll)){n[m]("refresh")}n.each(t,function(t,r){var i,o,l;l=[];o=r.newscroll>r.oldscroll;i=o?r.forward:r.backward;n.each(e.waypoints[t],function(t,e){var n,i;if(r.oldscroll<(n=e.offset)&&n<=r.newscroll){return l.push(e)}else if(r.newscroll<(i=e.offset)&&i<=r.oldscroll){return l.push(e)}});l.sort(function(t,e){return t.offset-e.offset});if(!o){l.reverse()}return n.each(l,function(t,e){if(e.options.continuous||t===l.length-1){return e.trigger([i])}})});return this.oldscroll={x:t.horizontal.newscroll,y:t.vertical.newscroll}};t.prototype.refresh=function(){var t,e,r,i=this;r=n.iswindow(this.element);e=this.$element.offset();this.doscroll();t={horizontal:{contextoffset:r?0:e.left,contextscroll:r?0:this.oldscroll.x,contextdimension:this.$element.width(),oldscroll:this.oldscroll.x,forward:"right",backward:"left",offsetprop:"left"},vertical:{contextoffset:r?0:e.top,contextscroll:r?0:this.oldscroll.y,contextdimension:r?n[m]("viewportheight"):this.$element.height(),oldscroll:this.oldscroll.y,forward:"down",backward:"up",offsetprop:"top"}};return n.each(t,function(t,e){return n.each(i.waypoints[t],function(t,r){var i,o,l,s,f;i=r.options.offset;l=r.offset;o=n.iswindow(r.element)?0:r.$element.offset()[e.offsetprop];if(n.isfunction(i)){i=i.apply(r.element)}else if(typeof i==="string"){i=parsefloat(i);if(r.options.offset.indexof("%")>-1){i=math.ceil(e.contextdimension*i/100)}}r.offset=o-e.contextoffset+e.contextscroll-i;if(r.options.onlyonscroll&&l!=null||!r.enabled){return}if(l!==null&&l<(s=e.oldscroll)&&s<=r.offset){return r.trigger([e.backward])}else if(l!==null&&l>(f=e.oldscroll)&&f>=r.offset){return r.trigger([e.forward])}else if(l===null&&e.oldscroll>=r.offset){return r.trigger([e.forward])}})})};t.prototype.checkempty=function(){if(n.isemptyobject(this.waypoints.horizontal)&&n.isemptyobject(this.waypoints.vertical)){this.$element.unbind([p,y].join(" "));return delete c[this.id]}};return t}();l=function(){function t(t,e,r){var i,o;if(r.offset==="bottom-in-view"){r.offset=function(){var t;t=n[m]("viewportheight");if(!n.iswindow(e.element)){t=e.$element.height()}return t-n(this).outerheight()}}this.$element=t;this.element=t[0];this.axis=r.horizontal?"horizontal":"vertical";this.callback=r.handler;this.context=e;this.enabled=r.enabled;this.id="waypoints"+v++;this.offset=null;this.options=r;e.waypoints[this.axis][this.id]=this;s[this.axis][this.id]=this;i=(o=this.element[w])!=null?o:[];i.push(this.id);this.element[w]=i}t.prototype.trigger=function(t){if(!this.enabled){return}if(this.callback!=null){this.callback.apply(this.element,t)}if(this.options.triggeronce){return this.destroy()}};t.prototype.disable=function(){return this.enabled=false};t.prototype.enable=function(){this.context.refresh();return this.enabled=true};t.prototype.destroy=function(){delete s[this.axis][this.id];delete this.context.waypoints[this.axis][this.id];return this.context.checkempty()};t.getwaypointsbyelement=function(t){var e,r;r=t[w];if(!r){return[]}e=n.extend({},s.horizontal,s.vertical);return n.map(r,function(t){return e[t]})};return t}();d={init:function(t,e){var r;e=n.extend({},n.fn[g].defaults,e);if((r=e.handler)==null){e.handler=t}this.each(function(){var t,r,i,s;t=n(this);i=(s=e.context)!=null?s:n.fn[g].defaults.context;if(!n.iswindow(i)){i=t.closest(i)}i=n(i);r=c[i[0][u]];if(!r){r=new o(i)}return new l(t,r,e)});n[m]("refresh");return this},disable:function(){return d._invoke.call(this,"disable")},enable:function(){return d._invoke.call(this,"enable")},destroy:function(){return d._invoke.call(this,"destroy")},prev:function(t,e){return d._traverse.call(this,t,e,function(t,e,n){if(e>0){return t.push(n[e-1])}})},next:function(t,e){return d._traverse.call(this,t,e,function(t,e,n){if(et.oldscroll.y})},left:function(t){if(t==null){t=r}return h._filter(t,"horizontal",function(t,e){return e.offset<=t.oldscroll.x})},right:function(t){if(t==null){t=r}return h._filter(t,"horizontal",function(t,e){return e.offset>t.oldscroll.x})},enable:function(){return h._invoke("enable")},disable:function(){return h._invoke("disable")},destroy:function(){return h._invoke("destroy")},extendfn:function(t,e){return d[t]=e},_invoke:function(t){var e;e=n.extend({},s.vertical,s.horizontal);return n.each(e,function(e,n){n[t]();return true})},_filter:function(t,e,r){var i,o;i=c[n(t)[0][u]];if(!i){return[]}o=[];n.each(i.waypoints[e],function(t,e){if(r(i,e)){return o.push(e)}});o.sort(function(t,e){return t.offset-e.offset});return n.map(o,function(t){return t.element})}};n[m]=function(){var t,n;n=arguments[0],t=2<=arguments.length?e.call(arguments,1):[];if(h[n]){return h[n].apply(null,t)}else{return h.aggregate.call(null,n)}};n[m].settings={resizethrottle:100,scrollthrottle:30};return i.on("load.waypoints",function(){return n[m]("refresh")})})}).call(this);