1/** 2 * How to: 3 * $('div.container').imagesLoaded(function(){console.log('all images loaded in .container');}); 4 * In case you need to support IE8, you need to use HTML5shiv **and** need to modify jQuery the following way: 5 * https://github.com/jquery/jquery/commit/a9533893b9e5e9a248139f5794c5d6099382cf14 6 */ 7 8(function($){ 9 'use strict'; 10 $.fn.imagesLoaded = (function(){ 11 var imageLoaded = function (img, cb, delay){ 12 var timer; 13 var isReponsive = false; 14 var $parent = $(img).parent(); 15 var $img = $('<img />'); 16 var srcset = $(img).attr('srcset'); 17 var sizes = $(img).attr('sizes') || '100vw'; 18 var src = $(img).attr('src'); 19 var onload = function(){ 20 $img.off('load error', onload); 21 clearTimeout(timer); 22 cb(); 23 }; 24 25 if(delay){ 26 timer = setTimeout(onload, delay); 27 } 28 29 $img.on('load error', onload); 30 31 if($parent.is('picture')){ 32 $parent = $parent.clone(); 33 $parent.find('img').remove().end(); 34 $parent.append($img); 35 isReponsive = true; 36 } 37 38 if(srcset){ 39 $img.attr('sizes', sizes); 40 $img.attr('srcset', srcset); 41 if(!isReponsive){ 42 $img.appendTo(document.createElement('div')); 43 } 44 isReponsive = true; 45 } else if(src){ 46 $img.attr('src', src); 47 } 48 49 if(isReponsive && !window.HTMLPictureElement){ 50 if(window.respimage){ 51 window.respimage({elements: [$img[0]]}); 52 } else if(window.picturefill){ 53 window.picturefill({elements: [$img[0]]}); 54 } else if(src){ 55 $img.attr('src', src); 56 } 57 } 58 }; 59 60 return function(cb){ 61 var i = 0; 62 var $imgs = $('img', this).add(this.filter('img')); 63 var ready = function(){ 64 i++; 65 if(i >= $imgs.length){ 66 cb(); 67 } 68 }; 69 $imgs.each(function(){ 70 imageLoaded(this, ready); 71 }); 72 return this; 73 }; 74 })(); 75})(jQuery);
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.