PageSourceSearch

https://machikado-gallery.com/wp-content/themes/machikado-gallery/assets/js/jquery.lazyscript.js?ver=7.0.6

js machikado-gallery.com collected 2026-09-24 10:15:29 UTC 3,981 bytes, 139 lines download raw bytes

1/*!
2 * jQuery Lazy script
3 * version: 1.0.0
4 * @requires jQuery v1.5 or later
5 * Copyright (c) 2013 Ravishanker Kusuma
6 * http://hayageek.com/
7 */
8(function ($) {
9    jQuery.cachedScript = function (url, cb) {
10        var options = {
11            dataType: "script",
12            cache: true,
13            url: url,
14            complete: function (jqXHR, textStatus) {
15                cb.call(this);
16            }
17        };
18        return jQuery.ajax(options);
19    };
20
21    $.lazyscript = function (options) {
22        // This is the easiest way to have default options.
23        var s = $.extend({
24            // These are the defaults.
25            type: false, //scroll,hover,click,visible,delay
26            id: false,
27            time: 1000,
28            partial: true,
29            scripts: [],
30            success: false
31        }, options);
32        var loaded = false;
33
34        if(s.type) {
35            switch(s.type) {
36            case 'scroll':
37                $(window).scroll(handleScroll);
38                break;
39            case 'hover':
40                $("#" + s.id).hover(handleHover);
41                break;
42            case 'click':
43                $("#" + s.id).click(handleHover);
44                break;
45            case 'visible':
46                $(window).scroll(handleVisible);
47                break;
48            case 'delay':
49                if(s.time)
50                    setTimeout(handleTimeOut, s.time);
51                break;
52            default:
53                alert("Invalid lazy script type");
54                break;
55            }
56
57        }
58
59        function removeEventHandler(elem, eventType, handler) {
60            if(elem.removeEventListener)
61                elem.removeEventListener(eventType, handler, false);
62            if(elem.detachEvent)
63                elem.detachEvent('on' + eventType, handler);
64        }
65
66        function handleTimeOut() {
67            if(!loaded) {
68                loaded = true;
69                loadScripts();
70            }
71        }
72
73        function handleHover() {
74            if(!loaded) {
75                loaded = true;
76                setTimeout(loadScripts, 5);
77                removeEventHandler($("#" + s.id).get(0), 'hover', handleHover);
78            }
79        }
80
81        function handleClick() {
82            if(!loaded) {
83                loaded = true;
84                setTimeout(loadScripts, 5);
85                removeEventHandler($("#" + s.id).get(0), 'click', handleHover);
86
87            }
88        }
89
90        function handleScroll() {
91            if(!loaded) {
92                loaded = true;
93                setTimeout(loadScripts, 5);
94                removeEventHandler(window, 'scroll', handleScroll);
95
96            }
97
98        }
99
100
101        function handleVisible() {
102            var $t = $("#" + s.id);
103            t = $t.get(0);
104            $w = $(window);
105            viewTop = $w.scrollTop();
106            viewBottom = viewTop + $w.height();
107            _top = $t.offset().top;
108            _bottom = _top + $t.height();
109            compareTop = s.partial === true ? _bottom : _top;
110            compareBottom = s.partial === true ? _top : _bottom;
111            if(!loaded) {
112                if((compareBottom <= viewBottom) && (compareTop >= viewTop)) {
113                    loaded = true;
114                    removeEventHandler(window, 'scroll', handleVisible);
115                    setTimeout(loadScripts, 5);
116                }
117            }
118        }
119
120        function loadScripts() {
121            var tCount = s.scripts.length;
122            var lCount = 0;
123            for(var i = 0; i < tCount; i++) {
124                jQuery.cachedScript(s.scripts[i], function () {
125                    lCount++;
126                });
127            }
128
129            (function checkScriptsLoaded() {
130                if(lCount == tCount) {
131                    if(s.success)
132                        s.success.call(this);
133                } else window.setTimeout(checkScriptsLoaded, 20);
134            })();
135
136        }
137
138    }
139}(jQuery));

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.