PageSourceSearch

https://www.carltonsc.com/themes/default/scripts/twitter_embed.jquery.js?R119

js carltonsc.com collected 2026-10-04 21:36:35 UTC 8,165 bytes, 225 lines download raw bytes

1/*!
2 * Lazy Load - jQuery plugin for lazy loading images
3 *
4 * Copyright (c) 2007-2015 Mika Tuupola
5 *
6 * Licensed under the MIT license:
7 *   http://www.opensource.org/licenses/mit-license.php
8 *
9 * Project home:
10 *   http://www.appelsiini.net/projects/lazyload
11 *
12 * Version:  1.9.7
13 *
14 */
15
16(function($, window, document, undefined) {
17    var $window = $(window);
18
19    $.fn.lazyload = function(options) {
20        var elements = this;
21        var $container;
22        var settings = {
23            threshold       : 0,
24            failure_limit   : 0,
25            event           : "scroll",
26            effect          : "show",
27            container       : window,
28            data_attribute  : "original",
29            skip_invisible  : false,
30            appear          : null,
31            load            : null,
32            placeholder     : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC"
33        };
34
35        function update() {
36            var counter = 0;
37
38            elements.each(function() {
39                var $this = $(this);
40                if (settings.skip_invisible && !$this.is(":visible")) {
41                    return;
42                }
43                if ($.abovethetop(this, settings) ||
44                    $.leftofbegin(this, settings)) {
45                        /* Nothing. */
46                } else if (!$.belowthefold(this, settings) &&
47                    !$.rightoffold(this, settings)) {
48                        $this.trigger("appear");
49                        /* if we found an image we'll load, reset the counter */
50                        counter = 0;
51                } else {
52                    if (++counter > settings.failure_limit) {
53                        return false;
54                    }
55                }
56            });
57
58        }
59
60        if(options) {
61            /* Maintain BC for a couple of versions. */
62            if (undefined !== options.failurelimit) {
63                options.failure_limit = options.failurelimit;
64                delete options.failurelimit;
65            }
66            if (undefined !== options.effectspeed) {
67                options.effect_speed = options.effectspeed;
68                delete options.effectspeed;
69            }
70
71            $.extend(settings, options);
72        }
73
74        /* Cache container as jQuery as object. */
75        $container = (settings.container === undefined ||
76                      settings.container === window) ? $window : $(settings.container);
77
78        /* Fire one scroll event per scroll. Not one scroll event per image. */
79        if (0 === settings.event.indexOf("scroll")) {
80            $container.on(settings.event, function() {
81                return update();
82            });
83        }
84
85        this.each(function() {
86            var self = this;
87            var $self = $(self);
88
89            self.loaded = false;
90
91            /* If no src attribute given use data:uri. */
92            if ($self.attr("href") === undefined || $self.attr("href") === false) {
93                if ($self.is("a")) {
94//                     $self.attr("src", settings.placeholder);
95                }
96            }
97
98            /* When appear is triggered load original image. */
99            $self.one("appear", function() {
100                if (!this.loaded) {
101                    if (settings.appear) {
102                        var elements_left = elements.length;
103                        settings.appear.call(self, elements_left, settings);
104                    }
105
106                    $.ajax({
107                      type:     "GET",
108                      url:      'https://publish.twitter.com/oembed?url=' + encodeURIComponent($self.attr('href')),
109                      dataType: "jsonp",
110                      success: function(data){
111                        $self.html(data.html);
112                      }
113                    });
114                }
115            });
116
117            /* When wanted event is triggered load original image */
118            /* by triggering appear.                              */
119            if (0 !== settings.event.indexOf("scroll")) {
120                $self.on(settings.event, function() {
121                    if (!self.loaded) {
122                        $self.trigger("appear");
123                    }
124                });
125            }
126        });
127
128        /* Check if something appears when window is resized. */
129        $window.on("resize", function() {
130            update();
131        });
132
133        /* With IOS5 force loading images when navigating with back button. */
134        /* Non optimal workaround. */
135        if ((/(?:iphone|ipod|ipad).*os 5/gi).test(navigator.appVersion)) {
136            $window.on
vendor: 3,404 bytes, lines 136-225
136("pageshow", function(event) {
137                if (event.originalEvent && event.originalEvent.persisted) {
138                    elements.each(function() {
139                        $(this).trigger("appear");
140                    });
141                }
142            });
143        }
144
145        /* Force initial check if images should appear. */
146        $(document).ready(function() {
147            update();
148        });
149
150        return this;
151    };
152
153    /* Convenience methods in jQuery namespace.           */
154    /* Use as  $.belowthefold(element, {threshold : 100, container : window}) */
155
156    $.belowthefold = function(element, settings) {
157        var fold;
158
159        if (settings.container === undefined || settings.container === window) {
160            fold = (window.innerHeight ? window.innerHeight : $window.height()) + $window.scrollTop();
161        } else {
162            fold = $(settings.container).offset().top + $(settings.container).height();
163        }
164
165        return fold <= $(element).offset().top - settings.threshold;
166    };
167
168    $.rightoffold = function(element, settings) {
169        var fold;
170
171        if (settings.container === undefined || settings.container === window) {
172            fold = $window.width() + $window.scrollLeft();
173        } else {
174            fold = $(settings.container).offset().left + $(settings.container).width();
175        }
176
177        return fold <= $(element).offset().left - settings.threshold;
178    };
179
180    $.abovethetop = function(element, settings) {
181        var fold;
182
183        if (settings.container === undefined || settings.container === window) {
184            fold = $window.scrollTop();
185        } else {
186            fold = $(settings.container).offset().top;
187        }
188
189        return fold >= $(element).offset().top + settings.threshold  + $(element).height();
190    };
191
192    $.leftofbegin = function(element, settings) {
193        var fold;
194
195        if (settings.container === undefined || settings.container === window) {
196            fold = $window.scrollLeft();
197        } else {
198            fold = $(settings.container).offset().left;
199        }
200
201        return fold >= $(element).offset().left + settings.threshold + $(element).width();
202    };
203
204    $.inviewport = function(element, settings) {
205         return !$.rightoffold(element, settings) && !$.leftofbegin(element, settings) &&
206                !$.belowthefold(element, settings) && !$.abovethetop(element, settings);
207     };
208
209    /* Custom selectors for your convenience.   */
210    /* Use as $("img:below-the-fold").something() or */
211    /* $("img").filter(":below-the-fold").something() which is faster */
212
213    $.extend($.expr[":"], {
214        "below-the-fold" : function(a) { return $.belowthefold(a, {threshold : 0}); },
215        "above-the-top"  : function(a) { return !$.belowthefold(a, {threshold : 0}); },
216        "right-of-screen": function(a) { return $.rightoffold(a, {threshold : 0}); },
217        "left-of-screen" : function(a) { return !$.rightoffold(a, {threshold : 0}); },
218        "in-viewport"    : function(a) { return $.inviewport(a, {threshold : 0}); },
219        /* Maintain BC for couple of versions. */
220        "above-the-fold" : function(a) { return !$.belowthefold(a, {threshold : 0}); },
221        "right-of-fold"  : function(a) { return $.rightoffold(a, {threshold : 0}); },
222        "left-of-fold"   : function(a) { return !$.rightoffold(a, {threshold : 0}); }
223    });
224
225})(jQuery, window, document);

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.