1jQuery(document).ready(function($) { 2 $('.fancybox img').each(function () { 3 var $img = $(this); 4 var imgSrc = $img.attr('src'); 5 var imgTitle = $img.attr('title'); 6 7 if (!imgTitle) { 8 imgTitle = imgSrc.split('/').pop() 9 .replace(/\.\w+$/, '') 10 .replace(/[_-]+/g, ' ') 11 .replace(/\b\d+\b/g, '') 12 .trim(); 13 } 14 15 imgTitle = imgTitle.replace(/["']/g, "'"); 16 17 if (!$img.parent().is('a')) { 18 $img.wrap('<a href="' + imgSrc + '" class="ari-fancybox" aria-label="Bild ' + imgTitle + ' vergröÃern"></a>'); 19 } 20 }); 21 22 setTimeout(function () { 23 $('.ari-fancybox').each(function () { 24 var $this = $(this); 25 26 $this.fancybox({ 27 autoStart: false, 28 buttons: ['close'], 29 30 afterShow: function (instance) { 31 var lightboxImage = $('.fancybox-image'); 32 var closeButton = $('.fancybox-button--close'); 33 var focusableElements = [lightboxImage[0], closeButton[0]]; 34 var currentIndex = 0; 35 36 closeButton.attr('title', 'Bild schlieÃen'); 37 lightboxImage.attr('tabindex', '0').focus(); 38 39 // Disable tab navigation outside the lightbox 40 $('body *').not('.fancybox-container *').attr('tabindex', '-1'); 41 42 // Clean previous events before adding new ones 43 $(document).off('keydown.fancybox').off('mousedown.fancybox'); 44 45 // Function to close Fancybox and return focus 46 function closeFancybox() { 47 $this.focus(); 48 $(document).off('keydown.fancybox').off('mousedown.fancybox'); 49 $('body *').removeAttr('tabindex'); 50 } 51 52 // Handle tab and escape key navigation 53 $(document).on('keydown.fancybox', function (e) { 54 if (e.key === 'Tab') { 55 e.preventDefault(); 56 currentIndex = (currentIndex + 1) % focusableElements.length; 57 focusableElements[currentIndex].focus(); 58 } else if (e.key === 'Escape') { 59 closeFancybox(); 60 instance.close(); 61 } 62 }); 63 64 // Prevent mouse clicks outside the lightbox 65 $(document).on('mousedown.fancybox', function (e) { 66 if (!$(e.target).closest('.fancybox-container').length) { 67 e.preventDefault(); 68 focusableElements[currentIndex].focus(); 69 } 70 }); 71 }, 72 73 afterClose: function () { 74 $this.focus(); 75 $(document).off('keydown.fancybox').off('mousedown.fancybox'); 76 $('body *').removeAttr('tabindex'); 77 } 78 }); 79 }); 80 }, 300); 81});
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.