vendor: 8,599 bytes, lines 1-263
1// Generated by CoffeeScript 1.9.2 2 3// @license Sticky-kit v1.1.2 | WTFPL | Leaf Corcoran 2015 | http://leafo.net 4 5(function() { 6 var $, win; 7 8 $ = this.jQuery || window.jQuery; 9 10 win = $(window); 11 12 $.fn.stick_in_parent = function(opts) { 13 var doc, elm, enable_bottoming, fn, i, inner_scrolling, len, manual_spacer, offset_top, outer_width, parent_selector, recalc_every, sticky_class; 14 if (opts == null) { 15 opts = {}; 16 } 17 sticky_class = opts.sticky_class, inner_scrolling = opts.inner_scrolling, recalc_every = opts.recalc_every, parent_selector = opts.parent, offset_top = opts.offset_top, manual_spacer = opts.spacer, enable_bottoming = opts.bottoming; 18 if (offset_top == null) { 19 offset_top = 0; 20 } 21 if (parent_selector == null) { 22 parent_selector = void 0; 23 } 24 if (inner_scrolling == null) { 25 inner_scrolling = true; 26 } 27 if (sticky_class == null) { 28 sticky_class = "is_stuck"; 29 } 30 doc = $(document); 31 if (enable_bottoming == null) { 32 enable_bottoming = true; 33 } 34 outer_width = function(el) { 35 var _el, computed, w; 36 if (window.getComputedStyle) { 37 _el = el[0]; 38 computed = window.getComputedStyle(el[0]); 39 w = parseFloat(computed.getPropertyValue("width")) + parseFloat(computed.getPropertyValue("margin-left")) + parseFloat(computed.getPropertyValue("margin-right")); 40 if (computed.getPropertyValue("box-sizing") !== "border-box") { 41 w += parseFloat(computed.getPropertyValue("border-left-width")) + parseFloat(computed.getPropertyValue("border-right-width")) + parseFloat(computed.getPropertyValue("padding-left")) + parseFloat(computed.getPropertyValue("padding-right")); 42 } 43 return w; 44 } else { 45 return el.outerWidth(true); 46 } 47 }; 48 fn = function(elm, padding_bottom, parent_top, parent_height, top, height, el_float, detached) { 49 var bottomed, detach, fixed, last_pos, last_scroll_height, offset, parent, recalc, recalc_and_tick, recalc_counter, spacer, tick; 50 if (elm.data("sticky_kit")) { 51 return; 52 } 53 elm.data("sticky_kit", true); 54 last_scroll_height = doc.height(); 55 parent = elm.parent(); 56 if (parent_selector != null) { 57 parent = parent.closest(parent_selector); 58 } 59 if (!parent.length) { 60 throw "failed to find stick parent"; 61 } 62 fixed = false; 63 bottomed = false; 64 spacer = manual_spacer != null ? manual_spacer && elm.closest(manual_spacer) : $("<div />"); 65 if (spacer) { 66 spacer.css('position', elm.css('position')); 67 } 68 recalc = function() { 69 var border_top, padding_top, restore; 70 if (detached) { 71 return; 72 } 73 last_scroll_height = doc.height(); 74 border_top = parseInt(parent.css("border-top-width"), 10); 75 padding_top = parseInt(parent.css("padding-top"), 10); 76 padding_bottom = parseInt(parent.css("padding-bottom"), 10); 77 parent_top = parent.offset().top + border_top + padding_top; 78 parent_height = parent.height(); 79 if (fixed) { 80 fixed = false; 81 bottomed = false; 82 if (manual_spacer == null) { 83 elm.insertAfter(spacer); 84 spacer.detach(); 85 } 86 elm.css({ 87 position: "", 88 top: "", 89 width: "", 90 bottom: "" 91 }).removeClass(sticky_class); 92 restore = true; 93 } 94 top = elm.offset().top - (parseInt(elm.css("margin-top"), 10) || 0) - offset_top; 95 height = elm.outerHeight(true); 96 el_float = elm.css("float"); 97 if (spacer) { 98 spacer.css({ 99 width: outer_width(elm), 100 height: height, 101 display: elm.css("display"), 102 "vertical-align": elm.css("vertical-align"), 103 "float": el_float 104 }); 105 } 106 if (restore) { 107 return tick(); 108 } 109 }; 110 recalc(); 111 if (height === parent_height) { 112 return; 113 } 114 last_pos = void 0; 115 offset = offset_top; 116 recalc_counter = recalc_every; 117 tick = function() { 118 var css, delta, recalced, scroll, will_bottom, win_height; 119 if (detached) { 120 return; 121 } 122 recalced = false; 123 if (recalc_counter != null) { 124 recalc_counter -= 1; 125 if (recalc_counter <= 0) { 126 recalc_counter = recalc_every; 127 recalc(); 128 recalced = true; 129 } 130 } 131 if (!recalced && doc.height() !== last_scroll_height) { 132 recalc(); 133 recalced = true; 134 } 135 scroll = win.scrollTop(); 136 if (last_pos != null) { 137 delta = scroll - last_pos; 138 } 139 last_pos = scroll; 140 if (fixed) { 141 if (enable_bottoming) { 142 will_bottom = scroll + height + offset > parent_height + parent_top; 143 if (bottomed && !will_bottom) { 144 bottomed = false; 145 elm.css({ 146 position: "fixed", 147 bottom: "", 148 top: offset 149 }).trigger("sticky_kit:unbottom"); 150 } 151 } 152 if (scroll < top) { 153 fixed = false; 154 offset = offset_top; 155 if (manual_spacer == null) { 156 if (el_float === "left" || el_float === "right") { 157 elm.insertAfter(spacer); 158 } 159 spacer.detach(); 160 } 161 css = { 162 position: "", 163 width: "", 164 top: "" 165 }; 166 elm.css(css).removeClass(sticky_class).trigger("sticky_kit:unstick"); 167 } 168 if (inner_scrolling) { 169 win_height = win.height(); 170 if (height + offset_top > win_height) { 171 if (!bottomed) { 172 offset -= delta; 173 offset = Math.max(win_height - height, offset); 174 offset = Math.min(offset_top, offset); 175 if (fixed) { 176 elm.css({ 177 top: offset + "px" 178 }); 179 } 180 } 181 } 182 } 183 } else { 184 if (scroll > top) { 185 fixed = true; 186 css = { 187 position: "fixed", 188 top: offset 189 }; 190 css.width = elm.css("box-sizing") === "border-box" ? elm.outerWidth() + "px" : elm.width() + "px"; 191 elm.css(css).addClass(sticky_class); 192 if (manual_spacer == null) { 193 elm.after(spacer); 194 if (el_float === "left" || el_float === "right") { 195 spacer.append(elm); 196 } 197 } 198 elm.trigger("sticky_kit:stick"); 199 } 200 } 201 if (fixed && enable_bottoming) { 202 if (will_bottom == null) { 203 will_bottom = scroll + height + offset > parent_height + parent_top; 204 } 205 if (!bottomed && will_bottom) { 206 bottomed = true; 207 if (parent.css("position") === "static") { 208 parent.css({ 209 position: "relative" 210 }); 211 } 212 return elm.css({ 213 position: "absolute", 214 bottom: padding_bottom, 215 top: "auto" 216 }).trigger("sticky_kit:bottom"); 217 } 218 } 219 }; 220 recalc_and_tick = function() { 221 recalc(); 222 return tick(); 223 }; 224 detach = function() { 225 detached = true; 226 win.off("touchmove", tick); 227 win.off("scroll", tick); 228 win.off("resize", recalc_and_tick); 229 $(document.body).off("sticky_kit:recalc", recalc_and_tick); 230 elm.off("sticky_kit:detach", detach); 231 elm.removeData("sticky_kit"); 232 elm.css({ 233 position: "", 234 bottom: "", 235 top: "", 236 width: "" 237 }); 238 parent.position("position", ""); 239 if (fixed) { 240 if (manual_spacer == null) { 241 if (el_float === "left" || el_float === "right") { 242 elm.insertAfter(spacer); 243 } 244 spacer.remove(); 245 } 246 return elm.removeClass(sticky_class); 247 } 248 }; 249 win.on("touchmove", tick); 250 win.on("scroll", tick); 251 win.on("resize", recalc_and_tick); 252 $(document.body).on("sticky_kit:recalc", recalc_and_tick); 253 elm.on("sticky_kit:detach", detach); 254 return setTimeout(tick, 0); 255 }; 256 for (i = 0, len = this.length; i < len; i++) { 257 elm = this[i]; 258 fn($(elm)); 259 } 260 return this; 261 }; 262 263}).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.