1/*! 2 -------------------------------- 3 Waterfall.js 4 -------------------------------- 5 + https://github.com/raphamorim/waterfall 6 + version 1.1.0 7 + Copyright 2016 Raphael Amorim & Israel Teixeira 8 + Licensed under the MIT license 9 + Documentation: https://github.com/raphamorim/waterfall 10*/ 11 12(function (root, factory) { 13 if (typeof define === 'function' && define.amd) { 14 define('waterfall', function () { 15 return factory 16 }) 17 } else if (typeof module === 'object' && module.exports) { 18 module.exports = factory 19 } else { 20 root.waterfall = factory 21 } 22}(this, function waterfall (container) { 23 if (typeof (container) === 'string') { 24 container = document.querySelector(container) 25 } 26 27 function style (el) { 28 return window.getComputedStyle(el) 29 } 30 31 function margin (name, el) { 32 return parseFloat(style(el)['margin' + name]) || 0 33 } 34 35 function px (n) { return parseFloat(n) + 'px' } 36 function y (el) { return parseFloat(el.style.top) } 37 function x (el) { return parseFloat(el.style.left) } 38 function width (el) { return parseFloat(style(el).width) } 39 function height (el) { return parseFloat(style(el).height) } 40 function bottom (el) { return y(el) + height(el) + margin('Bottom', el) } 41 function right (el) { return x(el) + width(el) + margin('Right', el) } 42 43 function sort (l) { 44 l = l.sort(function (a, b) { 45 var bottomDiff = bottom(b) - bottom(a) 46 return bottomDiff || x(b) - x(a) 47 }) 48 } 49 50 function Boundary (firstRow) { 51 var els = firstRow 52 sort(els) 53 54 this.add = function (el) { 55 els.push(el) 56 sort(els) 57 els.pop() 58 } 59 60 this.min = function () { return els[els.length - 1] } 61 this.max = function () { return els[0] } 62 } 63 64 function placeEl (el, top, left) { 65 el.style.position = 'absolute' 66 el.style.top = px(top) 67 el.style.left = px(left) 68 } 69 70 function placeFirstElement (el) { 71 placeEl(el, 0, margin('Left', el)) 72 } 73 74 function placeAtTheFirstLine (prev, el) { 75 placeEl(el, prev.style.top, right(prev) + margin('Left', el)) 76 } 77 78 function placeAtTheSmallestColumn (minEl, el) { 79 placeEl(el, bottom(minEl) + margin('Top', el), x(minEl)) 80 } 81 82 function adjustContainer (container, maxEl) { 83 container.style.position = 'relative' 84 container.style.height = px(bottom(maxEl) + margin('Bottom', maxEl)) 85 } 86 87 function thereIsSpace (els, i) { 88 return right(els[i - 1]) + width(els[i]) <= width(container) 89 } 90 91 var els = container.children 92 93 if (els.length) { 94 placeFirstElement(els[0]) 95 } 96 97 for (var i = 1; i < els.length && thereIsSpace(els, i); i++) { 98 placeAtTheFirstLine(els[i - 1], els[i]) 99 } 100 101 var firstRow = [].slice.call(els, 0, i) 102 var boundary = new Boundary(firstRow) 103 104 for (; i < els.length; i++) { 105 placeAtTheSmallestColumn(boundary.min(), els[i]) 106 boundary.add(els[i]) 107 } 108 109 adjustContainer(container, boundary.max()) 110}))
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.