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