diff --git a/HISTORY.rst b/HISTORY.rst index 1772c2e9c0..16a7cdd886 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -1,3 +1,8 @@ +3.1.7 (2018-10-XX) +================== +* Fix an issue with some browsers not firing the .load event on cached + images. Ref: http://api.jquery.com/load-event/ + 3.1.6 (2018-10-09) ================== * Improve index mirroring value clean up code to remove the spaces at the diff --git a/mayan/apps/appearance/static/appearance/js/mayan_image.js b/mayan/apps/appearance/static/appearance/js/mayan_image.js index 43e0a6ed88..d04f896832 100644 --- a/mayan/apps/appearance/static/appearance/js/mayan_image.js +++ b/mayan/apps/appearance/static/appearance/js/mayan_image.js @@ -40,7 +40,7 @@ class MayanImage { threshold: 2000, }); - $('.lazy-load').on('load', function() { + $('.lazy-load').one('load', function() { $(this).hide(); $(this).fadeIn(300); $(this).siblings('.spinner-container').remove(); @@ -49,7 +49,7 @@ class MayanImage { MayanImage.timer = setTimeout(MayanImage.timerFunction, 100); }); - $('.lazy-load-carousel').on('load', function() { + $('.lazy-load-carousel').one('load', function() { $(this).hide(); $(this).fadeIn(300); $(this).siblings('.spinner-container').remove(); @@ -66,11 +66,19 @@ class MayanImage { var self = this; var container = this.element.parent().parent().parent(); - this.element.on('error', (function(event) { - container.html(MayanImage.templateInvalidDocument); - })); - this.element.attr('src', this.element.attr('data-url')); + this.element.on('error', function() { + // Check the .complete property to see if it is a real error + // or it was a cached image + if (this.complete === false) { + // It is a cached image, set the src attribute to trigger + // it's display. + this.src = this.src; + } else { + container.html(MayanImage.templateInvalidDocument); + } + }); + $.fn.matchHeight._maintainScroll = true; }; }