From b8511619da31ef2bdcc8dbef35a4d2569b17c051 Mon Sep 17 00:00:00 2001 From: David DeSandro Date: Thu, 23 May 2013 07:17:11 -0400 Subject: [PATCH] lowercase i, imagesLoaded --- .jshintrc | 2 +- README.md | 26 +++++++++++++------------- imagesloaded.js | 2 +- test/append.js | 2 +- test/basics.js | 2 +- test/data-uri.js | 2 +- test/jquery-fail.js | 6 +++--- test/jquery-success.js | 6 +++--- test/local-files.js | 4 +++- test/selector-string.js | 2 +- test/single-element.js | 2 +- 11 files changed, 29 insertions(+), 27 deletions(-) diff --git a/.jshintrc b/.jshintrc index 804e9b9..96cec27 100644 --- a/.jshintrc +++ b/.jshintrc @@ -7,7 +7,7 @@ "predef": { "define": false, - "ImagesLoaded": false, + "imagesLoaded": false, "test": false, "ok": false, "equal": false, diff --git a/README.md b/README.md index 255f08c..4ddcd0f 100644 --- a/README.md +++ b/README.md @@ -24,9 +24,9 @@ bower install imagesloaded ## Usage ``` js -ImagesLoaded( elem, callback ) +imagesLoaded( elem, callback ) // you can use `new` if you like -new ImagesLoaded( elem, callback ) +new imagesLoaded( elem, callback ) ``` + `elem` _Element, NodeList, Array, or Selector String_ @@ -34,23 +34,23 @@ new ImagesLoaded( elem, callback ) ``` js // element -ImagesLoaded( document.querySelector('#container'), function( instance ) { +imagesLoaded( document.querySelector('#container'), function( instance ) { console.log('all images are loaded'); }); // selector string -ImagesLoaded( '#container', function() {...}); +imagesLoaded( '#container', function() {...}); // multiple elements var posts = document.querySelectorAll('.post'); -ImagesLoaded( posts, function() {...}); +imagesLoaded( posts, function() {...}); ``` ## Events -ImagesLoaded is an Event Emitter. You can bind event listeners to events. +imagesLoaded is an Event Emitter. You can bind event listeners to events. ``` js -var imgLoad = ImagesLoaded( elem ); +var imgLoad = imagesLoaded( elem ); function onAlways( instance ) { console.log('all images are loaded'); } @@ -70,7 +70,7 @@ imgLoad.on( 'always', function( instance ) { Triggered after all images have been either loaded or confirmed broken. -+ `instance` _ImagesLoaded_ - the ImagesLoaded instance ++ `instance` _imagesLoaded_ - the imagesLoaded instance ### done @@ -103,7 +103,7 @@ imgLoad.on( 'progress', function( instance, image ) { Triggered after each image has been loaded. -+ `instance` _ImagesLoaded_ - the ImagesLoaded instance ++ `instance` _imagesLoaded_ - the imagesLoaded instance + `image` _LoadingImage_ - the LoadingImage instance of the loaded image ## Properties @@ -116,12 +116,12 @@ _Image_ - The `img` element _Boolean_ - `true` when the image has succesfully loaded -### ImagesLoaded.images +### imagesLoaded.images Array of _LoadingImage_ instances for each image detected ``` js -var imgLoad = ImagesLoaded('#container'); +var imgLoad = imagesLoaded('#container'); imgLoad.on( 'always', function() { console.log( imgLoad.images.length + ' images loaded' ); // detect which image is broken @@ -135,7 +135,7 @@ imgLoad.on( 'always', function() { ## jQuery -If you include jQuery, ImagesLoaded can be used as a jQuery Plugin. +If you include jQuery, imagesLoaded can be used as a jQuery Plugin. ``` js $('#container').imagesLoaded( function() { @@ -170,4 +170,4 @@ This project has a [storied legacy](https://github.com/desandro/imagesloaded/gra ## MIT License -ImagesLoaded is released under the [MIT License](http://desandro.mit-license.org/). Have at it. +imagesLoaded is released under the [MIT License](http://desandro.mit-license.org/). Have at it. diff --git a/imagesloaded.js b/imagesloaded.js index 66b2ef3..0f88403 100644 --- a/imagesloaded.js +++ b/imagesloaded.js @@ -265,7 +265,7 @@ if ( typeof define === 'function' && define.amd ) { defineImagesLoaded ); } else { // browser global - window.ImagesLoaded = defineImagesLoaded( + window.imagesLoaded = defineImagesLoaded( window.EventEmitter, window.eventie ); diff --git a/test/append.js b/test/append.js index 2f0c77e..5d28354 100644 --- a/test/append.js +++ b/test/append.js @@ -12,7 +12,7 @@ test( 'append', function() { elem.appendChild( fragment ); stop(); - var imgLoad = ImagesLoaded( elem, { debug: true } ).on( 'done', function() { + var imgLoad = imagesLoaded( elem, { debug: true } ).on( 'done', function() { ok( 'appended images loaded' ); start(); }); diff --git a/test/basics.js b/test/basics.js index e1055ab..5e9ed84 100644 --- a/test/basics.js +++ b/test/basics.js @@ -6,7 +6,7 @@ test( 'basics', function() { var images = elem.querySelectorAll('img'); var isCallbacked, isDone, isAlways, isAllProgressed; // stop(); - var imgLoader = new ImagesLoaded( elem, function( obj ) { + var imgLoader = new imagesLoaded( elem, function( obj ) { ok( true, 'callback function triggered' ); equal( imgLoader, obj, 'callback argument and instance match' ); isCallbacked = true; diff --git a/test/data-uri.js b/test/data-uri.js index e78c0e5..c52ae12 100644 --- a/test/data-uri.js +++ b/test/data-uri.js @@ -2,7 +2,7 @@ test( 'data-uri', function() { 'use strict'; stop(); - ImagesLoaded('#data-uri', { debug: true }).on( 'done', function( obj ) { + imagesLoaded('#data-uri', { debug: true }).on( 'done', function( obj ) { ok( true, 'data-uri images loaded' ); equal( obj.images.length, 2, 'instance has 2 images' ); start(); diff --git a/test/jquery-fail.js b/test/jquery-fail.js index 4e6f589..6f359a5 100644 --- a/test/jquery-fail.js +++ b/test/jquery-fail.js @@ -10,19 +10,19 @@ test( 'jquery fail', function() { $('#jquery-fail').imagesLoaded( function( instance ) { ok( true, 'callback triggered' ); - ok( instance instanceof ImagesLoaded, 'instance instanceof ImagesLoaded' ); + ok( instance instanceof imagesLoaded, 'instance instanceof imagesLoaded' ); isCallbacked = true; checkReady(); }) .fail( function( instance ) { ok( true, 'done triggered' ); - ok( instance instanceof ImagesLoaded, 'instance instanceof ImagesLoaded' ); + ok( instance instanceof imagesLoaded, 'instance instanceof imagesLoaded' ); isFailed = true; checkReady(); }) .always( function( instance ) { ok( true, 'always triggered' ); - ok( instance instanceof ImagesLoaded, 'instance instanceof ImagesLoaded' ); + ok( instance instanceof imagesLoaded, 'instance instanceof imagesLoaded' ); isAlways = true; checkReady(); }) diff --git a/test/jquery-success.js b/test/jquery-success.js index e16ac3d..5a1089a 100644 --- a/test/jquery-success.js +++ b/test/jquery-success.js @@ -9,19 +9,19 @@ test( 'jquery success', function() { $('#jquery-success').imagesLoaded( function( instance ) { ok( true, 'callback triggered' ); - ok( instance instanceof ImagesLoaded, 'instance instanceof ImagesLoaded' ); + ok( instance instanceof imagesLoaded, 'instance instanceof imagesLoaded' ); isCallbacked = true; checkReady(); }) .done( function( instance ) { ok( true, 'done triggered' ); - ok( instance instanceof ImagesLoaded, 'instance instanceof ImagesLoaded' ); + ok( instance instanceof imagesLoaded, 'instance instanceof imagesLoaded' ); isDone = true; checkReady(); }) .always( function( instance ) { ok( true, 'always triggered' ); - ok( instance instanceof ImagesLoaded, 'instance instanceof ImagesLoaded' ); + ok( instance instanceof imagesLoaded, 'instance instanceof imagesLoaded' ); isAlways = true; checkReady(); }) diff --git a/test/local-files.js b/test/local-files.js index 9770f44..153ab4b 100644 --- a/test/local-files.js +++ b/test/local-files.js @@ -1,9 +1,11 @@ test( 'local files', function() { + 'use strict'; + var elem = document.querySelector('#locals'); var isCallbacked, isFailed, isAlways, isAllProgressed; // stop(); - var imgLoader = new ImagesLoaded( elem, function( obj ) { + var imgLoader = new imagesLoaded( elem, function( obj ) { ok( true, 'callback function triggered' ); equal( imgLoader, obj, 'callback argument and instance match' ); isCallbacked = true; diff --git a/test/selector-string.js b/test/selector-string.js index 2b320a3..d777057 100644 --- a/test/selector-string.js +++ b/test/selector-string.js @@ -1,7 +1,7 @@ test( 'selector string', function() { stop(); var images = document.querySelectorAll('#basics img'); - var imgLoad = ImagesLoaded('#basics', { debug: true }).on( 'done', function( obj ) { + var imgLoad = imagesLoaded('#basics', { debug: true }).on( 'done', function( obj ) { ok( true, 'selector string worked' ); ok( obj.images, 'argument has images' ); equal( obj.images.length, images.length, 'images.length matches' ); diff --git a/test/single-element.js b/test/single-element.js index 1371cc3..f6110f6 100644 --- a/test/single-element.js +++ b/test/single-element.js @@ -1,7 +1,7 @@ test( 'single element', function() { var elem = document.querySelector('#mario-with-shell'); stop(); - ImagesLoaded( elem ).on( 'done', function( obj ) { + imagesLoaded( elem ).on( 'done', function( obj ) { ok( true, 'single element worked' ); ok( obj.images, 'argument has images' ); equal( obj.images.length, 1, 'images.length = 1' );