PageSourceSearch

https://www.tagapplication.it/wp-content/themes/pathsoft/assets/libs/flickity/bg-lazyload.js?ver=1758897433

js tagapplication.it collected 2026-10-02 01:59:18 UTC 3,320 bytes, 119 lines download raw bytes

1/**
2 * Flickity background lazyload v1.0.1
3 * lazyload background cell images
4 */
5
6/*jshint browser: true, unused: true, undef: true */
7
8( function( window, factory ) {
9    // universal module definition
10    /*globals define, module, require */
11    if ( typeof define == 'function' && define.amd ) {
12      // AMD
13      define( [
14        'flickity/js/index',
15        'fizzy-ui-utils/utils'
16      ], factory );
17    } else if ( typeof module == 'object' && module.exports ) {
18      // CommonJS
19      module.exports = factory(
20        require('flickity'),
21        require('fizzy-ui-utils')
22      );
23    } else {
24      // browser global
25      factory(
26        window.Flickity,
27        window.fizzyUIUtils
28      );
29    }
30  
31  }( window, function factory( Flickity, utils ) {
32  /*jshint strict: true */
33  'use strict';
34  
35  Flickity.createMethods.push('_createBgLazyLoad');
36  
37  var proto = Flickity.prototype;
38  
39  proto._createBgLazyLoad = function() {
40    this.on( 'select', this.bgLazyLoad );
41  };
42  
43  proto.bgLazyLoad = function() {
44    var lazyLoad = this.options.bgLazyLoad;
45    if ( !lazyLoad ) {
46      return;
47    }
48  
49    // get adjacent cells, use lazyLoad option for adjacent count
50    var adjCount = typeof lazyLoad == 'number' ? lazyLoad : 0;
51    var cellElems = this.getAdjacentCellElements( adjCount );
52  
53    for ( var i=0; i < cellElems.length; i++ ) {
54      var cellElem = cellElems[i];
55      this.bgLazyLoadElem( cellElem );
56      // select lazy elems in cell
57      var children = cellElem.querySelectorAll('[data-flickity-bg-lazyload]');
58      for ( var j=0; j < children.length; j++ ) {
59        this.bgLazyLoadElem( children[j] );
60      }
61    }
62  };
63  
64  proto.bgLazyLoadElem = function( elem ) {
65    var attr = elem.getAttribute('data-flickity-bg-lazyload');
66    if ( attr ) {
67      new BgLazyLoader( elem, attr, this );
68    }
69  };
70  
71  // -------------------------- LazyBGLoader -------------------------- //
72  
73  /**
74   * class to handle loading images
75   */
76  function BgLazyLoader( elem, url, flickity ) {
77    this.element = elem;
78    this.url = url;
79    this.img = new Image();
80    this.flickity = flickity;
81    this.load();
82  }
83  
84  BgLazyLoader.prototype.handleEvent = utils.handleEvent;
85  
86  BgLazyLoader.prototype.load = function() {
87    this.img.addEventListener( 'load', this );
88    this.img.addEventListener( 'error', this );
89    // load image
90    this.img.src = this.url;
91    // remove attr
92    this.element.removeAttribute('data-flickity-bg-lazyload');
93  };
94  
95  BgLazyLoader.prototype.onload = function( event ) {
96    this.element.style.backgroundImage = 'url("' + this.url + '")';
97    this.complete( event, 'flickity-bg-lazyloaded' );
98  };
99  
100  BgLazyLoader.prototype.onerror = function( event ) {
101    this.complete( event, 'flickity-bg-lazyerror' );
102  };
103  
104  BgLazyLoader.prototype.complete = function( event, className ) {
105    // unbind events
106    this.img.removeEventListener( 'load', this );
107    this.img.removeEventListener( 'error', this );
108  
109    this.element.classList.add( className );
110    this.flickity.dispatchEvent( 'bgLazyLoad', event, this.element );
111  };
112  
113  // -----  ----- //
114  
115  Flickity.BgLazyLoader = BgLazyLoader;
116  
117  return Flickity;
118  
119  }));

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.