1/*! 2Waypoints Sticky Element Shortcut - 4.0.0 3Copyright © 2011-2015 Caleb Troughton 4Licensed under the MIT license. 5https://github.com/imakewebthings/waypoints/blog/master/licenses.txt 6*/ 7(function() { 8 'use strict' 9 10 var $ = window.jQuery 11 var Waypoint = window.Waypoint 12 13 /* http://imakewebthings.com/waypoints/shortcuts/sticky-elements */ 14 function Sticky(options) { 15 this.options = $.extend({}, Waypoint.defaults, Sticky.defaults, options) 16 this.element = this.options.element 17 this.$element = $(this.element) 18 this.createWrapper() 19 this.createWaypoint() 20 } 21 22 /* Private */ 23 Sticky.prototype.createWaypoint = function() { 24 var originalHandler = this.options.handler 25 26 this.waypoint = new Waypoint($.extend({}, this.options, { 27 element: this.wrapper, 28 handler: $.proxy(function(direction) { 29 var shouldBeStuck = this.options.direction.indexOf(direction) > -1 30 var wrapperHeight = shouldBeStuck ? this.$element.outerHeight(true) : '' 31 32 this.$wrapper.height(wrapperHeight) 33 this.$element.toggleClass(this.options.stuckClass, shouldBeStuck) 34 35 if (originalHandler) { 36 originalHandler.call(this, direction) 37 } 38 }, this) 39 })) 40 } 41 42 /* Private */ 43 Sticky.prototype.createWrapper = function() { 44 if (this.options.wrapper) { 45 this.$element.wrap(this.options.wrapper) 46 } 47 this.$wrapper = this.$element.parent() 48 this.wrapper = this.$wrapper[0] 49 } 50 51 /* Public */ 52 Sticky.prototype.destroy = function() { 53 if (this.$element.parent()[0] === this.wrapper) { 54 this.waypoint.destroy() 55 this.$element.removeClass(this.options.stuckClass) 56 if (this.options.wrapper) { 57 this.$element.unwrap() 58 } 59 } 60 } 61 62 Sticky.defaults = { 63 wrapper: '<div class="sticky-wrapper" />', 64 stuckClass: 'stuck', 65 direction: 'down right' 66 } 67
68 Waypoint.Sticky = Sticky 69}()) 70;
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.