/* jshint strict: false */ var progressElem, statusElem; var supportsProgress; var loadedImageCount, imageCount; var container = document.querySelector('#image-container'); statusElem = document.querySelector('#status'); progressElem = document.querySelector('progress'); supportsProgress = progressElem && // IE does not support progress progressElem.toString().indexOf('Unknown') === -1; document.querySelector('#add').onclick = function() { // add new images var fragment = getItemsFragment(); container.insertBefore( fragment, container.firstChild ); // use ImagesLoaded var imgLoad = imagesLoaded( container ); imgLoad.on( 'progress', onProgress ); imgLoad.on( 'always', onAlways ); // reset progress counter imageCount = imgLoad.images.length; resetProgress(); updateProgress( 0 ); }; // reset container document.querySelector('#reset').onclick = function() { empty( container ); }; // ----- set text helper ----- // var docElem = document.documentElement; var textSetter = docElem.textContent !== undefined ? 'textContent' : 'innerText'; function setText( elem, value ) { elem[ textSetter ] = value; } function empty( elem ) { while ( elem.firstChild ) { elem.removeChild( elem.firstChild ); } } // ----- ----- // // return doc fragment with function getItemsFragment() { var fragment = document.createDocumentFragment(); for ( var i = 0; i < 7; i++ ) { var item = getImageItem(); fragment.appendChild( item ); } return fragment; } // return an