PageSourceSearch

https://marijuanastocks.com/wp-content/plugins/powerkit/modules/li…/js/public-powerkit-lightbox.js?ver=2.9.6

js marijuanastocks.com collected 2026-09-26 04:26:30 UTC 4,419 bytes, 169 lines download raw bytes

1/**
2 * Lightbox
3 */
4
5( function( $ ) {
6
7	$.fn.powerkitLightbox = function( options ) {
8
9		var settings = $.extend( {
10			gallery: false,
11		}, options );
12
13		var objSelector = this;
14		var imageSelector = null;
15		var containerSelector = null;
16		var initGallery = [];
17
18		$( objSelector ).each( function() {
19			var id = Math.random().toString( 36 ).substr( 2, 9 );
20
21			if ( $( this ).is( 'img' ) ) {
22				imageSelector = this;
23			} else {
24				imageSelector = $( this ).find( 'img' );
25			}
26
27			$( imageSelector ).each( function() {
28
29				var container = $( this ).parent();
30
31				if ( !$( container ).is( 'a' ) ) {
32					return;
33				}
34
35				var imagehref = $( container ).attr( 'href' );
36				if ( !imagehref.match( /\.(gif|jpeg|jpg|png|webp)/ ) ) {
37					return;
38				}
39
40				if ( !( $( container ).closest( 'figure' ).length ) ) {
41					$( container ).wrap( '<figure class="pk-lightbox-container"></figure>' );
42				}
43
44				if ( !$( container ).closest( 'figure' ).hasClass( 'pk-lightbox-container' ) ) {
45					$( container ).closest( 'figure' ).addClass( 'pk-lightbox-container' );
46				}
47
48				// Img classes.
49				var imgClasses = [ 'alignnone', 'aligncenter', 'alignleft', 'alignright' ];
50
51				imgClasses.forEach( function( el ) {
52					if ( $( container ).find( 'img' ).hasClass( el ) ) {
53						$( container ).find( 'img' ).removeClass( el );
54						$( container ).find( 'img' ).closest( 'figure' ).addClass( el );
55
56						// Add width to figure.
57						var imgWidth = $( container ).find( 'img' ).attr( 'width' );
58
59						if ( parseInt( imgWidth ) !== 'NaN' ) {
60							$( container ).find( 'img' ).closest( 'figure' ).width( imgWidth );
61						}
62					}
63				} );
64
65				container = $( container ).parent();
66
67				$( '> a', container ).not( '.pk-pin-it' ).addClass( 'pk-image-popup' );
68
69				if ( powerkit_lightbox_localize.zoom_icon ) {
70					$( '> a', container ).not( '.pk-pin-it' ).addClass( 'pk-zoom-icon-popup' );
71				}
72
73				if ( $( objSelector ).is( 'img' ) ) {
74					containerSelector = container;
75				}
76
77			} );
78
79			if ( !$( objSelector ).is( 'img' ) ) {
80				containerSelector = this;
81			}
82
83			if ( $( containerSelector ).is( '[data-pk-uuid]' ) ) {
84				return;
85			}
86
87			$( containerSelector ).attr( 'data-pk-uuid', id );
88
89			initGallery[ id ] = GLightbox( {
90				loop: settings.gallery,
91				touchNavigation: true,
92				autoplayVideos: true,
93				selector: `[data-pk-uuid="${id}"] .pk-image-popup`,
94			} );
95
96			initGallery[ id ].on( 'slide_before_load', ( data ) => {
97				const { slideIndex, slideNode, slideConfig, player, trigger } = data;
98
99				let figure = $( trigger ).closest( 'figure' );
100
101				let description = $( figure ).find( 'img' ).data( 'lightbox-description' ) || '';
102
103				if ( !description ) {
104					description = $( figure ).find( '.wp-caption-text' ).text();
105				}
106
107				if ( !description ) {
108					description = $( figure ).find( 'figcaption' ).text();
109				}
110
111				if ( description ) {
112					slideConfig.title = description;
113				}
114			} );
115		} );
116	};
117
118
119	function initPowerkitLightbox() {
120		var excludeSelectors = powerkit_lightbox_localize.exclude_selectors;
121		var imageSelectors = powerkit_lightbox_localize.single_image_selectors;
122		var gallerySelectors = powerkit_lightbox_localize.gallery_selectors
123
124		// Exclude.
125		var filterSelectors = null;
126
127		var filterPowerkitLightbox = function() {
128			if ( filterSelectors ) {
129				if ( $( this ).closest( filterSelectors ).length > 0 ) {
130					return false;
131				}
132			}
133			return true;
134		}
135
136		// Single Init -----------------------------------
137		$( imageSelectors ).imagesLoaded( function() {
138			var exSplit = excludeSelectors.split( ',' );
139			var glSplit = gallerySelectors.split( ',' );
140
141			// Join exclude selectors.
142			filterSelectors = exSplit.concat( glSplit ).filter( function( value ) {
143				return !!value;
144			} ).filter( function( value ) {
145				return !this[ value ] && ( this[ value ] = true );
146			}, Object.create( null ) ).join( ',' );
147
148			// Init.
149			$( imageSelectors ).filter( filterPowerkitLightbox ).powerkitLightbox();
150		} );
151
152		// Gallery Init -----------------------------------
153		$( gallerySelectors ).imagesLoaded( function() {
154			filterSelectors = excludeSelectors;
155
156			// Init.
157			$( gallerySelectors ).filter( filterPowerkitLightbox ).powerkitLightbox( { gallery: true } );
158		} );
159	}
160
161	$( document ).ready( function() {
162		initPowerkitLightbox();
163
164		$( document.body ).on( 'post-load image-load', function() {
165			initPowerkitLightbox();
166		} );
167	} );
168
169} )( 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.