1/* 2 * This file is part of the "gridgallery" Extension for TYPO3 CMS. 3 * 4 * For the full copyright and license information, please read the 5 * LICENSE file that was distributed with this source code. 6 */ 7 8let gridgallery = { 9 10 /** 11 * Initialize the grid gallery 12 */ 13 init: function () { 14 gridgallery.loadGallery(); 15 gridgallery.lazyLoadImages(); 16 jQuery(window).on('resize scroll', function () { 17 gridgallery.lazyLoadImages(); 18 }); 19 }, 20 21 /** 22 * Load the gallery with justifiedGallery() 23 */ 24 loadGallery: function () { 25 jQuery('.ce-gridgallery').each(function () { 26 jQuery(this).justifiedGallery({ 27 rowHeight: jQuery(this).data('row-height'), 28 margins: jQuery(this).data('margins'), 29 captions: jQuery(this).data('captions') === 1, 30 randomize: jQuery(this).data('randomize') === 1, 31 lastRow: jQuery(this).data('last-row'), 32 border: jQuery(this).data('border') 33 }); 34 }); 35 }, 36 37 /** 38 * Load "unloaded" images if they are in the viewport 39 */ 40 lazyLoadImages: function () { 41 jQuery('.ce-gridgallery img.unloaded').each(function () { 42 if (gridgallery.isInViewport(jQuery(this)) === true) { 43 let src = jQuery(this).attr('data-src'); 44 let srcset = jQuery(this).attr('data-srcset'); 45 if (src !== undefined && src !== '') { 46 jQuery(this).attr('src', src).removeAttr('data-src'); 47 } 48 if (srcset !== undefined && srcset !== '') { 49 jQuery(this).attr('srcset', srcset).removeAttr('data-srcset'); 50 } 51 jQuery(this).removeClass('unloaded'); 52 } 53 }); 54 }, 55 56 /** 57 * Checks if an element is in the viewport 58 * 59 * @param img Image Object 60 * @returns boolean returns true if the image is in viewport 61 */ 62 isInViewport: function (img) { 63 let elementTop = img.offset().top; 64 let elementBottom = elementTop + img.outerHeight(); 65 let viewportTop = jQuery(window).scrollTop(); 66 let viewportBottom = viewportTop + jQuery(window).height(); 67 return elementBottom >= viewportTop && elementTop <= viewportBottom; 68 } 69}; 70 71jQuery(document).ready(function () { 72 gridgallery.init(); 73 74 75 jQuery('a.fancybox').fancybox({ 76 buttons : [ 77 'download', 78 'zoom', 79 'slideShow', 80 'thumbs', 81 'close' 82 ], 83 afterShow : function(instance, current) { 84 var src = current.src.replace('1500x1000', '5000x2000'); 85 jQuery("[data-fancybox-download]").attr('href', src); 86 } 87 }); 88 89});
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.