PageSourceSearch

https://nuboyana.com/wp-content/plugins/gg-lightbox/ggbl-lightbox.js?ver=1

js nuboyana.com collected 2026-10-02 13:00:20 UTC 6,634 bytes, 189 lines download raw bytes

1jQuery(document).ready(function($) {
2	// global variables for script
3	var current, size;
4	$('.wp-block-gallery a').click(function(e) {
5		// prevent default click event
6		e.preventDefault();
7		// get href from clicked element
8		var image_href = $(this).attr("href");
9		console.log(image_href);
10		// determine the index of clicked trigger
11		var slideNum = $('.wp-block-gallery a').index(this);
12		console.log(slideNum);
13
14		// find out if #ggbl_lightbox exists
15		if ($('#ggbl_lightbox').length > 0) {
16			// if it does
17			$('#ggbl_lightbox').fadeIn(300);
18			// otherwise
19		} else {
20			// create HTML markup for lightbox window
21			var lightbox =
22				'<div id="ggbl_lightbox">' +
23				'<div class="ggbl_close"></div>' +
24				'<ul id="ggbl_slider"></ul>' +
25				'<div class="ggbl_nav">' +
26				'<a href="#" class="ggbl_prev ggbl_slide-nav"></a>' +
27				'<a href="#" class="ggbl_next ggbl_slide-nav"></a>' +
28				'</div><!-- .ggbl_nav -->' +
29				'</div><!-- #ggbl_lightbox -->';
30			// add lightbox HTML to the DOM
31			$('body').append(lightbox);
32			// make sure the user can't scroll while the lightbox is showing
33			$('body').addClass("ggbl_noscroll");
34			// fill lightbox with .blocks-gallery-grid a hrefs
35			$('.wp-block-gallery').find('.wp-block-image a').each(function() {
36				var $href = $(this).attr('href');
37				$('#ggbl_slider').append(
38					'<li>' +
39					'<img src="' + $href + '">' +
40					'</li>'
41				);
42			});
43		}
44		// set the slider size based on number of objects in slideshow
45		size = $('#ggbl_slider > li').length;
46		// hide all slides, then show the selected slide
47		$('#ggbl_slider > li').hide();
48		$('#ggbl_slider > li:eq(' + slideNum + ')').show();
49		// set current to selected slide
50		current = slideNum;
51	});
52	// click anywhere on the page to get rid of lightbox window
53	$('body').on('click', '#ggbl_lightbox', function() { // using .on() instead of .live(). more modern, and fixes event bubbling issues
54		$('#ggbl_lightbox').fadeOut(300);
55		$('body').removeClass("ggbl_noscroll");
56	});
57	var swipeInProgress = false;
58
59	// navigation prev/next
60	$('body').on('click', '.ggbl_slide-nav', function(e) {
61	    e.preventDefault();
62	    e.stopPropagation();
63	    var $this = $(this);
64	    var dest;
65	    if ($this.hasClass('ggbl_prev')) {
66	        dest = current - 1;
67	        if (dest < 0) dest = size - 1;
68	    } else {
69	        dest = current + 1;
70	        if (dest > size - 1) dest = 0;
71	    }
72	    if (!swipeInProgress) {
73	        $('#ggbl_slider > li:eq(' + current + ')').fadeOut(750);
74	        $('#ggbl_slider > li:eq(' + dest + ')').fadeIn(750);
75	    } else {
76	        swipeInProgress = false; // Move this line BEFORE .show()
77	        $('#ggbl_slider > li:eq(' + current + ')').hide();
78	        $('#ggbl_slider > li:eq(' + dest + ')').show();
79	    }
80	    current = dest;
81	});
82
83	// navigation left/right arrow keys, esc to close
84	document.onkeydown = function(e) {
85	    e = e || window.event;
86	    var dest;
87	    if (e.keyCode == '37') {
88	        e.preventDefault();
89	        e.stopPropagation();
90	        dest = current - 1;
91	        if (dest < 0) dest = size - 1;
92	        if (!swipeInProgress) {
93	            $('#ggbl_slider > li:eq(' + current + ')').fadeOut(750);
94	            $('#ggbl_slider > li:eq(' + dest + ')').fadeIn(750);
95	        } else {
96	            swipeInProgress = false; // Move this line BEFORE .show()
97	            $('#ggbl_slider > li:eq(' + current + ')').hide();
98	            $('#ggbl_slider > li:eq(' + dest + ')').show();
99	        }
100	        current = dest;
101	    } else if (e.keyCode == '39') {
102	        e.preventDefault();
103	        e.stopPropagation();
104	        dest = current + 1;
105	        if (dest > size - 1) dest = 0;
106	        if (!swipeInProgress) {
107	            $('#ggbl_slider > li:eq(' + current + ')').fadeOut(750);
108	            $('#ggbl_slider > li:eq(' + dest + ')').fadeIn(750);
109	        } else {
110	            swipeInProgress = false; // Move this line BEFORE .show()
111	            $('#ggbl_slider > li:eq(' + current + ')').hide();
112	            $('#ggbl_slider > li:eq(' + dest + ')').show();
113	        }
114	        current = dest;
115	    } else if (e.keyCode == '27') {
116	        $('#ggbl_lightbox').fadeOut(300);
117	        $('body').removeClass("ggbl_noscroll");
118	    }
119	};
120
121	// Swipe navigation for mobile with slide animation
122	var touchStartX = null;
123	var touchEndX = null;
124	var swipeThreshold = 50; // Minimum px distance for swipe
125
126	$('body').on('touchstart', '#ggbl_slider', function(e) {
127	    if (e.originalEvent.touches.length === 1) {
128	        touchStartX = e.originalEvent.touches[0].clientX;
129	    }
130	});
131
132	$('body').on('touchmove', '#ggbl_slider', function(e) {
133	    if (e.originalEvent.touches.length === 1) {
134	        touchEndX = e.originalEvent.touches[0].clientX;
135	    }
136	});
137
138	$('body').on('touchend', '#ggbl_slider', function(e) {
139	    if (touchStartX !== null && touchEndX !== null) {
140	        var diff = touchStartX - touchEndX;
141	        if (Math.abs(diff) > swipeThreshold) {
142	            var $slides = $('#ggbl_slider > li');
143	            var $currentSlide = $slides.eq(current);
144	            var dest, direction;
145	            if (diff > 0) {
146	                dest = current + 1;
147	                if (dest > size - 1) dest = 0;
148	                direction = 'left';
149	            } else {
150	                dest = current - 1;
151	                if (dest < 0) dest = size - 1;
152	                direction = 'right';
153	            }
154	            var $nextSlide = $slides.eq(dest);
155
156	            // Set up parent for sliding
157	            $('#ggbl_slider').css({position: 'relative', overflow: 'hidden'});
158
159	            // Prepare next slide position
160	            $nextSlide.css({
161	                display: 'block',
162	                position: 'absolute',
163	                left: (direction === 'left' ? '100%' : '-100%'),
164	                top: 0,
165	                width: '100%'
166	            });
167
168	            // Animate slides
169	            $currentSlide
170	                .css({position: 'absolute', left: 0, top: 0, width: '100%'})
171	                .animate({left: (direction === 'left' ? '-100%' : '100%')}, 400, function() {
172	                    $(this).hide().css({position: '', left: '', top: '', width: ''});
173	                });
174	            $nextSlide
175	                .animate({left: '0%'}, 400, function() {
176	                    $(this).css({position: '', left: '', top: '', width: ''});
177	                    // Hide all other slides just in case
178	                    $slides.not($(this)).hide();
179	                });
180
181	            current = dest;
182	            swipeInProgress = true;
183	        }
184	    }
185	    // Reset
186	    touchStartX = null;
187	    touchEndX = null;
188	});
189});

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.