PageSourceSearch

https://www.elcorreo.com/contentfactory/post/wp-content/themes/cms…/js/jquery.appear.js?2026-10-01-05-10-27

js elcorreo.com collected 2026-10-01 09:03:43 UTC 4,300 bytes, 188 lines download raw bytes

1/*
2 * jQuery appear plugin
3 *
4 * Copyright (c) 2012 Andrey Sidorov
5 * licensed under MIT license.
6 *
7 * https://github.com/morr/jquery.appear/
8 *
9 * Version: 0.3.6
10 */
11(function ($) {
12  var selectors = [];
13
14  var check_binded = false;
15  var check_lock = false;
16  var defaults = {
17    interval: 250,
18    force_process: false
19  };
20  var $window = $(window);
21
22  var $prior_appeared = [];
23
24  function appeared(selector) {
25    return $(selector).filter(function () {
26      return $(this).is(':appeared');
27    });
28  }
29
30  function process() {
31    check_lock = false;
32    for (var index = 0, selectorsLength = selectors.length; index < selectorsLength; index++) {
33      var $appeared = appeared(selectors[index]);
34
35      $appeared.trigger('appear', [$appeared]);
36
37      if ($prior_appeared[index]) {
38        var $disappeared = $prior_appeared[index].not($appeared);
39        $disappeared.trigger('disappear', [$disappeared]);
40      }
41      $prior_appeared[index] = $appeared;
42    }
43  }
44
45  function add_selector(selector) {
46    selectors.push(selector);
47    $prior_appeared.push();
48  }
49
50  // "appeared" custom filter
51  $.expr[':'].appeared = function (element) {
52    var $element = $(element);
53    if (!$element.is(':visible')) {
54      return false;
55    }
56
57    var window_left = $window.scrollLeft();
58    var window_top = $window.scrollTop();
59    var offset = $element.offset();
60    var left = offset.left;
61    var top = offset.top;
62
63    if (top + $element.height() >= window_top &&
64      top - ($element.data('appear-top-offset') || 0) <= window_top + $window.height() &&
65      left + $element.width() >= window_left &&
66      left - ($element.data('appear-left-offset') || 0) <= window_left + $window.width()) {
67      return true;
68    } else {
69      return false;
70    }
71  };
72
73  $.fn.extend({
74    // watching for element's appearance in browser viewport
75    appear: function (options) {
76      var opts = $.extend({}, defaults, options || {});
77      var selector = this.selector || this;
78      if (!check_binded) {
79        var on_check = function () {
80          if (check_lock) {
81            return;
82          }
83          check_lock = true;
84
85          setTimeout(process, opts.interval);
86        };
87
88        $(window).scroll(on_check).resize(on_check);
89        check_binded = true;
90      }
91
92      if (opts.force_process) {
93        setTimeout(process, opts.interval);
94      }
95      add_selector(selector);
96      return $(selector);
97    }
98  });
99
100  $.extend({
101    // force elements's appearance check
102    force_appear: function () {
103      if (check_binded) {
104        process();
105        return true;
106      }
107      return false;
108    }
109  });
110})(function () {
111  if (typeof module !== 'undefined') {
112    // Node
113    return require('jquery');
114  } else {
115    return jQuery;
116  }
117}());
118
119jQuery(document).ready(function () {
120
121  let elements = [];
122  let oldElements = [];
123  let pausaFueraFoco = "";
124
125
126  $(window).bind("load", function () {
127
128    $('video').each(function (index, value) {
129
130      let autoplay = $(this).closest('.autoplay').data('autoplay');
131      if (autoplay == 'yes') {
132        elements[value.id] = 'true';
133      } else {
134        elements[value.id] = 'false';
135      }
136
137      if (index == 0) {
138        $(this).prop('muted', true);
139        elements[this.id] = 'true';
140        this.play();
141      }
142    });
143    oldElements = elements;
144
145  });
146
147  $('video').appear();
148
149  $(document.body).on('appear', 'video.vjs-tech', function (e, $affected) {
150    //console.log(elements);
151    $affected.each(function () {
152      pausaFueraFoco = "";
153      this.onplay = function () {
154        for (key in elements) {
155          if (this.id == key)
156            elements[this.id] = 'true';
157        }
158      };
159
160      this.onpause = function () {
161        if (pausaFueraFoco == "fuera") {
162          if (oldElements[this.id] == elements[this.id]) {
163            elements[this.id] = oldElements[this.id];
164          } else {
165            elements[this.id] = 'false';
166          }
167        } else {
168          elements[this.id] = 'false';
169        }
170      }
171
172      if (elements[this.id] == 'true') {
173        this.play();
174      }
175
176    })
177  });
178
179  $(document.body).on('disappear', 'video', function (e, $affected) {
180    $affected.each(function () {
181      oldElements = elements;
182      pausaFueraFoco = 'fuera';
183      this.pause();
184    })
185  });
186
187
188});

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.