1(function ($) { 2 "use strict"; 3 /*jslint undef: false, browser: true, devel: false, eqeqeq: false, bitwise: false, white: false, plusplus: false, regexp: false, nomen: false */ 4 /*jshint undef: false, browser: true, devel: false, eqeqeq: false, bitwise: false, white: false, plusplus: false, regexp: false, nomen: false, validthis: true */ 5 /*global jQuery,setTimeout,location,setInterval,YT,clearInterval,clearTimeout,pixelentity */ 6 7 $.pixelentity = $.pixelentity || {version: '1.0.0'}; 8 9 $.pixelentity.peLazyLoading = { 10 conf: { 11 api: false 12 } 13 }; 14 15 var jwin = $(window); 16 var scroller = false; 17 var hires = window.devicePixelRatio >= 1.5; 18 19 $(function () { 20 scroller = $(".scroller > .scroll-content"); 21 scroller = scroller.length === 0 ? false : scroller; 22 }); 23 24 function PeLazyLoading(target, conf) { 25 26 var top, bottom, refresh = true,counter = 0; 27 28 function checkIfLoaded(idx,el) { 29 if (el.peLoading || el._peLoaded) { 30 return; 31 } 32 33 el = target.eq(el.peIDX); 34 35 if (!el.hasClass("pe-lazyloading-forceload")) { 36 var y = (refresh || !el.data("pe-lazyload-top")) ? (el.data("pe-lazyload-forced-top") ? el.data("pe-lazyload-forced-top") : el.offset().top) : el.data("pe-lazyload-top"); 37 el.data("pe-lazyload-top",y); 38 39 var h = (refresh || !el.data("pe-lazyload-height")) ? el.height() : el.data("pe-lazyload-height"); 40 el.data("pe-lazyload-height",h); 41 42 if ((y+h) < top || y > bottom) { 43 return; 44 } 45 } 46 47 el.triggerHandler("pe-lazyload-load"); 48 } 49 50 function loaded() { 51 var el = target.eq(this.idx); 52 el.attr("src",this.src); 53 el.addClass("pe-lazyload-loaded").triggerHandler("pe-lazyload-loaded"); 54 el.fadeTo($.pixelentity.browser.mobile ? 0 : 200,1); 55 //el.fadeTo(200,1); 56 el[0].peLoaded = true; 57 this.src = ""; 58 counter--; 59 //el.addClass("animated fadeIn"); 60 } 61 62 63 function load() { 64 var idx = this.peIDX; 65 var el = target.eq(idx); 66 this.peLoading = true; 67 var img = $("<img />"); 68 img[0].idx = this.peIDX; 69 var src = hires ? el.attr("data-original-hires") : el.attr("data-original"); 70 // fallback if no hires image is defined 71 src = src || el.attr("data-original"); 72 img.one("load",loaded).attr("src",src); 73 } 74 75 function init(idx) { 76 this.peLoading = false; 77 this.peLoaded = false; 78 this.peIDX = idx; 79 counter++; 80 target.eq(idx).css("opacity",0).addClass("pe-lazyload-inited"); 81 } 82 83 84 function update() { 85 if (counter === 0) { 86 destroy(); 87 return true; 88 } 89 top = scroller ? scroller.scrollTop() : 0; 90 top += jwin.scrollTop(); 91 bottom = top + (window.innerHeight ? window.innerHeight : jwin.height()); 92 refresh = true; 93 target.each(checkIfLoaded); 94 return true; 95 } 96 97 function destroy() { 98 jwin.off("scroll pe-lazyloading-refresh", update); 99 if (scroller) { 100 scroller.off("scroll",update); 101 } 102 103 if (target) { 104 target.off("pe-lazyload-load"); 105 target.data("peLazyLoading", null); 106 target = undefined; 107 } 108 } 109 110 111 // init function 112 function start() { 113 target.each(init); 114 target.on("pe-lazyload-load",load); 115 $(update); 116 jwin.on("scroll pe-lazyloading-refresh", update); 117 if (scroller) { 118 scroller.on("scroll",update); 119 } 120 } 121 122 $.extend(this, { 123 // plublic API 124 destroy: destroy 125 }); 126 127 // initialize 128 start(); 129 } 130 131 // jQuery plugin implementation 132 $.fn.peLazyLoading = function(conf) { 133 134 // return existing instance 135 var api = this.data("peLazyLoading"); 136 137 if (api) { 138 return api; 139 } 140 141 conf = $.extend(true, {}, $.pixelentity.peLazyLoading.conf, conf); 142 143 //this.each(function() { 144 var el = $(this); 145 api = new PeLazyLoading(el, conf); 146 el.data("peLazyLoading", api); 147 //}); 148 149 return conf.api ? api: this; 150 }; 151 152}(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.