imagesLoaded_rails 3.1.2 → 3.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- OTgwZTBhZmE4MWM3OTgwZThlNjA3NjUwMGMzYmU2OTc0YmY5OGUwZQ==
5
- data.tar.gz: !binary |-
6
- MmEyZWMzMTc1YzU1Y2VhOGE1ZDhkYzU3ZWE1ODE0Mjc3ZDc2NDEwMg==
2
+ SHA1:
3
+ metadata.gz: 85bea1847708417e53b3ee50375528ee2096da67
4
+ data.tar.gz: 398a276112e9a812c57e2ff76b5fd3a1ffb00669
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- ZTM5MTBlYjEyNDFlZTUwOThjMTA1Y2U1N2VkNTc2ZWY1YTBjOTYwNjAzNTli
10
- OGRjZjJlNmI5ZjZkNDE5MzY4NGQ0NzE2ZmY4ZThmNTBiMThjYmRmZjczODMy
11
- ZDQ3YWVlMTY0ZTNkN2M5ZmE2YzU2MWFlNDk2ZjVlOGY3MzA3YjM=
12
- data.tar.gz: !binary |-
13
- MWI1ZTEwNWRjZTU1NTFiYjk1YTUyMTQzNWRlZGQyZTliM2YzNDA4YmI3YWYw
14
- ZjdkZGQ1MWM2NTFmZGFhNmQyMmYzMWFkMTc5NWUxN2QwMmQzN2U1NjQ2ODM3
15
- ZDE3MWIxYmViMDM5NDljMGExNGE2ZWYzNDlhNWE2N2U4MTgzYTg=
6
+ metadata.gz: aadc6fedcf014613a6c49ce6155b32d747800e0d42581f570a6285e70ee1c6165aa387ffff1a9561da8c6c321a31c811430f3214b927ba37ea3b22c6ee01cebc
7
+ data.tar.gz: 658e9f2c85a26b443d5da2f248c504e2ced0afedea9809aececdb97172ff94c7e770064d8e05ca63861fe11b67f2bcd5833ecaf8aa28ae20cb0eeeb860e153e4
@@ -1,317 +1,7 @@
1
1
  /*!
2
- * imagesLoaded v3.1.2
2
+ * imagesLoaded PACKAGED v3.1.4
3
3
  * JavaScript is all like "You images are done yet or what?"
4
4
  * MIT License
5
5
  */
6
6
 
