PageSourceSearch

https://wholesale.alspopcorn.com/skin/frontend/base/default/js/lib/imagesloaded.js?v=7.3.173-0

js alspopcorn.com collected 2026-10-08 03:43:20 UTC 16,555 bytes, 510 lines download raw bytes

vendor: 7,487 bytes, lines 1-258
1/*!
2 * imagesLoaded PACKAGED v4.1.4
3 * JavaScript is all like "You images are done yet or what?"
4 * MIT License
5 */
6
7/**
8 * EvEmitter v1.1.0
9 * Lil' event emitter
10 * MIT License
11 */
12
13/* jshint unused: true, undef: true, strict: true */
14
15( function( global, factory ) {
16    // universal module definition
17    /* jshint strict: false */ /* globals define, module, window */
18
19    // Begin modified by Zoey
20    // if ( typeof define == 'function' && define.amd ) {
21    //     // AMD - RequireJS
22    //     define( 'ev-emitter/ev-emitter',factory );
23    // } else if ( typeof module == 'object' && module.exports ) {
24    //     // CommonJS - Browserify, Webpack
25    //     module.exports = factory();
26    // } else {
27    //     // Browser globals
28    //     global.EvEmitter = factory();
29    // }
30
31    global.EvEmitter = factory();
32    // End modified by Zoey
33}( typeof window != 'undefined' ? window : this, function() {
34
35
36
37    function EvEmitter() {}
38
39    var proto = EvEmitter.prototype;
40
41    proto.on = function( eventName, listener ) {
42        if ( !eventName || !listener ) {
43            return;
44        }
45        // set events hash
46        var events = this._events = this._events || {};
47        // set listeners array
48        var listeners = events[ eventName ] = events[ eventName ] || [];
49        // only add once
50        if ( listeners.indexOf( listener ) == -1 ) {
51            listeners.push( listener );
52        }
53
54        return this;
55    };
56
57    proto.once = function( eventName, listener ) {
58        if ( !eventName || !listener ) {
59            return;
60        }
61        // add event
62        this.on( eventName, listener );
63        // set once flag
64        // set onceEvents hash
65        var onceEvents = this._onceEvents = this._onceEvents || {};
66        // set onceListeners object
67        var onceListeners = onceEvents[ eventName ] = onceEvents[ eventName ] || {};
68        // set flag
69        onceListeners[ listener ] = true;
70
71        return this;
72    };
73
74    proto.off = function( eventName, listener ) {
75        var listeners = this._events && this._events[ eventName ];
76        if ( !listeners || !listeners.length ) {
77            return;
78        }
79        var index = listeners.indexOf( listener );
80        if ( index != -1 ) {
81            listeners.splice( index, 1 );
82        }
83
84        return this;
85    };
86
87    proto.emitEvent = function( eventName, args ) {
88        var listeners = this._events && this._events[ eventName ];
89        if ( !listeners || !listeners.length ) {
90            return;
91        }
92        // copy over to avoid interference if .off() in listener
93        listeners = listeners.slice(0);
94        args = args || [];
95        // once stuff
96        var onceListeners = this._onceEvents && this._onceEvents[ eventName ];
97
98        for ( var i=0; i < listeners.length; i++ ) {
99            var listener = listeners[i]
100            var isOnce = onceListeners && onceListeners[ listener ];
101            if ( isOnce ) {
102                // remove listener
103                // remove before trigger to prevent recursion
104                this.off( eventName, listener );
105                // unset once flag
106                delete onceListeners[ listener ];
107            }
108            // trigger listener
109            listener.apply( this, args );
110        }
111
112        return this;
113    };
114
115    proto.allOff = function() {
116        delete this._events;
117        delete this._onceEvents;
118    };
119
120    return EvEmitter;
121
122}));
123
124/*!
125 * imagesLoaded v4.1.4
126 * JavaScript is all like "You images are done yet or what?"
127 * MIT License
128 */
129
130( function( window, factory ) { 'use strict';
131    // universal module definition
132
133    /*global define: false, module: false, require: false */
134
135    // Begin modified by Zoey
136    // if ( typeof define == 'function' && define.amd ) {
137    //     // AMD
138    //     define( [
139    //         'ev-emitter/ev-emitter'
140    //     ], function( EvEmitter ) {
141    //         return factory( window, EvEmitter );
142    //     });
143    // } else if ( typeof module == 'object' && module.exports ) {
144    //     // CommonJS
145    //     module.exports = factory(
146    //         window,
147    //         require('ev-emitter')
148    //     );
149    // } else {
150    //     // browser global
151    //     window.imagesLoaded = factory(
152    //         window,
153    //         window.EvEmitter
154    //     );
155    // }
156
157    // browser global
158    window.imagesLoaded = factory(
159        window,
160        window.EvEmitter
161    );
162    // End modified by Zoey
163
164})( typeof window !== 'undefined' ? window : this,
165
166    // --------------------------  factory -------------------------- //
167
168    function factory( window, EvEmitter ) {
169
170
171
172        var $ = window.jQuery;
173        var console = window.console;
174
175        // -------------------------- helpers -------------------------- //
176
177        // extend objects
178        function extend( a, b ) {
179            for ( var prop in b ) {
180                a[ prop ] = b[ prop ];
181            }
182            return a;
183        }
184
185        var arraySlice = Array.prototype.slice;
186
187        // turn element or nodeList into an array
188        function makeArray( obj ) {
189            if ( Array.isArray( obj ) ) {
190                // use object if already an array
191                return obj;
192            }
193
194            var isArrayLike = typeof obj == 'object' && typeof obj.length == 'number';
195            if ( isArrayLike ) {
196                // convert nodeList to array
197                return arraySlice.call( obj );
198            }
199
200            // array of single index
201            return [ obj ];
202        }
203
204        // -------------------------- imagesLoaded -------------------------- //
205
206        /**
207         * @param {Array, Element, NodeList, String} elem
208         * @param {Object or Function} options - if function, use as callback
209         * @param {Function} onAlways - callback function
210         */
211        function ImagesLoaded( elem, options, onAlways ) {
212            // coerce ImagesLoaded() without new, to be new ImagesLoaded()
213            if ( !( this instanceof ImagesLoaded ) ) {
214                return new ImagesLoaded( elem, options, onAlways );
215            }
216            // use elem as selector string
217            var queryElem = elem;
218            if ( typeof elem == 'string' ) {
219                queryElem = document.querySelectorAll( elem );
220            }
221            // bail if bad element
222            if ( !queryElem ) {
223                console.error( 'Bad element for imagesLoaded ' + ( queryElem || elem ) );
224                return;
225            }
226
227            this.elements = makeArray( queryElem );
228            this.options = extend( {}, this.options );
229            // shift arguments if no options set
230            if ( typeof options == 'function' ) {
231                onAlways = options;
232            } else {
233                extend( this.options, options );
234            }
235
236            if ( onAlways ) {
237                this.on( 'always', onAlways );
238            }
239
240            this.getImages();
241
242            if ( $ ) {
243                // add jQuery Deferred object
244                this.jqDeferred = new $.Deferred();
245            }
246
247            // HACK check async to allow time to bind listeners
248            setTimeout( this.check.bind( this ) );
249        }
250
251        ImagesLoaded.prototype = Object.create( EvEmitter.prototype );
252
253        ImagesLoaded.prototype.options = {};
254
255        ImagesLoaded.prototype.getImages = function() {
256            this.images = [];
257
258            // filter & find items if we have an item selector
vendor: 4,463 bytes, lines 259-382
259            this.elements.forEach( this.addElementImages, this );
260        };
261
262        /**
263         * @param {Node} element
264         */
265        ImagesLoaded.prototype.addElementImages = function( elem ) {
266            // filter siblings
267            if ( elem.nodeName == 'IMG' ) {
268                this.addImage( elem );
269            }
270            // get background image on element
271            if ( this.options.background === true ) {
272                this.addElementBackgroundImages( elem );
273            }
274
275            // find children
276            // no non-element nodes, #143
277            var nodeType = elem.nodeType;
278            if ( !nodeType || !elementNodeTypes[ nodeType ] ) {
279                return;
280            }
281            var childImgs = elem.querySelectorAll('img');
282            // concat childElems to filterFound array
283            for ( var i=0; i < childImgs.length; i++ ) {
284                var img = childImgs[i];
285                this.addImage( img );
286            }
287
288            // get child background images
289            if ( typeof this.options.background == 'string' ) {
290                var children = elem.querySelectorAll( this.options.background );
291                for ( i=0; i < children.length; i++ ) {
292                    var child = children[i];
293                    this.addElementBackgroundImages( child );
294                }
295            }
296        };
297
298        var elementNodeTypes = {
299            1: true,
300            9: true,
301            11: true
302        };
303
304        ImagesLoaded.prototype.addElementBackgroundImages = function( elem ) {
305            var style = getComputedStyle( elem );
306            if ( !style ) {
307                // Firefox returns null if in a hidden iframe https://bugzil.la/548397
308                return;
309            }
310            // get url inside url("...")
311            var reURL = /url\((['"])?(.*?)\1\)/gi;
312            var matches = reURL.exec( style.backgroundImage );
313            while ( matches !== null ) {
314                var url = matches && matches[2];
315                if ( url ) {
316                    this.addBackground( url, elem );
317                }
318                matches = reURL.exec( style.backgroundImage );
319            }
320        };
321
322        /**
323         * @param {Image} img
324         */
325        ImagesLoaded.prototype.addImage = function( img ) {
326            var loadingImage = new LoadingImage( img );
327            this.images.push( loadingImage );
328        };
329
330        ImagesLoaded.prototype.addBackground = function( url, elem ) {
331            var background = new Background( url, elem );
332            this.images.push( background );
333        };
334
335        ImagesLoaded.prototype.check = function() {
336            var _this = this;
337            this.progressedCount = 0;
338            this.hasAnyBroken = false;
339            // complete if no images
340            if ( !this.images.length ) {
341                this.complete();
342                return;
343            }
344
345            function onProgress( image, elem, message ) {
346                // HACK - Chrome triggers event before object properties have changed. #83
347                setTimeout( function() {
348                    _this.progress( image, elem, message );
349                });
350            }
351
352            this.images.forEach( function( loadingImage ) {
353                loadingImage.once( 'progress', onProgress );
354                loadingImage.check();
355            });
356        };
357
358        ImagesLoaded.prototype.progress = function( image, elem, message ) {
359            this.progressedCount++;
360            this.hasAnyBroken = this.hasAnyBroken || !image.isLoaded;
361            // progress event
362            this.emitEvent( 'progress', [ this, image, elem ] );
363            if ( this.jqDeferred && this.jqDeferred.notify ) {
364                this.jqDeferred.notify( this, image );
365            }
366            // check if completed
367            if ( this.progressedCount == this.images.length ) {
368                this.complete();
369            }
370
371            if ( this.options.debug && console ) {
372                console.log( 'progress: ' + message, image, elem );
373            }
374        };
375
376        ImagesLoaded.prototype.complete = function() {
377            var eventName = this.hasAnyBroken ? 'fail' : 'done';
378            this.isComplete = true;
379            this.emitEvent( eventName, [ this ] );
380            this.emitEvent( 'always', [ this ] );
381            if ( this.jqDeferred ) {
382                var jqMethod = this.hasAnyBroken ? 'reject' : 'resolve';
vendor: 4,549 bytes, lines 383-509
383                this.jqDeferred[ jqMethod ]( this );
384            }
385        };
386
387        // --------------------------  -------------------------- //
388
389        function LoadingImage( img ) {
390            this.img = img;
391        }
392
393        LoadingImage.prototype = Object.create( EvEmitter.prototype );
394
395        LoadingImage.prototype.check = function() {
396            // If complete is true and browser supports natural sizes,
397            // try to check for image status manually.
398            var isComplete = this.getIsImageComplete();
399            if ( isComplete ) {
400                // report based on naturalWidth
401                this.confirm( this.img.naturalWidth !== 0, 'naturalWidth' );
402                return;
403            }
404
405            // If none of the checks above matched, simulate loading on detached element.
406            this.proxyImage = new Image();
407            this.proxyImage.addEventListener( 'load', this );
408            this.proxyImage.addEventListener( 'error', this );
409            // bind to image as well for Firefox. #191
410            this.img.addEventListener( 'load', this );
411            this.img.addEventListener( 'error', this );
412            this.proxyImage.src = this.img.src;
413        };
414
415        LoadingImage.prototype.getIsImageComplete = function() {
416            // check for non-zero, non-undefined naturalWidth
417            // fixes Safari+InfiniteScroll+Masonry bug infinite-scroll#671
418            return this.img.complete && this.img.naturalWidth;
419        };
420
421        LoadingImage.prototype.confirm = function( isLoaded, message ) {
422            this.isLoaded = isLoaded;
423            this.emitEvent( 'progress', [ this, this.img, message ] );
424        };
425
426        // ----- events ----- //
427
428        // trigger specified handler for event type
429        LoadingImage.prototype.handleEvent = function( event ) {
430            var method = 'on' + event.type;
431            if ( this[ method ] ) {
432                this[ method ]( event );
433            }
434        };
435
436        LoadingImage.prototype.onload = function() {
437            this.confirm( true, 'onload' );
438            this.unbindEvents();
439        };
440
441        LoadingImage.prototype.onerror = function() {
442            this.confirm( false, 'onerror' );
443            this.unbindEvents();
444        };
445
446        LoadingImage.prototype.unbindEvents = function() {
447            this.proxyImage.removeEventListener( 'load', this );
448            this.proxyImage.removeEventListener( 'error', this );
449            this.img.removeEventListener( 'load', this );
450            this.img.removeEventListener( 'error', this );
451        };
452
453        // -------------------------- Background -------------------------- //
454
455        function Background( url, element ) {
456            this.url = url;
457            this.element = element;
458            this.img = new Image();
459        }
460
461        // inherit LoadingImage prototype
462        Background.prototype = Object.create( LoadingImage.prototype );
463
464        Background.prototype.check = function() {
465            this.img.addEventListener( 'load', this );
466            this.img.addEventListener( 'error', this );
467            this.img.src = this.url;
468            // check if image is already complete
469            var isComplete = this.getIsImageComplete();
470            if ( isComplete ) {
471                this.confirm( this.img.naturalWidth !== 0, 'naturalWidth' );
472                this.unbindEvents();
473            }
474        };
475
476        Background.prototype.unbindEvents = function() {
477            this.img.removeEventListener( 'load', this );
478            this.img.removeEventListener( 'error', this );
479        };
480
481        Background.prototype.confirm = function( isLoaded, message ) {
482            this.isLoaded = isLoaded;
483            this.emitEvent( 'progress', [ this, this.element, message ] );
484        };
485
486        // -------------------------- jQuery -------------------------- //
487
488        ImagesLoaded.makeJQueryPlugin = function( jQuery ) {
489            jQuery = jQuery || window.jQuery;
490            if ( !jQuery ) {
491                return;
492            }
493            // set local variable
494            $ = jQuery;
495            // $().imagesLoaded()
496            $.fn.imagesLoaded = function( options, callback ) {
497                var instance = new ImagesLoaded( this, options, callback );
498                return instance.jqDeferred.promise( $(this) );
499            };
500        };
501        // try making plugin
502        ImagesLoaded.makeJQueryPlugin();
503
504        // --------------------------  -------------------------- //
505
506        return ImagesLoaded;
507
508    });
509
510window.Zoey.export('imagesLoaded', window.imagesLoaded);

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.