PageSourceSearch

https://collectemsgame.com/wp-content/themes/accesspress-parallax/js/waypoint.js

js collectemsgame.com collected 2026-09-28 09:34:36 UTC 16,877 bytes, 520 lines download raw bytes

vendor: 16,877 bytes, lines 1-520
1// Generated by CoffeeScript 1.6.2
2/*
3jQuery Waypoints - v2.0.3
4Copyright (c) 2011-2013 Caleb Troughton
5Dual licensed under the MIT license and GPL license.
6https://github.com/imakewebthings/jquery-waypoints/blob/master/licenses.txt
7*/
8
9
10(function() {
11  var __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },
12    __slice = [].slice;
13
14  (function(root, factory) {
15    if (typeof define === 'function' && define.amd) {
16      return define('waypoints', ['jquery'], function($) {
17        return factory($, root);
18      });
19    } else {
20      return factory(root.jQuery, root);
21    }
22  })(this, function($, window) {
23    var $w, Context, Waypoint, allWaypoints, contextCounter, contextKey, contexts, isTouch, jQMethods, methods, resizeEvent, scrollEvent, waypointCounter, waypointKey, wp, wps;
24
25    $w = $(window);
26    isTouch = __indexOf.call(window, 'ontouchstart') >= 0;
27    allWaypoints = {
28      horizontal: {},
29      vertical: {}
30    };
31    contextCounter = 1;
32    contexts = {};
33    contextKey = 'waypoints-context-id';
34    resizeEvent = 'resize.waypoints';
35    scrollEvent = 'scroll.waypoints';
36    waypointCounter = 1;
37    waypointKey = 'waypoints-waypoint-ids';
38    wp = 'waypoint';
39    wps = 'waypoints';
40    Context = (function() {
41      function Context($element) {
42        var _this = this;
43
44        this.$element = $element;
45        this.element = $element[0];
46        this.didResize = false;
47        this.didScroll = false;
48        this.id = 'context' + contextCounter++;
49        this.oldScroll = {
50          x: $element.scrollLeft(),
51          y: $element.scrollTop()
52        };
53        this.waypoints = {
54          horizontal: {},
55          vertical: {}
56        };
57        $element.data(contextKey, this.id);
58        contexts[this.id] = this;
59        $element.bind(scrollEvent, function() {
60          var scrollHandler;
61
62          if (!(_this.didScroll || isTouch)) {
63            _this.didScroll = true;
64            scrollHandler = function() {
65              _this.doScroll();
66              return _this.didScroll = false;
67            };
68            return window.setTimeout(scrollHandler, $[wps].settings.scrollThrottle);
69          }
70        });
71        $element.bind(resizeEvent, function() {
72          var resizeHandler;
73
74          if (!_this.didResize) {
75            _this.didResize = true;
76            resizeHandler = function() {
77              $[wps]('refresh');
78              return _this.didResize = false;
79            };
80            return window.setTimeout(resizeHandler, $[wps].settings.resizeThrottle);
81          }
82        });
83      }
84
85      Context.prototype.doScroll = function() {
86        var axes,
87          _this = this;
88
89        axes = {
90          horizontal: {
91            newScroll: this.$element.scrollLeft(),
92            oldScroll: this.oldScroll.x,
93            forward: 'right',
94            backward: 'left'
95          },
96          vertical: {
97            newScroll: this.$element.scrollTop(),
98            oldScroll: this.oldScroll.y,
99            forward: 'down',
100            backward: 'up'
101          }
102        };
103        if (isTouch && (!axes.vertical.oldScroll || !axes.vertical.newScroll)) {
104          $[wps]('refresh');
105        }
106        $.each(axes, function(aKey, axis) {
107          var direction, isForward, triggered;
108
109          triggered = [];
110          isForward = axis.newScroll > axis.oldScroll;
111          direction = isForward ? axis.forward : axis.backward;
112          $.each(_this.waypoints[aKey], function(wKey, waypoint) {
113            var _ref, _ref1;
114
115            if ((axis.oldScroll < (_ref = waypoint.offset) && _ref <= axis.newScroll)) {
116              return triggered.push(waypoint);
117            } else if ((axis.newScroll < (_ref1 = waypoint.offset) && _ref1 <= axis.oldScroll)) {
118              return triggered.push(waypoint);
119            }
120          });
121          triggered.sort(function(a, b) {
122            return a.offset - b.offset;
123          });
124          if (!isForward) {
125            triggered.reverse();
126          }
127          return $.each(triggered, function(i, waypoint) {
128            if (waypoint.options.continuous || i === triggered.length - 1) {
129              return waypoint.trigger([direction]);
130            }
131          });
132        });
133        return this.oldScroll = {
134          x: axes.horizontal.newScroll,
135          y: axes.vertical.newScroll
136        };
137      };
138
139      Context.prototype.refresh = function() {
140        var axes, cOffset, isWin,
141          _this = this;
142
143        isWin = $.isWindow(this.element);
144        cOffset = this.$element.offset();
145        this.doScroll();
146        axes = {
147          horizontal: {
148            contextOffset: isWin ? 0 : cOffset.left,
149            contextScroll: isWin ? 0 : this.oldScroll.x,
150            contextDimension: this.$element.width(),
151            oldScroll: this.oldScroll.x,
152            forward: 'right',
153            backward: 'left',
154            offsetProp: 'left'
155          },
156          vertical: {
157            contextOffset: isWin ? 0 : cOffset.top,
158            contextScroll: isWin ? 0 : this.oldScroll.y,
159            contextDimension: isWin ? $[wps]('viewportHeight') : this.$element.height(),
160            oldScroll: this.oldScroll.y,
161            forward: 'down',
162            backward: 'up',
163            offsetProp: 'top'
164          }
165        };
166        return $.each(axes, function(aKey, axis) {
167          return $.each(_this.waypoints[aKey], function(i, waypoint) {
168            var adjustment, elementOffset, oldOffset, _ref, _ref1;
169
170            adjustment = waypoint.options.offset;
171            oldOffset = waypoint.offset;
172            elementOffset = $.isWindow(waypoint.element) ? 0 : waypoint.$element.offset()[axis.offsetProp];
173            if ($.isFunction(adjustment)) {
174              adjustment = adjustment.apply(waypoint.element);
175            } else if (typeof adjustment === 'string') {
176              adjustment = parseFloat(adjustment);
177              if (waypoint.options.offset.indexOf('%') > -1) {
178                adjustment = Math.ceil(axis.contextDimension * adjustment / 100);
179              }
180            }
181            waypoint.offset = elementOffset - axis.contextOffset + axis.contextScroll - adjustment;
182            if ((waypoint.options.onlyOnScroll && (oldOffset != null)) || !waypoint.enabled) {
183              return;
184            }
185            if (oldOffset !== null && (oldOffset < (_ref = axis.oldScroll) && _ref <= waypoint.offset)) {
186              return waypoint.trigger([axis.backward]);
187            } else if (oldOffset !== null && (oldOffset > (_ref1 = axis.oldScroll) && _ref1 >= waypoint.offset)) {
188              return waypoint.trigger([axis.forward]);
189            } else if (oldOffset === null && axis.oldScroll >= waypoint.offset) {
190              return waypoint.trigger([axis.forward]);
191            }
192          });
193        });
194      };
195
196      Context.prototype.checkEmpty = function() {
197        if ($.isEmptyObject(this.waypoints.horizontal) && $.isEmptyObject(this.waypoints.vertical)) {
198          this.$element.unbind([resizeEvent, scrollEvent].join(' '));
199          return delete contexts[this.id];
200        }
201      };
202
203      return Context;
204
205    })();
206    Waypoint = (function() {
207      function Waypoint($element, context, options) {
208        var idList, _ref;
209
210        options = $.extend({}, $.fn[wp].defaults, options);
211        if (options.offset === 'bottom-in-view') {
212          options.offset = function() {
213            var contextHeight;
214
215            contextHeight = $[wps]('viewportHeight');
216            if (!$.isWindow(context.element)) {
217              contextHeight = context.$element.height();
218            }
219            return contextHeight - $(this).outerHeight();
220          };
221        }
222        this.$element = $element;
223        this.element = $element[0];
224        this.axis = options.horizontal ? 'horizontal' : 'vertical';
225        this.callback = options.handler;
226        this.context = context;
227        this.enabled = options.enabled;
228        this.id = 'waypoints' + waypointCounter++;
229        this.offset = null;
230        this.options = options;
231        context.waypoints[this.axis][this.id] = this;
232        allWaypoints[this.axis][this.id] = this;
233        idList = (_ref = $element.data(waypointKey)) != null ? _ref : [];
234        idList.push(this.id);
235        $element.data(waypointKey, idList);
236      }
237
238      Waypoint.prototype.trigger = function(args) {
239        if (!this.enabled) {
240          return;
241        }
242        if (this.callback != null) {
243          this.callback.apply(this.element, args);
244        }
245        if (this.options.triggerOnce) {
246          return this.destroy();
247        }
248      };
249
250      Waypoint.prototype.disable = function() {
251        return this.enabled = false;
252      };
253
254      Waypoint.prototype.enable = function() {
255        this.context.refresh();
256        return this.enabled = true;
257      };
258
259      Waypoint.prototype.destroy = function() {
260        delete allWaypoints[this.axis][this.id];
261        delete this.context.waypoints[this.axis][this.id];
262        return this.context.checkEmpty();
263      };
264
265      Waypoint.getWaypointsByElement = function(element) {
266        var all, ids;
267
268        ids = $(element).data(waypointKey);
269        if (!ids) {
270          return [];
271        }
272        all = $.extend({}, allWaypoints.horizontal, allWaypoints.vertical);
273        return $.map(ids, function(id) {
274          return all[id];
275        });
276      };
277
278      return Waypoint;
279
280    })();
281    methods = {
282      init: function(f, options) {
283        var _ref;
284
285        if (options == null) {
286          options = {};
287        }
288        if ((_ref = options.handler) == null) {
289          options.handler = f;
290        }
291        this.each(function() {
292          var $this, context, contextElement, _ref1;
293
294          $this = $(this);
295          contextElement = (_ref1 = options.context) != null ? _ref1 : $.fn[wp].defaults.context;
296          if (!$.isWindow(contextElement)) {
297            contextElement = $this.closest(contextElement);
298          }
299          contextElement = $(contextElement);
300          context = contexts[contextElement.data(contextKey)];
301          if (!context) {
302            context = new Context(contextElement);
303          }
304          return new Waypoint($this, context, options);
305        });
306        $[wps]('refresh');
307        return this;
308      },
309      disable: function() {
310        return methods._invoke(this, 'disable');
311      },
312      enable: function() {
313        return methods._invoke(this, 'enable');
314      },
315      destroy: function() {
316        return methods._invoke(this, 'destroy');
317      },
318      prev: function(axis, selector) {
319        return methods._traverse.call(this, axis, selector, function(stack, index, waypoints) {
320          if (index > 0) {
321            return stack.push(waypoints[index - 1]);
322          }
323        });
324      },
325      next: function(axis, selector) {
326        return methods._traverse.call(this, axis, selector, function(stack, index, waypoints) {
327          if (index < waypoints.length - 1) {
328            return stack.push(waypoints[index + 1]);
329          }
330        });
331      },
332      _traverse: function(axis, selector, push) {
333        var stack, waypoints;
334
335        if (axis == null) {
336          axis = 'vertical';
337        }
338        if (selector == null) {
339          selector = window;
340        }
341        waypoints = jQMethods.aggregate(selector);
342        stack = [];
343        this.each(function() {
344          var index;
345
346          index = $.inArray(this, waypoints[axis]);
347          return push(stack, index, waypoints[axis]);
348        });
349        return this.pushStack(stack);
350      },
351      _invoke: function($elements, method) {
352        $elements.each(function() {
353          var waypoints;
354
355          waypoints = Waypoint.getWaypointsByElement(this);
356          return $.each(waypoints, function(i, waypoint) {
357            waypoint[method]();
358            return true;
359          });
360        });
361        return this;
362      }
363    };
364    $.fn[wp] = function() {
365      var args, method;
366
367      method = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
368      if (methods[method]) {
369        return methods[method].apply(this, args);
370      } else if ($.isFunction(method)) {
371        return methods.init.apply(this, arguments);
372      } else if ($.isPlainObject(method)) {
373        return methods.init.apply(this, [null, method]);
374      } else if (!method) {
375        return $.error("jQuery Waypoints needs a callback function or handler option.");
376      } else {
377        return $.error("The " + method + " method does not exist in jQuery Waypoints.");
378      }
379    };
380    $.fn[wp].defaults = {
381      context: window,
382      continuous: true,
383      enabled: true,
384      horizontal: false,
385      offset: 0,
386      triggerOnce: false
387    };
388    jQMethods = {
389      refresh: function() {
390        return $.each(contexts, function(i, context) {
391          return context.refresh();
392        });
393      },
394      viewportHeight: function() {
395        var _ref;
396
397        return (_ref = window.innerHeight) != null ? _ref : $w.height();
398      },
399      aggregate: function(contextSelector) {
400        var collection, waypoints, _ref;
401
402        collection = allWaypoints;
403        if (contextSelector) {
404          collection = (_ref = contexts[$(contextSelector).data(contextKey)]) != null ? _ref.waypoints : void 0;
405        }
406        if (!collection) {
407          return [];
408        }
409        waypoints = {
410          horizontal: [],
411          vertical: []
412        };
413        $.each(waypoints, function(axis, arr) {
414          $.each(collection[axis], function(key, waypoint) {
415            return arr.push(waypoint);
416          });
417          arr.sort(function(a, b) {
418            return a.offset - b.offset;
419          });
420          waypoints[axis] = $.map(arr, function(waypoint) {
421            return waypoint.element;
422          });
423          return waypoints[axis] = $.unique(waypoints[axis]);
424        });
425        return waypoints;
426      },
427      above: function(contextSelector) {
428        if (contextSelector == null) {
429          contextSelector = window;
430        }
431        return jQMethods._filter(contextSelector, 'vertical', function(context, waypoint) {
432          return waypoint.offset <= context.oldScroll.y;
433        });
434      },
435      below: function(contextSelector) {
436        if (contextSelector == null) {
437          contextSelector = window;
438        }
439        return jQMethods._filter(contextSelector, 'vertical', function(context, waypoint) {
440          return waypoint.offset > context.oldScroll.y;
441        });
442      },
443      left: function(contextSelector) {
444        if (contextSelector == null) {
445          contextSelector = window;
446        }
447        return jQMethods._filter(contextSelector, 'horizontal', function(context, waypoint) {
448          return waypoint.offset <= context.oldScroll.x;
449        });
450      },
451      right: function(contextSelector) {
452        if (contextSelector == null) {
453          contextSelector = window;
454        }
455        return jQMethods._filter(contextSelector, 'horizontal', function(context, waypoint) {
456          return waypoint.offset > context.oldScroll.x;
457        });
458      },
459      enable: function() {
460        return jQMethods._invoke('enable');
461      },
462      disable: function() {
463        return jQMethods._invoke('disable');
464      },
465      destroy: function() {
466        return jQMethods._invoke('destroy');
467      },
468      extendFn: function(methodName, f) {
469        return methods[methodName] = f;
470      },
471      _invoke: function(method) {
472        var waypoints;
473
474        waypoints = $.extend({}, allWaypoints.vertical, allWaypoints.horizontal);
475        return $.each(waypoints, function(key, waypoint) {
476          waypoint[method]();
477          return true;
478        });
479      },
480      _filter: function(selector, axis, test) {
481        var context, waypoints;
482
483        context = contexts[$(selector).data(contextKey)];
484        if (!context) {
485          return [];
486        }
487        waypoints = [];
488        $.each(context.waypoints[axis], function(i, waypoint) {
489          if (test(context, waypoint)) {
490            return waypoints.push(waypoint);
491          }
492        });
493        waypoints.sort(function(a, b) {
494          return a.offset - b.offset;
495        });
496        return $.map(waypoints, function(waypoint) {
497          return waypoint.element;
498        });
499      }
500    };
501    $[wps] = function() {
502      var args, method;
503
504      method = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
505      if (jQMethods[method]) {
506        return jQMethods[method].apply(null, args);
507      } else {
508        return jQMethods.aggregate.call(null, method);
509      }
510    };
511    $[wps].settings = {
512      resizeThrottle: 100,
513      scrollThrottle: 30
514    };
515    return $w.load(function() {
516      return $[wps]('refresh');
517    });
518  });
519
520}).call(this);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.