7
- ( function( window ) {
8
-
9
- 'use strict';
10
-
11
- var $ = window.jQuery;
12
- var console = window.console;
13
- var hasConsole = typeof console !== 'undefined';
14
-
15
- // -------------------------- helpers -------------------------- //
16
-
17
- // extend objects
18
- function extend( a, b ) {
19
- for ( var prop in b ) {
20
- a[ prop ] = b[ prop ];
21
- }
22
- return a;
23
- }
24
-
25
- var objToString = Object.prototype.toString;
26
- function isArray( obj ) {
27
- return objToString.call( obj ) === '[object Array]';
28
- }
29
-
30
- // turn element or nodeList into an array
31
- function makeArray( obj ) {
32
- var ary = [];
33
- if ( isArray( obj ) ) {
34
- // use object if already an array
35
- ary = obj;
36
- } else if ( typeof obj.length === 'number' ) {
37
- // convert nodeList to array
38
- for ( var i=0, len = obj.length; i < len; i++ ) {
39
- ary.push( obj[i] );
40
- }
41
- } else {
42
- // array of single index
43
- ary.push( obj );
44
- }
45
- return ary;
46
- }
47
-
48
- // -------------------------- -------------------------- //
49
-
50
- function defineImagesLoaded( EventEmitter, eventie ) {
51
-
52
- /**
53
- * @param {Array, Element, NodeList, String} elem
54
- * @param {Object or Function} options - if function, use as callback
55
- * @param {Function} onAlways - callback function
56
- */
57
- function ImagesLoaded( elem, options, onAlways ) {
58
- // coerce ImagesLoaded() without new, to be new ImagesLoaded()
59
- if ( !( this instanceof ImagesLoaded ) ) {
60
- return new ImagesLoaded( elem, options );
61
- }
62
- // use elem as selector string
63
- if ( typeof elem === 'string' ) {
64
- elem = document.querySelectorAll( elem );
65
- }
66
-
67
- this.elements = makeArray( elem );
68
- this.options = extend( {}, this.options );
69
-
70
- if ( typeof options === 'function' ) {
71
- onAlways = options;
72
- } else {
73
- extend( this.options, options );
74
- }
75
-
76
- if ( onAlways ) {
77
- this.on( 'always', onAlways );
78
- }
79
-
80
- this.getImages();
81
-
82
- if ( $ ) {
83
- // add jQuery Deferred object
84
- this.jqDeferred = new $.Deferred();
85
- }
86
-
87
- // HACK check async to allow time to bind listeners
88
- var _this = this;
89
- setTimeout( function() {
90
- _this.check();
91
- });
92
- }
93
-
94
- ImagesLoaded.prototype = new EventEmitter();
95
-
96
- ImagesLoaded.prototype.options = {};
97
-
98
- ImagesLoaded.prototype.getImages = function() {
99
- this.images = [];
100
-
101
- // filter & find items if we have an item selector
102
- for ( var i=0, len = this.elements.length; i < len; i++ ) {
103
- var elem = this.elements[i];
104
- // filter siblings
105
- if ( elem.nodeName === 'IMG' ) {
106
- this.addImage( elem );
107
- }
108
- // find children
109
- var childElems = elem.querySelectorAll('img');
110
- // concat childElems to filterFound array
111
- for ( var j=0, jLen = childElems.length; j < jLen; j++ ) {
112
- var img = childElems[j];
113
- this.addImage( img );
114
- }
115
- }
116
- };
117
-
118
- /**
119
- * @param {Image} img
120
- */
121
- ImagesLoaded.prototype.addImage = function( img ) {
122
- var loadingImage = new LoadingImage( img );
123
- this.images.push( loadingImage );
124
- };
125
-
126
- ImagesLoaded.prototype.check = function() {
127
- var _this = this;
128
- var checkedCount = 0;
129
- var length = this.images.length;
130
- this.hasAnyBroken = false;
131
- // complete if no images
132
- if ( !length ) {
133
- this.complete();
134
- return;
135
- }
136
-
137
- function onConfirm( image, message ) {
138
- if ( _this.options.debug && hasConsole ) {
139
- console.log( 'confirm', image, message );
140
- }
141
-
142
- _this.progress( image );
143
- checkedCount++;
144
- if ( checkedCount === length ) {
145
- _this.complete();
146
- }
147
- return true; // bind once
148
- }
149
-
150
- for ( var i=0; i < length; i++ ) {
151
- var loadingImage = this.images[i];
152
- loadingImage.on( 'confirm', onConfirm );
153
- loadingImage.check();
154
- }
155
- };
156
-
157
- ImagesLoaded.prototype.progress = function( image ) {
158
- this.hasAnyBroken = this.hasAnyBroken || !image.isLoaded;
159
- // HACK - Chrome triggers event before object properties have changed. #83
160
- var _this = this;
161
- setTimeout( function() {
162
- _this.emit( 'progress', _this, image );
163
- if ( _this.jqDeferred && _this.jqDeferred.notify ) {
164
- _this.jqDeferred.notify( _this, image );
165
- }
166
- });
167
- };
168
-
169
- ImagesLoaded.prototype.complete = function() {
170
- var eventName = this.hasAnyBroken ? 'fail' : 'done';
171
- this.isComplete = true;
172
- var _this = this;
173
- // HACK - another setTimeout so that confirm happens after progress
174
- setTimeout( function() {
175
- _this.emit( eventName, _this );
176
- _this.emit( 'always', _this );
177
- if ( _this.jqDeferred ) {
178
- var jqMethod = _this.hasAnyBroken ? 'reject' : 'resolve';
179
- _this.jqDeferred[ jqMethod ]( _this );
180
- }
181
- });
182
- };
183
-
184
- // -------------------------- jquery -------------------------- //
185
-
186
- if ( $ ) {
187
- $.fn.imagesLoaded = function( options, callback ) {
188
- var instance = new ImagesLoaded( this, options, callback );
189
- return instance.jqDeferred.promise( $(this) );
190
- };
191
- }
192
-
193
-
194
- // -------------------------- -------------------------- //
195
-
196
- function LoadingImage( img ) {
197
- this.img = img;
198
- }
199
-
200
- LoadingImage.prototype = new EventEmitter();
201
-
202
- LoadingImage.prototype.check = function() {
203
- // first check cached any previous images that have same src
204
- var resource = cache[ this.img.src ] || new Resource( this.img.src );
205
- if ( resource.isConfirmed ) {
206
- this.confirm( resource.isLoaded, 'cached was confirmed' );
207
- return;
208
- }
209
-
210
- // If complete is true and browser supports natural sizes,
211
- // try to check for image status manually.
212
- if ( this.img.complete && this.img.naturalWidth !== undefined ) {
213
- // report based on naturalWidth
214
- this.confirm( this.img.naturalWidth !== 0, 'naturalWidth' );
215
- return;
216
- }
217
-
218
- // If none of the checks above matched, simulate loading on detached element.
219
- var _this = this;
220
- resource.on( 'confirm', function( resrc, message ) {
221
- _this.confirm( resrc.isLoaded, message );
222
- return true;
223
- });
224
-
225
- resource.check();
226
- };
227
-
228
- LoadingImage.prototype.confirm = function( isLoaded, message ) {
229
- this.isLoaded = isLoaded;
230
- this.emit( 'confirm', this, message );
231
- };
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
-
264
- // trigger specified handler for event type
265
- Resource.prototype.handleEvent = function( event ) {
266
- var method = 'on' + event.type;
267
- if ( this[ method ] ) {
268
- this[ method ]( event );
269
- }
270
- };
271
-
272
- Resource.prototype.onload = function( event ) {
273
- this.confirm( true, 'onload' );
274
- this.unbindProxyEvents( event );
275
- };
276
-
277
- Resource.prototype.onerror = function( event ) {
278
- this.confirm( false, 'onerror' );
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 );
288
- };
289
-
290
- Resource.prototype.unbindProxyEvents = function( event ) {
291
- eventie.unbind( event.target, 'load', this );
292
- eventie.unbind( event.target, 'error', this );
293
- };
294
-
295
- // ----- ----- //
296
-
297
- return ImagesLoaded;
298
- }
299
-
300
- // -------------------------- transport -------------------------- //
301
-
302
- if ( typeof define === 'function' && define.amd ) {
303
- // AMD
304
- define( [
305
- 'eventEmitter/EventEmitter',
306
- 'eventie/eventie'
307
- ],
308
- defineImagesLoaded );
309
- } else {
310
- // browser global
311
- window.imagesLoaded = defineImagesLoaded(
312
- window.EventEmitter,
313
- window.eventie
314
- );
315
- }
316
-
317
- })( window );
7
+ (function(){function e(){}function t(e,t){for(var n=e.length;n--;)if(e[n].listener===t)return n;return-1}function n(e){return function(){return this[e].apply(this,arguments)}}var i=e.prototype,r=this,o=r.EventEmitter;i.getListeners=function(e){var t,n,i=this._getEvents();if("object"==typeof e){t={};for(n in i)i.hasOwnProperty(n)&&e.test(n)&&(t[n]=i[n])}else t=i[e]||(i[e]=[]);return t},i.flattenListeners=function(e){var t,n=[];for(t=0;e.length>t;t+=1)n.push(e[t].listener);return n},i.getListenersAsObject=function(e){var t,n=this.getListeners(e);return n instanceof Array&&(t={},t[e]=n),t||n},i.addListener=function(e,n){var i,r=this.getListenersAsObject(e),o="object"==typeof n;for(i in r)r.hasOwnProperty(i)&&-1===t(r[i],n)&&r[i].push(o?n:{listener:n,once:!1});return this},i.on=n("addListener"),i.addOnceListener=function(e,t){return this.addListener(e,{listener:t,once:!0})},i.once=n("addOnceListener"),i.defineEvent=function(e){return this.getListeners(e),this},i.defineEvents=function(e){for(var t=0;e.length>t;t+=1)this.defineEvent(e[t]);return this},i.removeListener=function(e,n){var i,r,o=this.getListenersAsObject(e);for(r in o)o.hasOwnProperty(r)&&(i=t(o[r],n),-1!==i&&o[r].splice(i,1));return this},i.off=n("removeListener"),i.addListeners=function(e,t){return this.manipulateListeners(!1,e,t)},i.removeListeners=function(e,t){return this.manipulateListeners(!0,e,t)},i.manipulateListeners=function(e,t,n){var i,r,o=e?this.removeListener:this.addListener,s=e?this.removeListeners:this.addListeners;if("object"!=typeof t||t instanceof RegExp)for(i=n.length;i--;)o.call(this,t,n[i]);else for(i in t)t.hasOwnProperty(i)&&(r=t[i])&&("function"==typeof r?o.call(this,i,r):s.call(this,i,r));return this},i.removeEvent=function(e){var t,n=typeof e,i=this._getEvents();if("string"===n)delete i[e];else if("object"===n)for(t in i)i.hasOwnProperty(t)&&e.test(t)&&delete i[t];else delete this._events;return this},i.removeAllListeners=n("removeEvent"),i.emitEvent=function(e,t){var n,i,r,o,s=this.getListenersAsObject(e);for(r in s)if(s.hasOwnProperty(r))for(i=s[r].length;i--;)n=s[r][i],n.once===!0&&this.removeListener(e,n.listener),o=n.listener.apply(this,t||[]),o===this._getOnceReturnValue()&&this.removeListener(e,n.listener);return this},i.trigger=n("emitEvent"),i.emit=function(e){var t=Array.prototype.slice.call(arguments,1);return this.emitEvent(e,t)},i.setOnceReturnValue=function(e){return this._onceReturnValue=e,this},i._getOnceReturnValue=function(){return this.hasOwnProperty("_onceReturnValue")?this._onceReturnValue:!0},i._getEvents=function(){return this._events||(this._events={})},e.noConflict=function(){return r.EventEmitter=o,e},"function"==typeof define&&define.amd?define("eventEmitter/EventEmitter",[],function(){return e}):"object"==typeof module&&module.exports?module.exports=e:this.EventEmitter=e}).call(this),function(e){function t(t){var n=e.event;return n.target=n.target||n.srcElement||t,n}var n=document.documentElement,i=function(){};n.addEventListener?i=function(e,t,n){e.addEventListener(t,n,!1)}:n.attachEvent&&(i=function(e,n,i){e[n+i]=i.handleEvent?function(){var n=t(e);i.handleEvent.call(i,n)}:function(){var n=t(e);i.call(e,n)},e.attachEvent("on"+n,e[n+i])});var r=function(){};n.removeEventListener?r=function(e,t,n){e.removeEventListener(t,n,!1)}:n.detachEvent&&(r=function(e,t,n){e.detachEvent("on"+t,e[t+n]);try{delete e[t+n]}catch(i){e[t+n]=void 0}});var o={bind:i,unbind:r};"function"==typeof define&&define.amd?define("eventie/eventie",o):e.eventie=o}(this),function(e,t){"function"==typeof define&&define.amd?define(["eventEmitter/EventEmitter","eventie/eventie"],function(n,i){return t(e,n,i)}):"object"==typeof exports?module.exports=t(e,require("eventEmitter"),require("eventie")):e.imagesLoaded=t(e,e.EventEmitter,e.eventie)}(this,function(e,t,n){function i(e,t){for(var n in t)e[n]=t[n];return e}function r(e){return"[object Array]"===d.call(e)}function o(e){var t=[];if(r(e))t=e;else if("number"==typeof e.length)for(var n=0,i=e.length;i>n;n++)t.push(e[n]);else t.push(e);return t}function s(e,t,n){if(!(this instanceof s))return new s(e,t);"string"==typeof e&&(e=document.querySelectorAll(e)),this.elements=o(e),this.options=i({},this.options),"function"==typeof t?n=t:i(this.options,t),n&&this.on("always",n),this.getImages(),a&&(this.jqDeferred=new a.Deferred);var r=this;setTimeout(function(){r.check()})}function c(e){this.img=e}function f(e){this.src=e,v[e]=this}var a=e.jQuery,u=e.console,h=u!==void 0,d=Object.prototype.toString;s.prototype=new t,s.prototype.options={},s.prototype.getImages=function(){this.images=[];for(var e=0,t=this.elements.length;t>e;e++){var n=this.elements[e];"IMG"===n.nodeName&&this.addImage(n);for(var i=n.querySelectorAll("img"),r=0,o=i.length;o>r;r++){var s=i[r];this.addImage(s)}}},s.prototype.addImage=function(e){var t=new c(e);this.images.push(t)},s.prototype.check=function(){function e(e,r){return t.options.debug&&h&&u.log("confirm",e,r),t.progress(e),n++,n===i&&t.complete(),!0}var t=this,n=0,i=this.images.length;if(this.hasAnyBroken=!1,!i)return this.complete(),void 0;for(var r=0;i>r;r++){var o=this.images[r];o.on("confirm",e),o.check()}},s.prototype.progress=function(e){this.hasAnyBroken=this.hasAnyBroken||!e.isLoaded;var t=this;setTimeout(function(){t.emit("progress",t,e),t.jqDeferred&&t.jqDeferred.notify&&t.jqDeferred.notify(t,e)})},s.prototype.complete=function(){var e=this.hasAnyBroken?"fail":"done";this.isComplete=!0;var t=this;setTimeout(function(){if(t.emit(e,t),t.emit("always",t),t.jqDeferred){var n=t.hasAnyBroken?"reject":"resolve";t.jqDeferred[n](t)}})},a&&(a.fn.imagesLoaded=function(e,t){var n=new s(this,e,t);return n.jqDeferred.promise(a(this))}),c.prototype=new t,c.prototype.check=function(){var e=v[this.img.src]||new f(this.img.src);if(e.isConfirmed)return this.confirm(e.isLoaded,"cached was confirmed"),void 0;if(this.img.complete&&void 0!==this.img.naturalWidth)return this.confirm(0!==this.img.naturalWidth,"naturalWidth"),void 0;var t=this;e.on("confirm",function(e,n){return t.confirm(e.isLoaded,n),!0}),e.check()},c.prototype.confirm=function(e,t){this.isLoaded=e,this.emit("confirm",this,t)};var v={};return f.prototype=new t,f.prototype.check=function(){if(!this.isChecked){var e=new Image;n.bind(e,"load",this),n.bind(e,"error",this),e.src=this.src,this.isChecked=!0}},f.prototype.handleEvent=function(e){var t="on"+e.type;this[t]&&this[t](e)},f.prototype.onload=function(e){this.confirm(!0,"onload"),this.unbindProxyEvents(e)},f.prototype.onerror=function(e){this.confirm(!1,"onerror"),this.unbindProxyEvents(e)},f.prototype.confirm=function(e,t){this.isConfirmed=!0,this.isLoaded=e,this.emit("confirm",this,t)},f.prototype.unbindProxyEvents=function(e){n.unbind(e.target,"load",this),n.unbind(e.target,"error",this)},s});
@@ -1,3 +1,3 @@
1
1
  module ImagesLoadedRails
