PageSourceSearch

https://www.kreis-lup.de/output/js/photoswipe/jqPhotoSwipe.js

js kreis-lup.de collected 2026-10-02 10:21:42 UTC 11,894 bytes, 285 lines download raw bytes

1/*!
2jqPhotoSwipe v0.1.1 - jQuery for PhotoSwipe
3https://ergec.github.io/jQuery-for-PhotoSwipe/
4*/
5(function (jQuery) {
6	jQuery.fn.jqPhotoSwipe = function (options) {
7		if (this.length) {
8			var parseHash = function() {
9				var hash = window.location.hash.substring(1),
10				params = {};
11				var vars = hash.split('&');
12				for (var i = 0; i < vars.length; i++) {
13					if(!vars[i]) {
14						continue;
15					}
16					var pair = vars[i].split('=');  
17					if(pair.length < 2) {
18						continue;
19					}           
20					params[pair[0]] = pair[1];
21				}
22
23				if(params.gid) {
24					params.gid = params.gid;
25				}
26
27				return params;
28			};
29			var _photoswipe = {};
30			var defaults = {
31				forceSingleGallery: false,
32				galleryOpen: function (gallery) {
33
34				}
35			};
36			_photoswipe.galleries = [];
37			_photoswipe.galleriesindex = [];
38			var $galleryid = 0;
39			var pswpElement;
40			if ($(".pswp[role='dialog']").length) {
41				pswpElement = $(".pswp[role='dialog']")[0];
42			} else {
43				var pswpHTML = '<div class="pswp" tabindex="0" role="dialog" aria-label="Bildergalerie" aria-modal="true" aria-hidden="true"><div class="pswp__bg"></div><div class="pswp__scroll-wrap"><div class="pswp__container"><div class="pswp__item"></div><div class="pswp__item"></div><div class="pswp__item"></div></div><div class="pswp__ui pswp__ui--hidden"><div class="pswp__top-bar"><div class="pswp__counter" role="status" aria-live="polite" aria-atomic="true"></div><button class="pswp__button pswp__button--close" title="Schlie&szlig;en (Esc)"><span class="sr-only">Schlie&szlig;en (Esc)</span></button><button class="pswp__button pswp__button--share" title="Share"><span class="sr-only">Share</span></button><button class="pswp__button pswp__button--fs" title="Vollbild"><span class="sr-only">Vollbild</span></button><button class="pswp__button pswp__button--zoom" title="Zoom"><span class="sr-only">Zoom</span></button></div><div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap"><div class="pswp__share-tooltip"></div> </div><div class="pswp__preloader"><i class="fas fa-spinner fa-spin fa-2x"></i></div><button class="pswp__button pswp__button--arrow--left" title="zur&uuml;ck"><span class="sr-only">zur&uuml;ck</span></button><button class="pswp__button pswp__button--arrow--right" title="vor"><span class="sr-only">vor</span></button><div id="photoswipe-caption" class="pswp__caption" role="status"><div class="pswp__caption__center"></div></div></div></div></div>';
44				pswpElement = $(pswpHTML).appendTo("body")[0];
45			}
46			var forcedGalleryId = "pswg-forced";
47			
48			//BR: ikissedit-Attribut setzen/entfernen
49			var setIkissEdit = function(galObj) {
50				var cItem = galObj.items[galObj.getCurrentIndex()];
51				$('.pswp__img, .pswp__caption__center').attr('ikissedit', (cItem && cItem.ikissedit) ? 'med|'+cItem.ikissedit : null);
52			};
53
54			var setAltText = function(galObj) {
55				var cItem = galObj.items[galObj.getCurrentIndex()];
56				$('.pswp__img').attr('alt', (cItem && cItem.altText) ? cItem.altText : null);
57			};
58			
59			//Aria-Attribute setzen
60			var setAriaAttributes = function() {
61				$('.pswp__img').attr('aria-labelledby', 'photoswipe-caption');
62			};
63			
64			//BR: Focus bei Tab-Key im Element behalten
65			var preserveFocusOnTabKey = function(el, focusEls, setFirstFocus, hasEnterKey) {
66				var	firstTabbable 	= focusEls[0],
67					lastTabbable 	= focusEls[focusEls.length-1];
68				
69				if (setFirstFocus) {
70					firstTabbable.focus();
71					if (hasEnterKey) {
72						firstTabbable.addClass('tab-focus').on('focusout', function() {
73							$(this).removeClass('tab-focus');
74						});
75					} else {
76						firstTabbable.removeClass('tab-focus');    
77					}
78				}
79						
80				el.off('.photoswipe-tabkey').on('keydown.photoswipe-tabkey', function(ev) {
81					var	trg	= ev.target, 
82						sk	= ev.shiftKey; 
83				
84					$('.pswp__ui').removeClass('pswp__ui--idle');
85					$(el).removeClass('pswp--has_mouse');
86				
87					if (ev.which === 9) {
88						
89						if ((!sk && trg == lastTabbable[0]) || (sk && trg == firstTabbable[0])) {
90							ev.preventDefault();
91							(sk ? lastTabbable : firstTabbable).focus();
92						} else {							
93							var index = -1;
94							$.each(focusEls, function(idx, el) {
95								if (el[0] === trg) {
96									index = idx;
97								}
98							});
99							
100							if (index !== -1) {
101								focusEls[index+(sk ? -1 : 1)].focus();
102								ev.preventDefault();
103							}			
104						}
105					}
106				});
107			};
108						
109			//BR: Tabindex festlegen, CSS-Klasse bei Focus per TabKey hinzufügen
110			var collectFocusElements = function(hasEnterKey) {
111				var focusEls		= [],
112					tabIdx			= 1,
113					setFirstFocus	= true;
114					
115				$.each(['zoom', 'fs', 'close', 'arrow--left', 'arrow--right'], function(idx, sel) {
116					var el = $('.pswp .pswp__button--'+sel);
117				
118					if (el.hasClass('tab-focus')) {
119						setFirstFocus = false;	
120					}
121					
122					if (el.is(':visible')) {
123						focusEls.push(el);	
124					} 
125													
126				});
127				preserveFocusOnTabKey($('.pswp'), focusEls, setFirstFocus, hasEnterKey);
128			};
129			
130			
131			this.each(function () {
132				var $options = $.extend(defaults, options);
133				var $this = $(this);
134				var $galleryname = $this.data("photoswipe-group");
135				if (!$galleryname) {
136					if ($options.forceSingleGallery) {
137						$galleryname = forcedGalleryId;
138						$this.data("photoswipe-group", $galleryname);
139					} else {
140						$galleryname = "pswgname" + (_photoswipe.galleriesindex.length);
141						$this.data("photoswipe-group", $galleryname);
142					}
143				}
144				if (_photoswipe.galleriesindex.indexOf($galleryname) === -1) {
145					$galleryid = _photoswipe.galleriesindex.length;
146					_photoswipe.galleriesindex.push($galleryname);
147					_photoswipe.galleries[$galleryid] = {};
148					_photoswipe.galleries[$galleryid].items = [];
149					_photoswipe.galleries[$galleryid].i = 0;
150				} else {
151					$galleryid = _photoswipe.galleriesindex.indexOf($galleryname);
152				}
153				var $galleryid2 = $galleryid;
154				$this.data("i", _photoswipe.galleries[$galleryid].i);
155				$this.data("gid", $galleryname);
156				
157				// Prüfen, ob das Bild sich in einem Slickslider befindet und evtl. geklont ist
158				var slickSlide = $this.closest('.slick-slide');
159				if (slickSlide.length && slickSlide.hasClass('slick-cloned')) { //Falls geklont, weitere Ausführung abbrechen
160				    return;
161				} 
162				
163				_photoswipe.galleries[$galleryid2].items.push({
164					src: $(window).width() > 960 ? $this.data("photoswipe-large-source") : $this.data("photoswipe-medium-source"),
165					title: ($this.data("photoswipe-desc") ? '<span class="description">'+$this.data("photoswipe-desc")+'</span>' : '')+($this.data("photoswipe-copyright") ? '<span class="copyright">'+$this.data("photoswipe-copyright")+'</span>' : ''), //BR: Titel um Copyright erweitert
166					ikissedit: $this.data("photoswipe-ikissedit"), //BR: FID fuer ikissedit-Attribut
167					altText: $this.data("photoswipe-alt"), //BR: Alttext für die Bilder
168					thumbnail: this, //BR:Thumbnail fuer getThumbBoundsFn() speichern
169					w: 0,
170					h: 0
171				});
172				
173				//BR: Enter-Taste abfangen
174				$(this).off('keypress.enter, keyup.enter').on('keypress.enter, keyup.enter', function(e) {
175					if(e.key === "Enter")
176						$(this).data('has-enter-key', e.type == 'keypress' ? '1' : '');
177				});
178				
179				
180				$this.off("click").on("click", function (e) {
181
182                    e.preventDefault();
183					var trgNode		= this,
184						index 		= $(this).data("i"),
185						hasEnterKey = $(this).data("has-enter-key") == '1'; //BR: Wurde per Enter geöffnet?
186					
187					$options.index = index;
188					$options.galleryUID = $(this).data("gid");
189					$options.showHideOpacity = true;  //BR: Hinzugefuegt auf Grund von Formatunterschieden Thumbnail/Vergroessertes Bild
190					
191					//BR: Vergroessernugseffekt fuer das Ursprungsbild
192					var galItems = _photoswipe.galleries[$galleryid2].items; 
193					$options.getThumbBoundsFn = function(index) { 
194						if (!galItems[index].thumbnail) return {}; /* PC: Fix für dynamisch hinzugefügte Bilder */
195						var pageYScroll = window.pageYOffset || document.documentElement.scrollTop,
196							rect = galItems[index].thumbnail.getBoundingClientRect(); 
197						return { x: rect.left, y: rect.top + pageYScroll, w: rect.width };
198					}
199					
200					_photoswipe.galleries[$galleryid2].obj = new PhotoSwipe( pswpElement, PhotoSwipeUI_Default, _photoswipe.galleries[$galleryid2].items, $options);
201					_photoswipe.galleries[$galleryid2].obj.init();
202					
203					_photoswipe.galleries[$galleryid2].obj.listen('initialZoomInEnd', function() {
204						$options.galleryOpen(_photoswipe.galleries[$galleryid2].obj);
205						
206						collectFocusElements(hasEnterKey);	//BR: Focuselemente sammeln 
207						setIkissEdit(this); //BR: ikissedit setzen/entfernen
208						setAltText(this); //BR: altext setzen/entfernen
209						//setAriaAttributes(); //BR: Aria-Attribute setzen
210						
211						//BR: Close Button bei Bedienung über Tastatur data-Attrbibut zuweisen
212						$('.pswp .pswp__button--close').off('keypress.close-enter, keyup.close-enter').on('keypress.close-enter, keyup.close-enter', function(e) {
213							if(e.key === "Enter")
214								$(this).data('has-enter-key', e.type == 'keypress' ? '1' : '');
215						});
216						
217						//BR: aria-pressed für den Vollbildbutton setzen
218						var fsApi = this.ui.getFullscreenAPI();
219						if (fsApi) {
220							var updateAriaPressedFs = function() {
221								$('.pswp .pswp__button--fs').attr('aria-pressed', fsApi.isFullscreen() ? 'true' : 'false');	
222							};
223							$(document).on(fsApi.eventK, updateAriaPressedFs);
224							updateAriaPressedFs();	
225						} 
226						
227					});
228					_photoswipe.galleries[$galleryid2].obj.listen('imageLoadComplete', function(index, item) {
229						loadImg(index, item);
230					});
231					_photoswipe.galleries[$galleryid2].obj.listen('gettingData', function(index, item) {
232						loadImg(index, item);
233					});
234					_photoswipe.galleries[$galleryid2].obj.listen('afterChange', function() {
235						$('.pswp__img').attr('alt', ''); //BR: Leeres Alt-Attribut setzen (BITV) #12723
236						collectFocusElements();	//BR: Focuselemente sammeln 
237						setIkissEdit(this); //BR: ikissedit setzen/entfernen
238						setAltText(this); //BR: Alttext setzen/entfernen
239						//setAriaAttributes(); //BR: Aria-Attribute setzen
240					});
241					
242					_photoswipe.galleries[$galleryid2].obj.listen('resize', function() { 
243						collectFocusElements();	//BR: Focuselemente sammeln 	
244					});
245					
246					//BR: Klasse tab-focus auf öffnendes Element setzen
247					_photoswipe.galleries[$galleryid2].obj.listen('close', function() {
248						var cBut = $('.pswp .pswp__button--close'); 
249						if (cBut.data('has-enter-key') == '1') {
250							$(trgNode).focus().addClass('tab-focus');
251							cBut.data('has-enter-key', '');	
252						}
253					}); 
254					
255					_photoswipe.galleries[$galleryid2].obj.listen('destroy', function() { 
256						$(trgNode).focus(); //BR: Fokus auf öffnendes Element setzen
257						return false;
258					});
259					
260					
261					function loadImg(index, item) {
262						if (item.w == 0 && item.h == 0) {
263							var imgpreload = new Image(); 
264							imgpreload.onload = function() {
265								item.w = this.width;
266								item.h = this.height;
267								item.needsUpdate = true;
268								_photoswipe.galleries[$galleryid2].obj.updateSize(true);
269							};
270							imgpreload.src = item.src;
271						}
272					}
273				});
274				var $hashparams = parseHash();
275				if ($hashparams.gid) {
276					if ($hashparams.gid.toString() === $galleryname && $hashparams.pid.toString() === (_photoswipe.galleries[$galleryid].i + 1).toString()) {
277						$this.trigger("click");
278					}
279				}
280				_photoswipe.galleries[$galleryid].i ++;
281			});
282			return _photoswipe;
283		}
284	};
285})(jQuery);

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.