1(function() { 2 'use strict'; 3 4 // Get thumb effect from localized script data 5 const nggInstagramThumbEffect = (typeof nggInstagramLinks !== 'undefined' && nggInstagramLinks.thumbEffect) 6 ? nggInstagramLinks.thumbEffect 7 : ''; 8 9 function updateInstagramLinks() { 10 // Target all links with instagram data attributes across different gallery display types. 11 const selectors = [ 12 'a[data-instagram-link]', 13 '.ngg-gallery-thumbnail a[data-instagram-link]', 14 '.ngg-gallery a[data-instagram-link]', 15 '.nextgen-gallery a[data-instagram-link]' 16 ]; 17 18 const links = document.querySelectorAll(selectors.join(', ')); 19 20 links.forEach((link) => { 21 const instagramLink = link.getAttribute('data-instagram-link'); 22 const instagramTarget = link.getAttribute('data-instagram-target'); 23 24 if (instagramLink) { 25 link.href = instagramLink; 26 27 // Disable lightbox behavior first (clears stale rel + lightbox attrs). 28 link.classList.remove('ngg-fancybox', 'ngg-simplelightbox', 'nextgen_pro_lightbox', 'shutter', 'shutterset'); 29 link.removeAttribute('data-fancybox'); 30 link.removeAttribute('data-lightbox'); 31 link.removeAttribute('data-nplmodal'); 32 link.removeAttribute('rel'); 33 34 if (instagramTarget === '_blank') { 35 link.target = '_blank'; 36 link.rel = 'noopener noreferrer'; 37 } else { 38 link.removeAttribute('target'); 39 } 40 41 link.setAttribute('data-instagram-direct', 'true'); 42 43 // Add click handler to ensure navigation happens. 44 if (!link.hasAttribute('data-instagram-click-bound')) { 45 link.setAttribute('data-instagram-click-bound', 'true'); 46 link.addEventListener('click', (e) => { 47 e.stopPropagation(); 48 // Allow default navigation behavior. 49 // If target is _blank, browser will open new tab. 50 // Otherwise, navigate in same window. 51 if (link.target !== '_blank') { 52 e.preventDefault(); 53 window.location.href = link.href; 54 } 55 }, true); 56 } 57 } 58 }); 59 60 const noTitleLinks = document.querySelectorAll('a[data-ngg-instagram="1"][data-instagram-no-title="1"]'); 61 noTitleLinks.forEach((a) => { 62 a.removeAttribute('title'); 63 64 // Remove title from any nested images (including <picture><img ...>). 65 const imgs = a.querySelectorAll('img'); 66 imgs.forEach((img) => { 67 img.removeAttribute('title'); 68 }); 69 }); 70 71 // Fallback: ensure Instagram images remain clickable even when lightbox is disabled. 72 const lightboxIsNone = (nggInstagramThumbEffect === 'none' || nggInstagramThumbEffect === ''); 73 const instagramAnchors = document.querySelectorAll('a[data-ngg-instagram="1"]'); 74 instagramAnchors.forEach((a) => { 75 if (lightboxIsNone && a.hasAttribute('data-instagram-no-link')) { 76 a.removeAttribute('href'); 77 a.style.cursor = 'default'; 78 if (!a.hasAttribute('data-instagram-nolink-bound')) { 79 a.setAttribute('data-instagram-nolink-bound', 'true'); 80 a.addEventListener('click', (e) => { 81 e.preventDefault(); 82 e.stopPropagation(); 83 }, true); 84 } 85 return; 86 } 87 88 const href = a.getAttribute('href'); 89 if (href && href !== '#' && href !== '') { 90 return; 91 } 92 93 if (lightboxIsNone && !a.classList.contains('use_imagebrowser_effect')) { 94 return; 95 } 96 97 // If NextGen's imagebrowser/attach behavior is used, build a real URL from the stub. 98 if (a.classList.contains('use_imagebrowser_effect')) { 99 const stubUrl = a.getAttribute('data-imagebrowser-url'); 100 if (stubUrl) { 101 const stubId = a.getAttribute('data-image-slug') || a.getAttribute('data-image-id'); 102 if (stubId) { 103 a.setAttribute('href', stubUrl.replace('%STUB%', stubId)); 104 return; 105 } 106 } 107 } 108 109 // Otherwise fall back to the full-size URL provided in data-src. 110 const dataSrc = a.getAttribute('data-src'); 111 if (dataSrc) { 112 a.setAttribute('href', dataSrc); 113 } 114 }); 115 } 116 117 if (typeof jQuery !== 'undefined') { 118 jQuery(document).ready(($) => { 119 updateInstagramLinks(); 120 jQuery(document).on('refreshed', updateInstagramLinks); 121 jQuery(document).on('ngg_lightbox_ready', updateInstagramLinks); 122 jQuery(window).on('ngg.mosaic.complete', updateInstagramLinks); 123 }); 124 document.addEventListener('nextgen_page_refreshed', updateInstagramLinks); 125 } else { 126 if (document.readyState === 'loading') { 127 document.addEventListener('DOMContentLoaded', updateInstagramLinks); 128 } else { 129 updateInstagramLinks(); 130 } 131 document.addEventListener('nextgen_page_refreshed', updateInstagramLinks); 132 } 133})();
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.