PageSourceSearch

https://www.aladin.co.kr/js/jquery.lazyload.js

js aladin.co.kr collected 2026-09-24 08:28:27 UTC 8,659 bytes, 218 lines download raw bytes

1/*
2 * Lazy Load - jQuery plugin for lazy loading images
3 * Copyright (c) 2007-2009 Mika Tuupola
4 * Licensed under the MIT license:
5 *   http://www.opensource.org/licenses/mit-license.php
6 * Project home:
7 *   http://www.appelsiini.net/projects/lazyload
8 * Version:  1.5.0
9 */
10 
11(function($) {
12    $.fn.loadContent = function(type, options) {
13        var settings = {
14            bannerType   : 0,
15            branchType   : 1,
16            infoType     : 0,
17            isLazyload   : true,
18            threshold    : 400,
19            failurelimit : 0,
20            event        : "scroll",
21            effect       : "show",
22            container    : window,
23            complete     : false,
24            replaceElement: true,
25            isHashLink: false,         /* hash 태그 달고 온 경우 해당 컨텐츠 영역으로 바로가기 */
26            cid: 0,
27            itemType: 0,
28            isLine: 0
29         
30        };
31        if (options) { $.extend(settings, options); }
32
33        var goHashLink = function (obj)
34        {
35            //console.log('goHashLink');
36            //console.log($(obj).attr('id'));
37            //console.log('location.hash:' + location.hash);
38            var hash = location.hash;
39            if (hash ==null || hash.length == 0)
40                return;
41
42            if ($(obj).length == 0)
43                return;
44
45            var id = $(obj).attr('id');
46            if (location.hash == "#" + id) {
47                setTimeout(function () {
48                    if ($("#" + id).length > 0)
49                    {
50                        var top = $("#" + id).offset().top;
51                        if (top > 0) {
52                            //top = top - 100;
53                            window.scrollTo(0, top);
54                            //console.log("scrollTo: " + top);
55                        }
56                    }
57                }, 500);
58            }
59        }
60        
61        var elements = this;
62
63        //console.log($(elements).attr('id'));
64
65        if ("scroll" == settings.event) {
66            $(settings.container).bind("scroll", function(event) {
67                var counter = 0;
68                elements.each(function() {
69                    if ($.abovethetop(this, settings) || $.leftofbegin(this, settings)) {
70                    } else if (!$.belowthefold(this, settings) && !$.rightoffold(this, settings)) {
71                        $(this).trigger("appear");
72                    } else {
73                        if (counter++ > settings.failurelimit) {
74                            return false;
75                        }
76                    }
77                });
78                var temp = $.grep(elements, function(element) {
79                    return !element.loaded;
80                });
81                elements = $(temp);
82            });
83        }
84        this.each(function() {
85            var self = this;
86            if ("scroll" != settings.event ||  undefined == $(self).attr("src") ||  settings.placeholder == $(self).attr("src") || ($.abovethetop(self, settings) || $.leftofbegin(self, settings) || $.belowthefold(self, settings) || $.rightoffold(self, settings) )) {
87                self.loaded = false;
88            } else {
89                self.loaded = true;
90            }
91            $(self).one("appear", function() {
92                if (!this.loaded)
93                {
94                    var splitArray = $(self).attr("id").split("_");
95                    if(splitArray.length < 1) return;
96                    
97                    var isbn = splitArray[0];
98                    var name = splitArray[1];
99                    
100                    if ( typeof (type) != "number" ) {
101                        type = 0;
102                    }
103                    var url;
104                    if(type == 2) {
105                        url = "/shop/product/getBanner.aspx?BranchType="+settings.branchType+"&BannerType="+settings.bannerType;
106                    }
107                    else if(type == 3) {
108                        url = "/ucl/main/usedshop/getUsedContents.aspx?name=" + $( self ).attr( "id" );
109                    }
110                    else if ( type == 4 ) {
111                        url = "/ucl/main/ebook/ebookMainLazyLoad.aspx?name=" + $( self ).attr( "id" );
112                    }
113                    else if (type == 5) {
114                        url = "/shop/usedshop/offAjax.aspx?name=" + $(self).attr("id");
115                        if (settings.cid > 0) {
116                            url += "&cid=" + settings.cid;
117                        }
118                        if (settings.itemType > 0) {
119                            url += "&itemType=" + settings.itemType;
120                        }
121                        if (settings.isLine > 0) {
122                            url += "&isLine=" + settings.isLine;
123                        }
124                        
125                    }
126                    else {
127                        url = "/shop/product/getContents.aspx?ISBN=" + isbn + "&name=" + name + "&type=" + type;
128                        if ( settings.infoType > 0 ) {
129                            url += "&infoType=" + settings.infoType;
130                        }
131                    }
132                    var d = new Date();
133                    url += "&date="+d.getHours();
134                    
135
136                    if(type==2 || (type==0 && name=="CommentReview")) //#49072
137                    {    
138                        url += escape(new Date().getTime());
139                    }
140
141
142                    
143                    if( settings.replaceElement )
144                    {
145                        $.get(url, function(data, textStatus) {
146                            $(self).replaceWith(data);
147                            if (settings.isHashLink)
148                                goHashLink(self);
149                            if( $.isFunction(settings.complete) )
150                                settings.complete();
151                        }); 
152                    }
153                    else
154                    {
155                        $(self).load(url, function() {
156                            if (settings.isHashLink)
157                                goHashLink(self);
158                            if ($.isFunction(settings.complete))
159                                settings.complete();
160                        });
161                    }
162                }
163            });
164            if ("scroll" != settings.event) {
165                $(self).bind(settings.event, function(event) {
166                    if (!self.loaded) {
167                        $(self).trigger("appear");
168                    }
169                });
170            }
171        });
172        $(settings.container).trigger(settings.event);
173        
174        return this;
175
176    };
177    $.belowthefold = function(element, settings) {
178        if (settings.container === undefined || settings.container === window) {
179            var fold = $(window).height() + $(window).scrollTop();
180        } else {
181            var fold = $(settings.container).offset().top + $(settings.container).height();
182        } 
183        return fold <= $(element).offset().top - settings.threshold;
184    };
185    
186    $.rightoffold = function(element, settings) {
187        if (settings.container === undefined || settings.container === window) {
188            var fold = $(window).width() + $(window).scrollLeft();
189        } else {
190            var fold = $(settings.container).offset().left + $(settings.container).width();
191        }
192        return fold <= $(element).offset().left - settings.threshold;
193    };
194        
195    $.abovethetop = function(element, settings) {
196        if (settings.container === undefined || settings.container === window) {
197            var fold = $(window).scrollTop();
198        } else {
199            var fold = $(settings.container).offset().top;
200        }
201        return fold >= $(element).offset().top + settings.threshold  + $(element).height();
202    };
203    
204    $.leftofbegin = function(element, settings) {
205        if (settings.container === undefined || settings.container === window) {
206            var fold = $(window).scrollLeft();
207        } else {
208            var fold = $(settings.container).offset().left;
209        }
210        return fold >= $(element).offset().left + settings.threshold + $(element).width();
211    };
212    $.extend($.expr[':'], {
213        "below-the-fold" : "$.belowthefold(a, {threshold : 0, container: window}
213)",
214        "above-the-fold" : "!$.belowthefold(a, {threshold : 0, container: window})",
215        "right-of-fold"  : "$.rightoffold(a, {threshold : 0, container: window})",
216        "left-of-fold"   : "!$.rightoffold(a, {threshold : 0, container: window})"
217    });
218})(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.