From 91bac301f9aa6b7e9e63e5dbcdd5e4e8f8c9907c Mon Sep 17 00:00:00 2001 From: Martin Donnelly Date: Fri, 14 Aug 2015 11:16:58 +0100 Subject: [PATCH] blacklisting shit images --- html/js/jquery.unveil.js | 81 +++++++++++++++++++++++----------------- 1 file changed, 47 insertions(+), 34 deletions(-) diff --git a/html/js/jquery.unveil.js b/html/js/jquery.unveil.js index 65ad7ab..585a69d 100644 --- a/html/js/jquery.unveil.js +++ b/html/js/jquery.unveil.js @@ -8,49 +8,62 @@ * https://github.com/luis-almeida */ -;(function($) { +; +(function($) { - $.fn.unveil = function(threshold, callback) { + var blackList = ['feeds.feedburner.com', 'pi.feedsportal.com', 'rc.feedsportal.com']; + $.fn.unveil = function(threshold, callback) { - var $w = $(window), - th = threshold || 0, - retina = window.devicePixelRatio > 1, - attrib = retina? "data-src-retina" : "data-src", - images = this, - loaded; + var $w = $(window), + th = threshold || 0, + retina = window.devicePixelRatio > 1, + attrib = retina ? "data-src-retina" : "data-src", + images = this, + loaded; - this.one("unveil", function() { - var source = this.getAttribute(attrib); - source = source || this.getAttribute("data-src"); - if (source) { - this.setAttribute("src", source); - if (typeof callback === "function") callback.call(this); - } - }); + this.one("unveil", function() { + var source = this.getAttribute(attrib); + source = source || this.getAttribute("data-src"); - function unveil() { - var inview = images.filter(function() { - var $e = $(this); - // if ($e.is(":hidden")) return; + var flag = false; + for (var item in blacklist) { + if (source.indexOf(item)) { + flag = true; + } + } + if (source && !flag) { + this.setAttribute("src", source); + if (typeof callback === "function") callback.call(this); + } - var wt = $w.scrollTop(), - wb = wt + $w.height(), - et = $e.offset().top, - eb = et + $e.height(); + if (flag) { + this.hide(); + } + }); - return eb >= wt - th && et <= wb + th; - }); + function unveil() { + var inview = images.filter(function() { + var $e = $(this); + // if ($e.is(":hidden")) return; - loaded = inview.trigger("unveil"); - images = images.not(loaded); - } + var wt = $w.scrollTop(), + wb = wt + $w.height(), + et = $e.offset().top, + eb = et + $e.height(); - $w.on("scroll.unveil resize.unveil lookup.unveil", unveil); + return eb >= wt - th && et <= wb + th; + }); - unveil(); + loaded = inview.trigger("unveil"); + images = images.not(loaded); + } - return this; + $w.on("scroll.unveil resize.unveil lookup.unveil", unveil); - }; + unveil(); -})(window.jQuery || window.Zepto); + return this; + + }; + + })(window.jQuery || window.Zepto);