PageSourceSearch

https://vpsc.net/wp-content/themes/Retigo/js/jquery.waypoints.js?ver=1.5

js vpsc.net collected 2026-10-06 07:41:52 UTC 24,601 bytes, 765 lines download raw bytes

vendor: 18,162 bytes, lines 1-548
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);
521
522/*! http://mths.be/placeholder v2.0.7 by @mathias */
523;(function(window, document, $) {
524
525	var isInputSupported = 'placeholder' in document.createElement('input');
526	var isTextareaSupported = 'placeholder' in document.createElement('textarea');
527	var prototype = $.fn;
528	var valHooks = $.valHooks;
529	var propHooks = $.propHooks;
530	var hooks;
531	var placeholder;
532
533	if (isInputSupported && isTextareaSupported) {
534
535		placeholder = prototype.placeholder = function() {
536			return this;
537		};
538
539		placeholder.input = placeholder.textarea = true;
540
541	} else {
542
543		placeholder = prototype.placeholder = function() {
544			var $this = this;
545			$this
546				.filter((isInputSupported ? 'textarea' : ':input') + '[placeholder]')
547				.not('.placeholder')
548				.bind({
549					'focus.placeholder': clearPlaceholder,
550					'blur.placeholder': setPlaceholder
551				})
552				.data('placeholder-enabled', true)
553				.trigger('blur.placeholder');
554			return $this;
555		};
556
557		placeholder.input = isInputSupported;
558		placeholder.textarea = isTextareaSupported;
559
560		hooks = {
561			'get': function(element) {
562				var $element = $(element);
563
564				var $passwordInput = $element.data('placeholder-password');
565				if ($passwordInput) {
566					return $passwordInput[0].value;
567				}
568
569				return $element.data('placeholder-enabled') && $element.hasClass('placeholder') ? '' : element.value;
570			},
571			'set': function(element, value) {
572				var $element = $(element);
573
574				var $passwordInput = $element.data('placeholder-password');
575				if ($passwordInput) {
576					return $passwordInput[0].value = value;
577				}
578
579				if (!$element.data('placeholder-enabled')) {
580					return element.value = value;
581				}
582				if (value == '') {
583					element.value = value;
584					// Issue #56: Setting the placeholder causes problems if the element continues to have focus.
585					if (element != safeActiveElement()) {
586						// We can't use `triggerHandler` here because of dummy text/password inputs :(
587						setPlaceholder.call(element);
588					}
589				} else if ($element.hasClass('placeholder')) {
590					clearPlaceholder.call(element, true, value) || (element.value = value);
591				} else {
592					element.value = value;
593				}
594				// `set` can not return `undefined`; see http://jsapi.info/jquery/1.7.1/val#L2363
595				return $element;
596			}
597		};
598
599		if (!isInputSupported) {
600			valHooks.input = hooks;
601			propHooks.value = hooks;
602		}
603		if (!isTextareaSupported) {
604			valHooks.textarea = hooks;
605			propHooks.value = hooks;
606		}
607
608		$(function() {
609			// Look for forms
610			$(document).delegate('form', 'submit.placeholder', function() {
611				// Clear the placeholder values so they don't get submitted
612				var $inputs = $('.placeholder', this).each(clearPlaceholder);
613				setTimeout(function() {
614					$inputs.each(setPlaceholder);
615				}, 10);
616			});
617		});
618
619		// Clear placeholder values upon page reload
620		$(window).bind('beforeunload.placeholder', function() {
621			$('.placeholder').each(function() {
622				this.value = '';
623			});
624		});
625
626	}
627
628	function args(elem) {
629		// Return an object of element attributes
630		var newAttrs = {};
631		var rinlinejQuery = /^jQuery\d+$/;
632		$.each(elem.attributes, function(i, attr) {
633			if (attr.specified && !rinlinejQuery.test(attr.name)) {
634				newAttrs[attr.name] = attr.value;
635			}
636		});
637		return newAttrs;
638	}
639
640	function clearPlaceholder(event, value) {
641		var input = this;
642		var $input = $(input);
643		if (input.value == $input.attr('placeholder') && $input.hasClass('placeholder')) {
644			if ($input.data('placeholder-password')) {
645				$input = $input.hide().next().show().attr('id', $input.removeAttr('id').data('placeholder-id'));
646				// If `clearPlaceholder` was called from `$.valHooks.input.set`
647				if (event === true) {
648					return $input[0].value = value;
649				}
650				$input.focus();
651			} else {
652				input.value = '';
653				$input.removeClass('placeholder');
654				input == safeActiveElement() && input.select();
655			}
656		}
657	}
658
659	function setPlaceholder() {
660		var $replacement;
661		var input = this;
662		var $input = $(input);
663		var id = this.id;
664		if (input.value == '') {
665			if (input.type == 'password') {
666				if (!$input.data('placeholder-textinput')) {
667					try {
668						$replacement = $input.clone().attr({ 'type': 'text' });
669					} catch(e) {
670						$replacement = $('<input>').attr($.extend(args(this), { 'type': 'text' }));
671					}
672					$replacement
673						.removeAttr('name')
674						.data({
675							'placeholder-password': $input,
676							'placeholder-id': id
677						})
678						.bind('focus.placeholder', clearPlaceholder);
679					$input
680						.data({
681							'placeholder-textinput': $replacement,
682							'placeholder-id': id
683						})
684						.before($replacement);
685				}
686				$input = $input.removeAttr('id').hide().prev().attr('id', id).show();
687				// Note: `$input[0] != input` now!
688			}
689			$input.addClass('placeholder');
690			$input[0].value = $input.attr('placeholder');
691		} else {
692			$input.removeClass('placeholder');
693		}
694	}
695
696	function safeActiveElement() {
697		// Avoid IE9 `document.activeElement` of death
698		// https://github.com/mathiasbynens/jquery-placeholder/pull/99
699		try {
700			return document.activeElement;
701		} catch (err) {}
702	}
703
704}(this, document, jQuery));
705
706/*---------------------------------------------------*/
707/* Jquery Waypoints Sticky
708/*---------------------------------------------------*/
709
710// Generated by CoffeeScript 1.6.2
711/*
712Sticky Elements Shortcut for jQuery Waypoints - v2.0.3
713Copyright (c) 2011-2013 Caleb Troughton
714Dual licensed under the MIT license and GPL license.
715https://github.com/imakewebthings/jquery-waypoints/blob/master/licenses.txt
716*/
717
718
719(function() {
720  (function(root, factory) {
721    if (typeof define === 'function' && define.amd) {
722      return define(['jquery', 'waypoints'], factory);
723    } else {
724      return factory(root.jQuery);
725    }
726  })(this, function($) {
727    var defaults, wrap;
728
729    defaults = {
730      wrapper: '<div class="sticky-wrapper" />',
731      stuckClass: 'stuck'
732    };
733    wrap = function($elements, options) {
734      $elements.wrap(options.wrapper);
735      return $elements.parent();
736    };
737    $.waypoints('extendFn', 'sticky', function(opt) {
738      var $wrap, options, originalHandler;
739
740      options = $.extend({}, $.fn.waypoint.defaults, defaults, opt);
741      $wrap = wrap(this, options);
742      originalHandler = options.handler;
743      options.handler = function(direction) {
744        var $sticky, shouldBeStuck;
745
746        $sticky = $(this).children(':first');
747        shouldBeStuck = direction === 'down' || direction === 'right';
748        $sticky.toggleClass(options.stuckClass, shouldBeStuck);
749        $wrap.height(shouldBeStuck ? $sticky.outerHeight() : '');
750        if (originalHandler != null) {
751          return originalHandler.call(this, direction);
752        }
753      };
754      $wrap.waypoint(options);
755      return this.data('stuckClass', options.stuckClass);
756    });
757    return $.waypoints('extendFn', 'unsticky', function() {
758      this.parent().waypoint('destroy');
759      this.unwrap();
760      return this.removeClass(this.data('stuckClass'));
761    });
762  });
763
764}).call(this);
765

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.