1/*! 2 * jQuery imagesLoaded plugin v1.2.1 3 * http://github.com/desandro/imagesloaded 4 * 5 * MIT License. by Paul Irish et al. 6 */ 7 8(function($, undefined) { 9 10// $('#my-container').imagesLoaded(myFunction) 11// or 12// $('img').imagesLoaded(myFunction) 13 14// execute a callback when all images have loaded. 15// needed because .load() doesn't work on cached images 16 17// callback is executed when all images has fineshed loading 18// callback function arguments: $all_images, $proper_images, $broken_images 19// `this` is the jQuery wrapped container 20 21// returns previous jQuery wrapped container extended with deferred object 22// done method arguments: .done( function( $all_images ){ ... } ) 23// fail method arguments: .fail( function( $all_images, $proper_images, $broken_images ){ ... } ) 24// progress method arguments: .progress( function( images_count, loaded_count, proper_count, broken_count ) 25 26$.fn.imagesLoaded = function( callback ) { 27 var $this = this, 28 deferred = $.Deferred(), 29 $images = $this.find('img').add( $this.filter('img') ), 30 len = $images.length, 31 blank = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==', 32 loaded = [], 33 proper = [], 34 broken = []; 35 36 function doneLoading() { 37 var $proper = $(proper), 38 $broken = $(broken); 39 40 if ( broken.length ) { 41 deferred.reject( $images, $proper, $broken ); 42 } else { 43 deferred.resolve( $images ); 44 } 45 46 callback.call( $this, $images, $proper, $broken ); 47 } 48 49 function imgLoaded( event ) { 50 // dont proceed if img src is blank or if img is already loaded 51 if ( event.target.src === blank || $.inArray( this, loaded ) !== -1 ) { 52 return; 53 } 54 55 loaded.push( this ); 56 // keep track of broken and properly loaded images 57 if ( event.type === 'error' ) { 58 broken.push( this ); 59 } else { 60 proper.push( this ); 61 } 62 63 deferred.notify( $images.length, loaded.length, proper.length, broken.length ); 64 65 if ( --len <= 0 ){ 66 setTimeout( doneLoading ); 67 $images.unbind( '.imagesLoaded', imgLoaded ); 68 } 69 } 70 71 // if no images, trigger immediately 72 if ( !len ) { 73 doneLoading(); 74 } 75 76 $images.bind( 'load.imagesLoaded error.imagesLoaded', imgLoaded ).each( function() { 77 // cached images don't fire load sometimes, so we reset src. 78 var src = this.src; 79 // webkit hack from http://groups.google.com/group/jquery-dev/browse_thread/thread/eee6ab7b2da50e1f 80 // data uri bypasses webkit log warning (thx doug jones) 81 this.src = blank; 82 this.src = src; 83 }); 84 85 return deferred.promise( $this ); 86}; 87 88})(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.