1 2$.fn.scrollLoading = function (options) { 3 4 let images = $(this); 5 6 images.each(function () { 7 8 9 if( typeof DNNapplyTypography == "undefined" && this.nodeName.toLowerCase() == "img" ){ 10 let url = $(this).attr("data-src"); 11 var viewBox =$(this).attr("src") && $(this).attr("src").indexOf("viewBox='")!=-1? $(this).attr("src").split("viewBox='")[1].split("' ")[0].split(" "):false; 12 if(viewBox[2]){ 13 var w= viewBox[2]; 14 }else{ 15 var w= $(this).width(); 16 } 17 $(this).siblings(".Lazy-loading-transparent,.Lazy-loading").remove(); 18 if(url && (url.indexOf(".png")!= -1 || url.indexOf(".gif")!= -1)){ 19 $(this).before('<span class="Lazy-loading-transparent" style="width:'+w+'px"></span>').parent().addClass("img-Lazy-warp"); 20 }else if(url){ 21 $(this).before('<span class="Lazy-loading" style="width:'+w+'px"></span>').parent().addClass("img-Lazy-warp"); 22 } 23 24 $(this).addClass("img-loading"); 25 } 26 }) 27 28 function imgAnimation(o){ 29 o.siblings(".Lazy-loading,.Lazy-loading-transparent").addClass("load-over").delay(400).queue(function(){$(this).remove().dequeue();}); 30 o.removeClass("img-loading"); 31 } 32 33 var LoadImages = function (event) { 34 if (event.isTrusted) { 35 images.each(function(){ 36 var e =$(this); 37 if(this.dataset.src){ 38 this.src = this.dataset.src; 39 delete this.dataset.src; 40 e.one("load", function () { 41 imgAnimation(e); 42 }); 43 } 44 }); 45 ['click', 'scroll'].forEach(function (e) { 46 document.removeEventListener(e, LoadImages); 47 window.removeEventListener('resize', LoadImagesOne); 48 }); 49 } 50 }; 51 ['click', 'scroll'].forEach(function (e) { 52 document.addEventListener(e, LoadImages); 53 }); 54 55 var LoadImagesOne = function (event) { 56 const viewPortHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight; 57 images.each(function () { 58 const top = this.getBoundingClientRect() && this.getBoundingClientRect().top; 59 if (top <= viewPortHeight && this.dataset.src) { 60 this.src = this.dataset.src; 61 delete this.dataset.src ; 62 $(this).one("load", function () {imgAnimation($(this));}) 63 } 64 }); 65 } 66 LoadImagesOne(); 67 window.addEventListener('resize', LoadImagesOne); 68 69}; 70 71$.fn.scrollLoadingBackground = function (options) { 72 73 let background = $(this); 74 var LoadBackground = function (event) { 75 if (event.isTrusted) { 76 background.each(function(){ 77 var e =$(this); 78 if(this.dataset.src){ 79 this.style.backgroundImage = "url(\"" + this.dataset.src + "\")"; 80 delete this.dataset.src ; 81 } 82 }); 83 ['click', 'scroll'].forEach(function (e) { 84 document.removeEventListener(e, LoadBackground); 85 window.removeEventListener('resize', LoadBackgroundOne); 86 }); 87 } 88 }; 89 ['click', 'scroll'].forEach(function (e) { 90 document.addEventListener(e, LoadBackground); 91 }); 92 var LoadBackgroundOne = function (event) { 93 const viewPortHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight; 94 background.each(function () { 95 if($(this).is(":visible")){ 96 const top = this.getBoundingClientRect() && this.getBoundingClientRect().top; 97 if (top <= viewPortHeight && this.dataset.src) { 98 this.style.backgroundImage = "url(\"" + this.dataset.src + "\")"; 99 delete this.dataset.src ; 100 } 101 } 102 }); 103 };
104 LoadBackgroundOne(); 105 window.addEventListener('resize', LoadBackgroundOne); 106 107}; 108 109 110$.fn.scrollLoadingVideo = function (options) { 111 112 let background = $(this); 113 var LoadBackground = function (event) { 114 if (event.isTrusted) { 115 background.each(function(){ 116 117 var isLazy = false; 118 $(this).find("source").each(function(){ 119 if(this.dataset.src){ 120 this.src = this.dataset.src; 121 delete this.dataset.src ; 122 isLazy = true; 123 } 124 }) 125 if(isLazy){ 126 var video = $(this).find("video"); 127 video.after(video[0].outerHTML); 128 video.remove(); 129 } 130 131 }); 132 ['click', 'scroll'].forEach(function (e) { 133 document.removeEventListener(e, LoadBackground); 134 document.removeEventListener('resize', LoadBackgroundOne); 135 }); 136 } 137 }; 138 ['click', 'scroll'].forEach(function (e) { 139 document.addEventListener(e, LoadBackground); 140 }); 141 var LoadBackgroundOne = function (event) { 142 const viewPortHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight; 143 background.each(function () { 144 if($(this).is(":visible")){ 145 const top = this.getBoundingClientRect() && this.getBoundingClientRect().top; 146 if (top <= viewPortHeight) { 147 148 var isLazy = false; 149 $(this).find("source").each(function(){ 150 151 if(this.dataset.src){ 152 this.src = this.dataset.src; 153 delete this.dataset.src ; 154 isLazy = true; 155 } 156 157 }) 158 if(isLazy){ 159 var video = $(this).find("video"); 160 video.after(video[0].outerHTML); 161 video.remove(); 162 } 163 } 164 165 166 } 167 }); 168 }; 169 LoadBackgroundOne(); 170 window.addEventListener('resize', LoadBackgroundOne); 171 172}; 173 174 175jQuery(document).ready(function () { 176 $(".img-Lazy:not(.img-loading)[data-src]").scrollLoading({ 177 loading: true, 178 }); 179 $(".bg-Lazy").scrollLoadingBackground({ 180 loading: true, 181 }); 182 $(".video-Lazy").scrollLoadingVideo({ 183 loading: true, 184 }); 185 186 $(".iframe-Lazy").scrollLoading({ 187 loading: true, 188 }); 189 190}) 191 192 193 194 195
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.