PageSourceSearch

https://piehtoolco.com/shared_files/echo.js?lmd=45191.927963

js piehtoolco.com collected 2026-10-02 23:03:47 UTC 4,217 bytes, 139 lines download raw bytes

1/*! echo-js v1.7.3 | (c) 2016 @toddmotto | https://github.com/toddmotto/echo */
2(function (root, factory) {
3if (typeof define === 'function' && define.amd) {
4define(function() {
5return factory(root);
6});
7} else if (typeof exports === 'object') {
8module.exports = factory;
9} else {
10root.echo = factory(root);
11}
12})(this, function (root) {
13'use strict';
14var echo = {};
15var callback = function () {};
16var offset, poll, delay, useDebounce, unload;
17var getClientRect = function(el) {
18var rect = el.getBoundingClientRect();
19if (rect.left == 0 && rect.right == 0 && rect.top == 0 && rect.bottom == 0) {
20if (el.parentNode) rect = el.parentNode.getBoundingClientRect();
21}
22return rect;
23}
24var isHidden = function (el, rect) {
25function getComputedStyle(el, prop){
26if (el.currentStyle) return el.currentStyle[prop];
27else return tf.content.document.defaultView.getComputedStyle(el, '')[prop];
28}
29while (el && el.nodeType === 1) {
30if (getComputedStyle(el, 'display') == 'none' || getComputedStyle(el, 'visibility') == 'hidden') {
31return true;
32}
33el = el.parentNode;
34if (el.offsetWidth <= 0 && el.offsetHeight <= 0 && !el.getClientRects().length) return true;
35}
36return false;
37};
38var inView = function (element, view) {
39if (tf.jQuery && $(element).parents('.Index1,.Index2').length > 0 && isHidden(element, box)) {
40return false;
41}
42var box = getClientRect(element);
43return (box.right >= view.l && box.bottom >= view.t && box.left <= view.r && box.top <= view.b);
44};
45var debounceOrThrottle = function () {
46if(!useDebounce && !!poll) {
47return;
48}
49clearTimeout(poll);
50poll = setTimeout(function(){
51echo.render();
52poll = null;
53}, delay);
54};
55echo.init = function (opts) {
56opts = opts || {};
57var offsetAll = opts.offset || 0;
58var offsetVertical = opts.offsetVertical || offsetAll;
59var offsetHorizontal = opts.offsetHorizontal || offsetAll;
60var optionToInt = function (opt, fallback) {
61return parseInt(opt || fallback, 10);
62};
63offset = {
64t: optionToInt(opts.offsetTop, offsetVertical),
65b: optionToInt(opts.offsetBottom, offsetVertical),
66l: optionToInt(opts.offsetLeft, offsetHorizontal),
67r: optionToInt(opts.offsetRight, offsetHorizontal)
68};
69delay = optionToInt(opts.throttle, 250);
70useDebounce = opts.debounce !== false;
71unload = !!opts.unload;
72callback = opts.callback || callback;
73setTimeout(echo.render, 20);
74if (document.addEventListener) {
75root.addEventListener('load', debounceOrThrottle, false);
76root.addEventListener('scroll', debounceOrThrottle, false);
77if (document.body) document.body.addEventListener('scroll', debounceOrThrottle, false);
78} else {
79root.attachEvent('onload', debounceOrThrottle);
80root.attachEvent('onscroll', debounceOrThrottle);
81if (document.body) document.body.attachEvent('onscroll', debounceOrThrottle);
82}
83};
84echo.render = function () {
85var nodes = document.querySelectorAll('img[data-echo], [data-echo-background]');
86var length = nodes.length;
87if (!length) return;
88var src, elem;
89var view = {
90l: 0 - offset.l,
91t: 0 - offset.t,
92b: (root.innerHeight || document.documentElement.clientHeight) + offset.b,
93r: (root.innerWidth || document.documentElement.clientWidth) + offset.r
94};
95for (var i = 0; i < length; i++) {
96elem = nodes[i];
97if (inView(elem, view)) {
98if (unload) {
99elem.setAttribute('data-echo-placeholder', elem.src);
100}
101if (elem.getAttribute('data-echo-background') !== null) {
102elem.style.backgroundImage = "url(" + elem.getAttribute('data-echo-background') + ")";
103}
104else {
105elem.src = elem.getAttribute('data-echo');
106}
107if (!unload) {
108elem.removeAttribute('data-echo');
109elem.removeAttribute('data-echo-background');
110}
111callback(elem, 'load');
112}
113else if (unload && !!(src = elem.getAttribute('data-echo-placeholder'))) {
114if (elem.getAttribute('data-echo-background') !== null) {
115elem.style.backgroundImage = "url(" + src + ")";
116}
117else {
118elem.src = src;
119}
120elem.removeAttribute('data-echo-placeholder');
121callback(elem, 'unload');
122}
123}
124/*if (!length) {
125echo.detach();
126}*/
127};
128echo.detach = function () {
129if (document.removeEventListener) {
130root.removeEventListener('scroll', debounceOrThrottle);
131} else {
132root.detachEvent('onscroll', debounceOrThrottle);
133}
134clearTimeout(poll);
135};
136return echo;
137});
138// $Revision: 40062 $
139// $HeadURL: svn://3d3-p432/ShopFactory/branches/V14_60/bin/SFXTemplates/shared_files/echo.js $

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.