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