2
- VERSION = "3.1.2"
2
+ VERSION = "3.1.4"
3
3
  end
metadata CHANGED
@@ -1,64 +1,64 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imagesLoaded_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.2
4
+ version: 3.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guy Israeli
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-22 00:00:00.000000000 Z
11
+ date: 2014-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.3'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: railties
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ! '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '3.1'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ! '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.1'
55
- description: ! 'imagesLoaded.js Wrapper for Rails 3.1+ Asset Pipeline '
55
+ description: 'imagesLoaded.js Wrapper for Rails 3.1+ Asset Pipeline '
56
56
  email:
57
57
  executables: []
58
58
  extensions: []
59
59
  extra_rdoc_files: []
60
60
  files:
61
- - .gitignore
61
+ - ".gitignore"
62
62
  - Gemfile
63
63
  - LICENSE.txt
64
64
  - README.md
@@ -77,17 +77,17 @@ require_paths:
77
77
  - lib
78
78
  required_ruby_version: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ! '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  required_rubygems_version: !ruby/object:Gem::Requirement
84
84
  requirements:
85
- - - ! '>='
85
+ - - ">="
86
86
  - !ruby/object:Gem::Version
87
87
  version: '0'
88
88
  requirements: []
89
89
  rubyforge_project:
90
- rubygems_version: 2.1.3
90
+ rubygems_version: 2.2.1
91
91
  signing_key:
92
92
  specification_version: 4
93
93
  summary: Asset pipeline is like "I'll take care of that js for you sir" and Rails