imagesLoaded_rails 3.0.4 → 3.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/app/assets/javascripts/imagesloaded.js +58 -36
- data/lib/imagesLoaded_rails/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YTZmM2JhYWU2MjkxOTY5NzI1YzAwM2VhNjE3ZGYwODc5NGIwZTMyNw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YTc2YmQ5MDNlOTQ3MjcxOGM4M2ZlM2ZkOTFmMmE3NDhhMDJkOGQ0OQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NDQ3YWI5ZTU3OGVmOTMzNzIyNjA5ODAzMDgwOTRlNDc0MWIyNTFmNmZiMjNh
|
10
|
+
YjY2N2JmY2RjMTc4MTUyMzA4NjcwYWU5MDJmZTA2NWQwMzJlMjkxZGQzODFj
|
11
|
+
NjcyOTYxOGI1MWY0MjZhNzVmM2ZmMWMwMDA0ZWY0Y2JkMTgyNjg=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NDBkODViMDE4ODVkMzZkMTViM2ZmODkxZTQ1NWY1ZjliMTdhNWJhNDljN2Zm
|
14
|
+
NDVhZThkZjQyMWM0YWNiZTQ1NjBlMGRhZDk3Y2I4ZGYwZmFiNzQwODAwM2E4
|
15
|
+
ZTkxYWRkM2ZlOGE0NThmM2M1YTk3ZjNkZTU1MTE4YTZhNTg5NGE=
|
@@ -1,10 +1,7 @@
|
|
1
1
|
/*!
|
2
|
-
* imagesLoaded
|
2
|
+
* imagesLoaded v3.1.1
|
3
3
|
* JavaScript is all like "You images are done yet or what?"
|
4
|
-
*
|
5
|
-
* MIT license - http://desandro.mit-license.org/
|
6
|
-
* http://desandro.github.io/imagesloaded/
|
7
|
-
* source - https://github.com/desandro/imagesloaded
|
4
|
+
* MIT License
|
8
5
|
*/
|
9
6
|
|
10
7
|
( function( window ) {
|
@@ -196,8 +193,6 @@ function defineImagesLoaded( EventEmitter, eventie ) {
|
|
196
193
|
|
197
194
|
// -------------------------- -------------------------- //
|
198
195
|
|
199
|
-
var cache = {};
|
200
|
-
|
201
196
|
function LoadingImage( img ) {
|
202
197
|
this.img = img;
|
203
198
|
}
|
@@ -206,13 +201,11 @@ function defineImagesLoaded( EventEmitter, eventie ) {
|
|
206
201
|
|
207
202
|
LoadingImage.prototype.check = function() {
|
208
203
|
// first check cached any previous images that have same src
|
209
|
-
var
|
210
|
-
if (
|
211
|
-
this.
|
204
|
+
var resource = cache[ this.img.src ] || new Resource( this.img.src );
|
205
|
+
if ( resource.isConfirmed ) {
|
206
|
+
this.confirm( resource.isLoaded, 'cached was confirmed' );
|
212
207
|
return;
|
213
208
|
}
|
214
|
-
// add this to cache
|
215
|
-
cache[ this.img.src ] = this;
|
216
209
|
|
217
210
|
// If complete is true and browser supports natural sizes,
|
218
211
|
// try to check for image status manually.
|
@@ -223,51 +216,80 @@ function defineImagesLoaded( EventEmitter, eventie ) {
|
|
223
216
|
}
|
224
217
|
|
225
218
|
// If none of the checks above matched, simulate loading on detached element.
|
226
|
-
var
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
219
|
+
var _this = this;
|
220
|
+
resource.on( 'confirm', function( resrc, message ) {
|
221
|
+
_this.confirm( resrc.isLoaded, message );
|
222
|
+
return true;
|
223
|
+
});
|
231
224
|
|
232
|
-
|
233
|
-
if ( cached.isConfirmed ) {
|
234
|
-
this.confirm( cached.isLoaded, 'cached was confirmed' );
|
235
|
-
} else {
|
236
|
-
var _this = this;
|
237
|
-
cached.on( 'confirm', function( image ) {
|
238
|
-
_this.confirm( image.isLoaded, 'cache emitted confirmed' );
|
239
|
-
return true; // bind once
|
240
|
-
});
|
241
|
-
}
|
225
|
+
resource.check();
|
242
226
|
};
|
243
227
|
|
244
228
|
LoadingImage.prototype.confirm = function( isLoaded, message ) {
|
245
|
-
this.isConfirmed = true;
|
246
229
|
this.isLoaded = isLoaded;
|
247
230
|
this.emit( 'confirm', this, message );
|
248
231
|
};
|
249
232
|
|
233
|
+
// -------------------------- Resource -------------------------- //
|
234
|
+
|
235
|
+
// Resource checks each src, only once
|
236
|
+
// separate class from LoadingImage to prevent memory leaks. See #115
|
237
|
+
|
238
|
+
var cache = {};
|
239
|
+
|
240
|
+
function Resource( src ) {
|
241
|
+
this.src = src;
|
242
|
+
// add to cache
|
243
|
+
cache[ src ] = this;
|
244
|
+
}
|
245
|
+
|
246
|
+
Resource.prototype = new EventEmitter();
|
247
|
+
|
248
|
+
Resource.prototype.check = function() {
|
249
|
+
// only trigger checking once
|
250
|
+
if ( this.isChecked ) {
|
251
|
+
return;
|
252
|
+
}
|
253
|
+
// simulate loading on detached element
|
254
|
+
var proxyImage = new Image();
|
255
|
+
eventie.bind( proxyImage, 'load', this );
|
256
|
+
eventie.bind( proxyImage, 'error', this );
|
257
|
+
proxyImage.src = this.src;
|
258
|
+
// set flag
|
259
|
+
this.isChecked = true;
|
260
|
+
};
|
261
|
+
|
262
|
+
// ----- events ----- //
|
263
|
+
|
250
264
|
// trigger specified handler for event type
|
251
|
-
|
265
|
+
Resource.prototype.handleEvent = function( event ) {
|
252
266
|
var method = 'on' + event.type;
|
253
267
|
if ( this[ method ] ) {
|
254
268
|
this[ method ]( event );
|
255
269
|
}
|
256
270
|
};
|
257
271
|
|
258
|
-
|
272
|
+
Resource.prototype.onload = function( event ) {
|
259
273
|
this.confirm( true, 'onload' );
|
260
|
-
this.unbindProxyEvents();
|
274
|
+
this.unbindProxyEvents( event );
|
261
275
|
};
|
262
276
|
|
263
|
-
|
277
|
+
Resource.prototype.onerror = function( event ) {
|
264
278
|
this.confirm( false, 'onerror' );
|
265
|
-
this.unbindProxyEvents();
|
279
|
+
this.unbindProxyEvents( event );
|
280
|
+
};
|
281
|
+
|
282
|
+
// ----- confirm ----- //
|
283
|
+
|
284
|
+
Resource.prototype.confirm = function( isLoaded, message ) {
|
285
|
+
this.isConfirmed = true;
|
286
|
+
this.isLoaded = isLoaded;
|
287
|
+
this.emit( 'confirm', this, message );
|
266
288
|
};
|
267
289
|
|
268
|
-
|
269
|
-
eventie.unbind(
|
270
|
-
eventie.unbind(
|
290
|
+
Resource.prototype.unbindProxyEvents = function( event ) {
|
291
|
+
eventie.unbind( event.target, 'load', this );
|
292
|
+
eventie.unbind( event.target, 'error', this );
|
271
293
|
};
|
272
294
|
|
273
295
|
// ----- ----- //
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: imagesLoaded_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Guy Israeli
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-01-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|