https://www.rculturi.com/wp-content/plugins/magee-shortcodes/assets/js/jquery.waypoints_ver-2.0.5.js
1// Generated by CoffeeScript 1.6.2 2/*!
vendor: 16,749 bytes, lines 3-517
3 Waypoints - v2.0.5 4Copyright (c) 2011-2014 Caleb Troughton 5Licensed under the MIT 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 })(window, 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 this.element[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 if (options.offset === 'bottom-in-view') { 211 options.offset = function() { 212 var contextHeight; 213 214 contextHeight = $[wps]('viewportHeight'); 215 if (!$.isWindow(context.element)) { 216 contextHeight = context.$element.height(); 217 } 218 return contextHeight - $(this).outerHeight(); 219 }; 220 } 221 this.$element = $element; 222 this.element = $element[0]; 223 this.axis = options.horizontal ? 'horizontal' : 'vertical'; 224 this.callback = options.handler; 225 this.context = context; 226 this.enabled = options.enabled; 227 this.id = 'waypoints' + waypointCounter++; 228 this.offset = null; 229 this.options = options; 230 context.waypoints[this.axis][this.id] = this; 231 allWaypoints[this.axis][this.id] = this; 232 idList = (_ref = this.element[waypointKey]) != null ? _ref : []; 233 idList.push(this.id); 234 this.element[waypointKey] = idList; 235 } 236 237 Waypoint.prototype.trigger = function(args) { 238 if (!this.enabled) { 239 return; 240 } 241 if (this.callback != null) { 242 this.callback.apply(this.element, args); 243 } 244 if (this.options.triggerOnce) { 245 return this.destroy(); 246 } 247 }; 248 249 Waypoint.prototype.disable = function() { 250 return this.enabled = false; 251 }; 252 253 Waypoint.prototype.enable = function() { 254 this.context.refresh(); 255 return this.enabled = true; 256 }; 257 258 Waypoint.prototype.destroy = function() { 259 delete allWaypoints[this.axis][this.id]; 260 delete this.context.waypoints[this.axis][this.id]; 261 return this.context.checkEmpty(); 262 }; 263 264 Waypoint.getWaypointsByElement = function(element) { 265 var all, ids; 266 267 ids = element[waypointKey]; 268 if (!ids) { 269 return []; 270 } 271 all = $.extend({}, allWaypoints.horizontal, allWaypoints.vertical); 272 return $.map(ids, function(id) { 273 return all[id]; 274 }); 275 }; 276 277 return Waypoint; 278 279 })(); 280 methods = { 281 init: function(f, options) { 282 var _ref; 283 284 options = $.extend({}, $.fn[wp].defaults, options); 285 if ((_ref = options.handler) == null) { 286 options.handler = f; 287 } 288 this.each(function() { 289 var $this, context, contextElement, _ref1; 290 291 $this = $(this); 292 contextElement = (_ref1 = options.context) != null ? _ref1 : $.fn[wp].defaults.context; 293 if (!$.isWindow(contextElement)) { 294 contextElement = $this.closest(contextElement); 295 } 296 contextElement = $(contextElement); 297 context = contexts[contextElement[0][contextKey]]; 298 if (!context) { 299 context = new Context(contextElement); 300 } 301 return new Waypoint($this, context, options); 302 }); 303 $[wps]('refresh'); 304 return this; 305 }, 306 disable: function() { 307 return methods._invoke.call(this, 'disable'); 308 }, 309 enable: function() { 310 return methods._invoke.call(this, 'enable'); 311 }, 312 destroy: function() { 313 return methods._invoke.call(this, 'destroy'); 314 }, 315 prev: function(axis, selector) { 316 return methods._traverse.call(this, axis, selector, function(stack, index, waypoints) { 317 if (index > 0) { 318 return stack.push(waypoints[index - 1]); 319 } 320 }); 321 }, 322 next: function(axis, selector) { 323 return methods._traverse.call(this, axis, selector, function(stack, index, waypoints) { 324 if (index < waypoints.length - 1) { 325 return stack.push(waypoints[index + 1]); 326 } 327 }); 328 }, 329 _traverse: function(axis, selector, push) { 330 var stack, waypoints; 331 332 if (axis == null) { 333 axis = 'vertical'; 334 } 335 if (selector == null) { 336 selector = window; 337 } 338 waypoints = jQMethods.aggregate(selector); 339 stack = []; 340 this.each(function() { 341 var index; 342 343 index = $.inArray(this, waypoints[axis]); 344 return push(stack, index, waypoints[axis]); 345 }); 346 return this.pushStack(stack); 347 }, 348 _invoke: function(method) { 349 this.each(function() { 350 var waypoints; 351 352 waypoints = Waypoint.getWaypointsByElement(this); 353 return $.each(waypoints, function(i, waypoint) { 354 waypoint[method](); 355 return true; 356 }); 357 }); 358 return this; 359 } 360 }; 361 $.fn[wp] = function() { 362 var args, method; 363 364 method = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : []; 365 if (methods[method]) { 366 return methods[method].apply(this, args); 367 } else if ($.isFunction(method)) { 368 return methods.init.apply(this, arguments); 369 } else if ($.isPlainObject(method)) { 370 return methods.init.apply(this, [null, method]); 371 } else if (!method) { 372 return $.error("jQuery Waypoints needs a callback function or handler option."); 373 } else { 374 return $.error("The " + method + " method does not exist in jQuery Waypoints."); 375 } 376 }; 377 $.fn[wp].defaults = { 378 context: window, 379 continuous: true, 380 enabled: true, 381 horizontal: false, 382 offset: 0, 383 triggerOnce: false 384 }; 385 jQMethods = { 386 refresh: function() { 387 return $.each(contexts, function(i, context) { 388 return context.refresh(); 389 }); 390 }, 391 viewportHeight: function() { 392 var _ref; 393 394 return (_ref = window.innerHeight) != null ? _ref : $w.height(); 395 }, 396 aggregate: function(contextSelector) { 397 var collection, waypoints, _ref; 398 399 collection = allWaypoints; 400 if (contextSelector) { 401 collection = (_ref = contexts[$(contextSelector)[0][contextKey]]) != null ? _ref.waypoints : void 0; 402 } 403 if (!collection) { 404 return []; 405 } 406 waypoints = { 407 horizontal: [], 408 vertical: [] 409 }; 410 $.each(waypoints, function(axis, arr) { 411 $.each(collection[axis], function(key, waypoint) { 412 return arr.push(waypoint); 413 }); 414 arr.sort(function(a, b) { 415 return a.offset - b.offset; 416 }); 417 waypoints[axis] = $.map(arr, function(waypoint) { 418 return waypoint.element; 419 }); 420 return waypoints[axis] = $.unique(waypoints[axis]); 421 }); 422 return waypoints; 423 }, 424 above: function(contextSelector) { 425 if (contextSelector == null) { 426 contextSelector = window; 427 } 428 return jQMethods._filter(contextSelector, 'vertical', function(context, waypoint) { 429 return waypoint.offset <= context.oldScroll.y; 430 }); 431 }, 432 below: function(contextSelector) { 433 if (contextSelector == null) { 434 contextSelector = window; 435 } 436 return jQMethods._filter(contextSelector, 'vertical', function(context, waypoint) { 437 return waypoint.offset > context.oldScroll.y; 438 }); 439 }, 440 left: function(contextSelector) { 441 if (contextSelector == null) { 442 contextSelector = window; 443 } 444 return jQMethods._filter(contextSelector, 'horizontal', function(context, waypoint) { 445 return waypoint.offset <= context.oldScroll.x; 446 }); 447 }, 448 right: function(contextSelector) { 449 if (contextSelector == null) { 450 contextSelector = window; 451 } 452 return jQMethods._filter(contextSelector, 'horizontal', function(context, waypoint) { 453 return waypoint.offset > context.oldScroll.x; 454 }); 455 }, 456 enable: function() { 457 return jQMethods._invoke('enable'); 458 }, 459 disable: function() { 460 return jQMethods._invoke('disable'); 461 }, 462 destroy: function() { 463 return jQMethods._invoke('destroy'); 464 }, 465 extendFn: function(methodName, f) { 466 return methods[methodName] = f; 467 }, 468 _invoke: function(method) { 469 var waypoints; 470 471 waypoints = $.extend({}, allWaypoints.vertical, allWaypoints.horizontal); 472 return $.each(waypoints, function(key, waypoint) { 473 waypoint[method](); 474 return true; 475 }); 476 }, 477 _filter: function(selector, axis, test) { 478 var context, waypoints; 479 480 context = contexts[$(selector)[0][contextKey]]; 481 if (!context) { 482 return []; 483 } 484 waypoints = []; 485 $.each(context.waypoints[axis], function(i, waypoint) { 486 if (test(context, waypoint)) { 487 return waypoints.push(waypoint); 488 } 489 }); 490 waypoints.sort(function(a, b) { 491 return a.offset - b.offset; 492 }); 493 return $.map(waypoints, function(waypoint) { 494 return waypoint.element; 495 }); 496 } 497 }; 498 $[wps] = function() { 499 var args, method; 500 501 method = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : []; 502 if (jQMethods[method]) { 503 return jQMethods[method].apply(null, args); 504 } else { 505 return jQMethods.aggregate.call(null, method); 506 } 507 }; 508 $[wps].settings = { 509 resizeThrottle: 100, 510 scrollThrottle: 30 511 }; 512 return $w.on('load.waypoints', function() { 513 return $[wps]('refresh'); 514 }); 515 }); 516 517}).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.