PageSourceSearch

https://bcd.bzh/becedia/sites/all/modules/lazyloader/lazyloader.js?titv3j

js bcd.bzh collected 2026-10-02 07:41:16 UTC 2,310 bytes, 77 lines download raw bytes

1/**
2 * @file
3 * Lazyloader echo integration.
4 */
5
6(function($){
7  // Cache the icon and it's dimensions.
8  var lazyloader_icon;
9
10  Drupal.behaviors.lazyloader = {
11    attach: function (context, settings) {
12      if (lazyloader_icon == undefined) {
13        lazyloader_icon = new Image();
14
15        $(lazyloader_icon).attr({src: settings.lazyloader.icon}).addClass('lazyloader-icon');
16      }
17
18      // add the loader icon
19      if(settings.lazyloader.icon != '') {
20        $('img[data-echo]').each(function() {
21          var $img = $(this);
22          var $icon = $(lazyloader_icon).clone();
23          $icon.css({
24            position: 'relative',
25            top: '-' + Math.floor($img.height() / 2 - settings.lazyloader.offsetY) + 'px',
26            left: '-'+ Math.floor($img.width() / 2 + settings.lazyloader.offsetX) + 'px',
27          });
28          $($icon).insertAfter($img);
29        });
30      }
31
32      // Initialize echo.
33      echo.init({
34        offset: settings.lazyloader.offset,
35        throttle: settings.lazyloader.throttle,
36        unload: settings.lazyloader.unload,
37        debounce: settings.lazyloader.debounce,
38        callback: function (element, op) {
39          // Remove the loader icon when the image is loaded.
40          $(element).next('.lazyloader-icon').remove();
41        }
42      });
43
44      // Add a scroll eventlistener to every parent element with overflow:scroll; so we can trigger echo when the
45      // element is scrolled.
46      $('img[data-echo], [data-echo-background]').each(function() {
47        $(this).parents().each(function() {
48          if ($(this).css('overflow') == 'scroll') {
49            $(this).bind('scroll', function() {
50              lazyloaderDebounceOrThrottle(settings.lazyloader.debounce, settings.lazyloader.throttle)
51            });
52          }
53        });
54      });
55    },
56
57    detach: function (context, settings) {
58      // Detach echo.
59      echo.detach();
60    },
61
62    // Variable for throttling.
63    poll: null
64  };
65
66})(jQuery);
67
68function lazyloaderDebounceOrThrottle(debounce, throttle) {
69  if(!debounce && !!Drupal.behaviors.lazyloader.poll) {
70    return;
71  }
72  clearTimeout(Drupal.behaviors.lazyloader.poll);
73  Drupal.behaviors.lazyloader.poll = setTimeout(function(){
74    echo.render();
75    Drupal.behaviors.lazyloader.poll = null;
76  }, throttle);
77}

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.