PageSourceSearch

https://wifaqulmadaris.org/assets/plugins/jquery.appear.js

js wifaqulmadaris.org collected 2026-10-02 13:53:39 UTC 4,368 bytes, 136 lines download raw bytes

vendor: 4,368 bytes, lines 1-136
1/*
2 * jQuery.appear
3 * https://github.com/bas2k/jquery.appear/
4 * http://code.google.com/p/jquery-appear/
5 *
6 * Copyright (c) 2009 Michael Hixson
7 * Copyright (c) 2012 Alexander Brovikov
8 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
9 */
10(function ($) {
11    $.fn.appear = function (fn, options) {
12        var settings = $.extend({
13            //arbitrary data to pass to fn
14            data: undefined,
15
16            //call fn only on the first appear?
17            one: true,
18
19            // X & Y accuracy
20            accX: 0,
21            accY: 0
22        }, options);
23
24        return this.each(function () {
25            var t = $(this);
26
27            //whether the element is currently visible
28            t.appeared = false;
29
30            if (!fn) {
31                //trigger the custom event
32                t.trigger('appear', settings.data);
33                return;
34            }
35
36            var w = $(window);
37
38            //fires the appear event when appropriate
39            var check = function () {
40                //is the element hidden?
41                if (!t.is(':visible')) {
42                    //it became hidden
43                    t.appeared = false;
44                    return;
45                }
46
47                //is the element inside the visible window?
48                var a = w.scrollLeft();
49                var b = w.scrollTop();
50                var o = t.offset();
51                var x = o.left;
52                var y = o.top;
53
54                var ax = settings.accX;
55                var ay = settings.accY;
56                var th = t.height();
57                var wh = w.height();
58                var tw = t.width();
59                var ww = w.width();
60
61                if (y + th + ay >= b &&
62                    y <= b + wh + ay &&
63                    x + tw + ax >= a &&
64                    x <= a + ww + ax) {
65                    //trigger the custom event
66                    if (!t.appeared) t.trigger('appear', settings.data);
67                } else {
68                    //it scrolled out of view
69                    t.appeared = false;
70                }
71            };
72
73            //create a modified fn with some additional logic
74            var modifiedFn = function () {
75                //mark the element as visible
76                t.appeared = true;
77
78                //is this supposed to happen only once?
79                if (settings.one) {
80                    //remove the check
81                    w.unbind('scroll', check);
82                    var i = $.inArray(check, $.fn.appear.checks);
83                    if (i >= 0) $.fn.appear.checks.splice(i, 1);
84                }
85
86                //trigger the original fn
87                fn.apply(this, arguments);
88            };
89
90            //bind the modified fn to the element
91            if (settings.one) t.one('appear', settings.data, modifiedFn);
92            else t.bind('appear', settings.data, modifiedFn);
93
94            //check whenever the window scrolls
95            w.scroll(check);
96
97            //check whenever the dom changes
98            $.fn.appear.checks.push(check);
99
100            //check now
101            (check)();
102        });
103    };
104
105    //keep a queue of appearance checks
106    $.extend($.fn.appear, {
107        checks: [],
108        timeout: null,
109
110        //process the queue
111        checkAll: function () {
112            var length = $.fn.appear.checks.length;
113            if (length > 0) while (length--) ($.fn.appear.checks[length])();
114        },
115
116        //check the queue asynchronously
117        run: function () {
118            if ($.fn.appear.timeout) clearTimeout($.fn.appear.timeout);
119            $.fn.appear.timeout = setTimeout($.fn.appear.checkAll, 20);
120        }
121    });
122
123    //run checks when these methods are called
124    $.each(['append', 'prepend', 'after', 'before', 'attr',
125        'removeAttr', 'addClass', 'removeClass', 'toggleClass',
126        'remove', 'css', 'show', 'hide'], function (i, n) {
127            var old = $.fn[n];
128            if (old) {
129                $.fn[n] = function () {
130                    var r = old.apply(this, arguments);
131                    $.fn.appear.run();
132                    return r;
133                }
134            }
135        });
136})(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.