PageSourceSearch

https://wohlstandschmiede.com/wp-content/plugins/art-divi-masonry-…/photoSwipe/js/photoSwipe.init.js?ver=1.0

js wohlstandschmiede.com collected 2026-10-06 09:06:22 UTC 7,014 bytes, 217 lines download raw bytes

1var $ = jQuery;
2$(document).ready(function() {	
3	$(window).load(function() {	
4
5			var initPhotoSwipeFromDOM = function(gallerySelector) {
6
7		    // parse slide data (url, title, size ...) from DOM elements 
8		    // (children of gallerySelector)
9		    var parseThumbnailElements = function(el) {
10		        var thumbElements = el.childNodes,
11		            numNodes = thumbElements.length,
12		            items = [],
13		            figureEl,
14		            linkEl,
15		            size,
16		            item;
17
18		        for(var i = 0; i < numNodes; i++) {
19
20		            figureEl = thumbElements[i]; // <figure> element - JETZT IST ES EIN <LI> ELEMENT
21
22		            // include only element nodes 
23		            if(figureEl.nodeType !== 1) {
24		                continue;
25		            }
26
27		            linkEl = figureEl.children[0]; // <a> element
28
29		           // console.log(linkEl);
30
31		            size = linkEl.getAttribute('data-size').split('x');
32
33		            // create slide object
34		            item = {
35		                src: linkEl.getAttribute('href'),
36		                w: parseInt(size[0], 10),
37		                h: parseInt(size[1], 10)
38		            };
39
40
41
42		            if(figureEl.children.length > 1) {
43		                // <figcaption> content - JETZT IST ES EIN <span> ELEMENT
44		                item.title = figureEl.children[1].innerHTML; 
45		            }
46
47		            if(linkEl.children.length > 0) {
48		                // <img> thumbnail element, retrieving thumbnail url
49		                item.msrc = linkEl.children[0].getAttribute('src');
50		            } 
51
52		            item.el = figureEl; // save link to element for getThumbBoundsFn
53		            items.push(item);
54		        }
55
56		        return items;
57		    };
58
59		    // find nearest parent element
60		    var closest = function closest(el, fn) {
61		        return el && ( fn(el) ? el : closest(el.parentNode, fn) );
62		    };
63
64		    // triggers when user clicks on thumbnail
65		    var onThumbnailsClick = function(e) {
66		        e = e || window.event;
67		        e.preventDefault ? e.preventDefault() : e.returnValue = false;
68
69		        var eTarget = e.target || e.srcElement;
70
71		        // find root element of slide
72		        var clickedListItem = closest(eTarget, function(el) {
73		            return (el.tagName && el.tagName.toUpperCase() === 'LI'); // hier wrap eingeben, frueher <figure>
74		        });
75
76		        if(!clickedListItem) {
77		            return;
78		        }
79
80		        // find index of clicked item by looping through all child nodes
81		        // alternatively, you may define index via data- attribute
82		        var clickedGallery = clickedListItem.parentNode,
83		            childNodes = clickedListItem.parentNode.childNodes,
84		            numChildNodes = childNodes.length,
85		            nodeIndex = 0,
86		            index;
87
88		        for (var i = 0; i < numChildNodes; i++) {
89		            if(childNodes[i].nodeType !== 1) { 
90		                continue; 
91		            }
92
93		            if(childNodes[i] === clickedListItem) {
94		                index = nodeIndex;
95		                break;
96		            }
97		            nodeIndex++;
98		        }
99
100		        if(index >= 0) {
101		            // open PhotoSwipe if valid index found
102		            openPhotoSwipe( index, clickedGallery );
103		        }
104		        return false;
105		    };
106
107		    // parse picture index and gallery index from URL (#&pid=1&gid=2)
108		    var photoswipeParseHash = function() {
109		        var hash = window.location.hash.substring(1),
110		        params = {};
111
112		        if(hash.length < 5) {
113		            return params;
114		        }
115
116		        var vars = hash.split('&');
117		        for (var i = 0; i < vars.length; i++) {
118		            if(!vars[i]) {
119		                continue;
120		            }
121		            var pair = vars[i].split('=');  
122		            if(pair.length < 2) {
123		                continue;
124		            }           
125		            params[pair[0]] = pair[1];
126		        }
127
128		        if(params.gid) {
129		            params.gid = parseInt(params.gid, 10);
130		        }
131
132		        return params;
133		    };
134
135		    var openPhotoSwipe = function(index, galleryElement, disableAnimation, fromURL) {
136		        var pswpElement = document.querySelectorAll('.pswp')[0],
137		            gallery,
138		            options,
139		            items;
140
141		        items = parseThumbnailElements(galleryElement);
142
143		        // define options (if needed) - HIER OPTIONEN Definiren
144		        options = {
145		            // define gallery index (for URL)
146		            galleryUID: galleryElement.getAttribute('data-pswp-uid'),
147		            closeOnScroll: true,
148		            bgOpacity: 1,
149		            shareEl: false,
150					captionEl: true,
151					fullscreenEl: false,
152					history: false,
153					zoomEl: false,
154		            getThumbBoundsFn: function(index) {
155		                // See Options -> getThumbBoundsFn section of documentation for more info
156		                var thumbnail = items[index].el.getElementsByTagName('img')[0], // find thumbnail
157		                    pageYScroll = window.pageYOffset || document.documentElement.scrollTop,
158		                    rect = thumbnail.getBoundingClientRect(); 
159
160		                return {x:rect.left, y:rect.top + pageYScroll, w:rect.width};
161		            }
162
163		        };
164
165		        // PhotoSwipe opened from URL
166		        if(fromURL) {
167		            if(options.galleryPIDs) {
168		                // parse real index when custom PIDs are used 
169		                // http://photoswipe.com/documentation/faq.html#custom-pid-in-url
170		                for(var j = 0; j < items.length; j++) {
171		                    if(items[j].pid == index) {
172		                        options.index = j;
173		                        break;
174		                    }
175		                }
176		            } else {
177		                // in URL indexes start from 1
178		                options.index = parseInt(index, 10) - 1;
179		            }
180		        } else {
181		            options.index = parseInt(index, 10);
182		        }
183
184		        // exit if index not found
185		        if( isNaN(options.index) ) {
186		            return;
187		        }
188
189		        if(disableAnimation) {
190		            options.showAnimationDuration = 0;
191		        }
192
193		        // Pass data to PhotoSwipe and initialize it
194		        gallery = new PhotoSwipe( pswpElement, PhotoSwipeUI_Default, items, options);
195		        gallery.init();
196		    };
197
198		    // loop through all gallery elements and bind events
199		    var galleryElements = document.querySelectorAll( gallerySelector );
200
201		    for(var i = 0, l = galleryElements.length; i < l; i++) {
202		        galleryElements[i].setAttribute('data-pswp-uid', i+1);
203		        galleryElements[i].onclick = onThumbnailsClick;
204		    }
205
206		    // Parse URL and open gallery if it contains #&pid=3&gid=1
207		    var hashData = photoswipeParseHash();
208		    if(hashData.pid && hashData.gid) {
209		        openPhotoSwipe( hashData.pid ,  galleryElements[ hashData.gid - 1 ], true, true );
210		    }
211		};
212
213		// execute above function
214		initPhotoSwipeFromDOM('.my-gallery');
215
216	});
217});

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.