PageSourceSearch

https://moda.ru/wp-content/themes/venosa/js/jquery.lazyload.min.js

js moda.ru collected 2026-10-02 07:55:03 UTC 11,707 bytes, 365 lines download raw bytes

1/*!
2 * Lazy Load - jQuery plugin for lazy loading images
3 *
4 * Copyright (c) 2007-2015 Mika Tuupola
5 *
6 * Licensed under the MIT license:
7 *   http://www.opensource.org/licenses/mit-license.php
8 *
9 * Project home:
10 *   http://www.appelsiini.net/projects/lazyload
11 *
12 * Version:  1.9.7
13 *
14 */
15
16(function($, window, document, undefined) {
17    var $window = $(window);
18
19    $.fn.lazyload = function(options) {
20        var elements = this;
21        var $container;
22        var settings = {
23            threshold       : 0,
24            failure_limit   : 0,
25            ignore          : 0,
26            event           : "scroll",
27            effect          : "show",
28            container       : window,
29            data_attribute  : "original",
30            data_set        : "original-set",
31            skip_invisible  : false,
32            appear          : null,
33            load            : null,
34            // placeholder     : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC",
35            placeholder: '',
36            beforeLoad: function(el) {},
37            afterLoad: function(el) {},
38        };
39
40        function update(){
41            var counter = 0;
42
43            elements.each(function() {
44
45                var $this = $(this);
46
47                if ( settings.skip_invisible && ( !$this.is(":in-viewport") || !$this.is(":visible") ) ) {
48                    return;
49                }
50
51                if ( $.abovethetop( this, settings ) ||
52                     $.leftofbegin( this, settings ) ) {
53
54                        /* Nothing. */
55
56                } else if ( !$.belowthefold( this, settings ) &&
57                    !$.rightoffold( this, settings ) ) {
58
59                        $this.trigger("appear");
60                        /* if we found an image we'll load, reset the counter */
61                        counter = 0;
62
63                } else {
64
65                    if ( ++counter > settings.failure_limit ) {
66                        return false;
67                    }
68
69                }
70            });
71
72        }
73
74        if(options) {
75            /* Maintain BC for a couple of versions. */
76            if (undefined !== options.failurelimit) {
77                options.failure_limit = options.failurelimit;
78                delete options.failurelimit;
79            }
80            if (undefined !== options.effectspeed) {
81                options.effect_speed = options.effectspeed;
82                delete options.effectspeed;
83            }
84
85            $.extend(settings, options);
86        }
87
88        /* Cache container as jQuery as object. */
89        $container = (settings.container === undefined ||
90                      settings.container === window) ? $window : $(settings.container);
91
92        /* Fire one scroll event per scroll. Not one scroll event per image. */
93        if (0 === settings.event.indexOf("scroll")) {
94            $container.on(settings.event, function() {
95                return update();
96            });
97        }
98
99        this.each(function() {
100            var self = this;
101            var $self = $(self);
102
103            self.loaded = false;
104
105            /* If no src attribute given use data:uri. */
106            if ($self.attr("src") === undefined || $self.attr("src") === false) {
107                if ($self.is("img")) {
108                    $self.attr("src", settings.placeholder);
109                }
110            }
111
112            if ( settings.ignore.length && settings.ignore.has($self).length ) {
113                return;
114            }
115
116            /* When appear is triggered load original image. */
117            $self.one("appear", function() {
118
119                if ( !this.loaded ) {
120
121                    if( typeof settings.beforeLoad == 'function' ) {
122
123                        settings.beforeLoad(this);
124
125                    }
126
127                    if ( settings.appear ) {
128
129                        var elements_left = elements.length;
130                        settings.appear.call( self, elements_left, settings );
131
132                    }
133                    
134                    $("<img />")
135                        .one("load", function() {
136
137                            var original = $self.attr("data-" + settings.data_attribute),
138                                originalSet = $self.attr("data-" + settings.data_set);
139
140                            $self.hide();
141
142                            if ( $self.is("img") ) {
143
144                                $self.attr("src", original).addClass('lazyloaded');
145
146                                if( $self.has('[srcset]') ) {
147                                    $self.attr("srcset", originalSet);
148                                }
149
150                            } else {
151
152                                $self.css("background-image", "url('" + original + "')").addClass('lazyloaded');
153
154                            }
155
156                            $self[ settings.effect ]( settings.effect_speed );
157
158                            self.loaded = true;
159
160                            /* Remove image from array so it is not looped next time. */
161                            var temp = $.grep( elements, function(element) {
162                                return !element.loaded;
163                            });
164
165                            elements = $( temp );
166
167                            if ( settings.load ) {
168
169                                var elements_left = elements.length;
170                                settings.load.call( self, elements_left, settings );
171
172                            }
173
174                            /*
175                             * Re-init, re-calc, reload, re-- everything that must bre reloaded after image was loaded, below.
176                             */
177
178                            if ( $self.closest(AIRKIT_EL.gallery.selector).length ) {
179                                AIRKIT_EL.gallery._lazyFix();
180                            }
181
182                            if ( $self.closest(AIRKIT_EL.greaseSlider.selector).length ) {
183                                AIRKIT_EL.greaseSlider._lazyFix();
184                            }
185
186                            if ( $self.closest(AIRKIT.equalHeightColumns.selector).length ) {
187                                setTimeout(function(){
188                                    AIRKIT.equalHeightColumns.init();
189                                }, 1000);
190                            }
191
192                            /*
193                             * Recalculate isotope.
194                             */
195
196                            if( $self.closest('.ts-masonry-container').length ) {
197                                
198                                $self.closest('.ts-masonry-container').isotope('layout');
199                                
200                            }
201
202
203                        })
204                        .attr( "src", $self.attr( "data-" + settings.data_attribute ) )
205                        .attr( "srcset", $self.attr( "data-" + settings.data_set ) );
206
207                    if( typeof settings.afterLoad == 'function' ) {
208
209                        settings.afterLoad(this);
210
211                    }
212                        
213                }
214            });
215
216            /* When wanted event is triggered load original image */
217            /* by triggering appear.                              */
218            if (0 !== settings.event.indexOf("scroll")) {
219
220                $self.on( settings.event, function() {
221
222                    if ( !self.loaded ) {
223
224                        $self.trigger("appear");
225
226                    }
227
228                });
229
230            }
231
232            jQuery(document).ready(function(){
233
234                if( $.inviewport( $self, settings ) == true ) {
235
236                    if(!self.loaded){ 
237
238                        $self.trigger("appear");
239
240                    }
241                }
242
243            })
244        });
245
246        /* Check if something appears when window is resized. */
247        $window.on("resize", function() {
248            update();
249        });
250
251        /* With IOS5 force loading images when navigating with back button. */
252        /* Non optimal workaround. */
253        if ((/(?:iphone|ipod|ipad).*os 5/gi).test(navigator.appVersion)) {
254            $window.on("pageshow", function(event) {
255                if (event.originalEvent && event.originalEvent.persisted) {
256                    elements.each(function() {
257                        $(this).trigger("appear");
258                    });
259                }
260            });
261        }
262
263        /* Force initial check if images should appear. */
264        $(document).ready(function() {
265            update();
266        });
267        return this;
268    };
269
270    /* Convenience methods in jQuery namespace.           */
271    /* Use as  $.belowthefold(element, {threshold : 100, container : window}) */
272
273
274    $.belowthefold = function(element, settings) {
275
276        var fold;
277
278        if (settings.container === undefined || settings.container === window) {
279
280            fold = (window.innerHeight ? window.innerHeight : $window.height()) + $window.scrollTop();
281
282        } else {
283
284            fold = $(settings.container).offset().top + $(settings.container).height();
285
286        }
287
288        return fold <= $(element).offset().top - settings.threshold;
289    };
290
291    $.rightoffold = function(element, settings) {
292
293        var fold;
294
295        if (settings.container === undefined || settings.container === window) {
296
297            fold = $window.width() + $window.scrollLeft();
298
299        } else {
300
301            fold = $(settings.container).offset().left + $(settings.container).width();
302
303        }
304
305        return fold <= $(element).offset().left - settings.threshold;
306    };
307
308    $.abovethetop = function(element, settings) {
309
310        var fold;
311
312        if (settings.container === undefined || settings.container === window) {
313
314            fold = $window.scrollTop();
315
316        } else {
317
318            fold = $(settings.container).offset().top;
319
320        }
321
322        return fold >= $(element).offset().top + settings.threshold  + $(element).height();
323    };
324
325    $.leftofbegin = function(element, settings) {
326
327        var fold;
328
329        if (settings.container === undefined || settings.container === window) {
330
331            fold = $window.scrollLeft();
332
333        } else {
334
335            fold = $(settings.container).offset().left;
336
337        }
338
339        return fold >= $(element).offset().left + settings.threshold + $(element).width();
340    };
341
342    $.inviewport = function(element, settings) {
343
344         return !$.rightoffold(element, settings) && !$.leftofbegin(element, settings) &&
345                !$.belowthefold(element, settings) && !$.abovethetop(element, settings);
346
347     };
348
349    /* Custom selectors for your convenience.   */
350    /* Use as $("img:below-the-fold").something() or */
351    /* $("img").filter(":below-the-fold").something() which is faster */
352
353    $.extend($.expr[":"], {
354        "below-the-fold" : function(a) { return $.belowthefold(a, {threshold : 0}); },
355        "above-the-top"  : function(a) { return !$.belowthefold(a, {threshold : 0}); },
356        "right-of-screen": function(a) { return $.rightoffold(a, {threshold : 0}); },
357        "left-of-screen" : function(a) { return !$.rightoffold(a, {threshold : 0}); },
358        "in-viewport"    : function(a) { return $.inviewport(a, {threshold : 0}); },
359        /* Maintain BC for couple of versions. */
360        "above-the-fold" : function(a) { return !$.belowthefold(a, {threshold : 0}); },
361        "right-of-fold"  : function(a) { return $.rightoffold(a, {threshold : 0}); },
362        "left-of-fold"   : function(a) { return !$.rightoffold(a, {threshold : 0}); },
363    });
364
365})(jQuery, window, document);

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.