1 2(function (window, document) { 3 'use strict'; 4 5 var ImageSizer = window.ImageSizer = window.ImageSizer || {}; 6 7 ImageSizer.ready = function (fn) { 8 if (document.readyState === 'loading') { 9 document.addEventListener('DOMContentLoaded', fn); 10 } else { 11 fn(); 12 } 13 }; 14 15 ImageSizer.containerOf = function (link) { 16 return link.closest('.gallery') || link.closest('div, p') || document.body; 17 }; 18 19 ImageSizer.groups = function (selector, fn) { 20 var containers = []; 21 var members = []; 22 23 Array.prototype.forEach.call(document.querySelectorAll(selector), function (link) { 24 var container = ImageSizer.containerOf(link); 25 var index = containers.indexOf(container); 26 27 if (index < 0) { 28 index = containers.push(container) - 1; 29 members.push([]); 30 } 31 32 members[index].push(link); 33 }); 34 35 containers.forEach(function (container, index) { 36 fn(container, index, members[index]); 37 }); 38 39 return containers; 40 }; 41 42 ImageSizer.ensureAttr = function (el, attr, fallback) { 43 if (!el.hasAttribute(attr)) { 44 var value = el.getAttribute('data-gallery') || fallback || ''; 45 46 if (value !== '') { 47 el.setAttribute(attr, value); 48 } 49 } 50 }; 51})(window, document);
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.