PageSourceSearch

https://irbarcelona.cat/wp-content/plugins/responsive-lightbox/js/front.js?ver=2.4.8

js irbarcelona.cat collected 2026-10-02 22:04:45 UTC 27,235 bytes, 869 lines download raw bytes

1( function( $ ) {
2
3	// parse query string
4	var parseQueryString = function( name, str ) {
5		var regex = new RegExp( '[?&]' + name.replace( /[\[\]]/g, '\\$&' ) + '(=([^&#]*)|&|#|$)' );
6		var results = regex.exec( '&' + str );
7
8		return ( ! results || ! results[2] ? '' : decodeURIComponent( results[2].replace( /\+/g, ' ' ) ) );
9	}
10
11	// observe DOM changes
12	var observeContentChanges = function( el, onlyAdded, callback ) {
13		if ( typeof MutationObserver !== 'undefined' ) {
14			// define a new observer
15			var observer = new MutationObserver( function( mutations, observer ) {
16				if ( onlyAdded ) {
17					if ( mutations[0].addedNodes.length )
18						callback();
19				} else {
20					if ( mutations[0].addedNodes.length || mutations[0].removedNodes.length )
21						callback();
22				}
23			} );
24
25			// have the observer observe for changes in children
26			observer.observe( el, { childList: true, subtree: true } );
27		}
28	};
29
30	// ready event
31	$( function() {
32		initPlugin();
33	} );
34
35	// custom events trigger
36	$( document ).on( rlArgs.customEvents, function() {
37		initPlugin();
38	} );
39
40	function initPlugin() {
41		var containers = [];
42
43		// check for infinite galleries
44		$( '.rl-gallery-container' ).each( function() {
45			var container = $( this );
46
47			// is it ifinite scroll gallery?
48			if ( container.hasClass( 'rl-pagination-infinite' ) )
49				containers.push( container );
50			// remove loading class
51			else
52				container.removeClass( 'rl-loading' );
53		} );
54
55		// any infinite galleries?
56		if ( containers.length > 0 ) {
57			var infArgs = [];
58
59			for ( var i = 0; i < containers.length; i++ ) {
60				var container = containers[i];
61				var gallery = container.find( '.rl-gallery' );
62				var galleryId = parseInt( container.data( 'gallery_id' ) );
63				var galleryScrollType = container.find( '.rl-pagination-bottom' ).data( 'button' );
64				var galleryButton = typeof galleryScrollType !== 'undefined' && galleryScrollType === 'manually';
65
66				infArgs[i] = {
67					container: container,
68					gallery: gallery,
69					galleryId: galleryId,
70					galleryButton: galleryButton
71				};
72
73				// initialize infinite scroll
74				infArgs[i].gallery.infiniteScroll( {
75					path: '.rl-gallery-container[data-gallery_id="' + infArgs[i].galleryId + '"] .rl-pagination-bottom .next',
76					append: '.rl-gallery-container[data-gallery_id="' + infArgs[i].galleryId + '"] .rl-gallery-item',
77					status: false,
78					hideNav: '.rl-gallery-container[data-gallery_id="' + infArgs[i].galleryId + '"] .rl-pagination-bottom',
79					prefill: ! infArgs[i].galleryButton,
80					loadOnScroll: true,
81					scrollThreshold: infArgs[i].galleryButton ? false : 400,
82					button: infArgs[i].galleryButton ? '.rl-gallery-container[data-gallery_id="' + infArgs[i].galleryId + '"] .rl-load-more' : false,
83					debug: false,
84					history: false,
85					responseBody: 'text',
86					onInit: function() {
87						// get current arguments
88						var args = infArgs[i];
89
90						// infinite with button?
91						if ( args.container.hasClass( 'rl-pagination-infinite' ) && args.galleryButton ) {
92							// remove loading class
93							args.container.removeClass( 'rl-loading' );
94						}
95
96						// request event
97						this.on( 'request', function() {
98							// add loading class
99							args.container.addClass( 'rl-loading' );
100						} );
101
102						// append event
103						this.on( 'append', function( body, path, items, response ) {
104							// remove loading class
105							args.container.removeClass( 'rl-loading' );
106
107							$.event.trigger( {
108								type: 'doResponsiveLightbox',
109								script: rlArgs.script,
110								selector: rlArgs.selector,
111								args: rlArgs,
112								pagination_type: 'infinite',
113								gallery_id: args.galleryId,
114								masonry: args.gallery.hasClass( 'rl-masonry-gallery' ) || args.gallery.hasClass( 'rl-basicmasonry-gallery' ),
115								delayLightbox: args.gallery.hasClass( 'rl-expander-gallery' ),
116								infinite: {
117									gallery: args.gallery,
118									body: body,
119									items: items,
120									response: response
121								}
122							} );
123						} );
124					}
125				} );
126			}
127		}
128
129		// initialize event
130		$.event.trigger( {
131			type: 'doResponsiveLightbox',
132			script: rlArgs.script,
133			selector: rlArgs.selector,
134			args: rlArgs
135		} );
136	}
137
138	// pagination
139	$( document ).on( 'click', '.rl-pagination a.page-numbers', function( e ) {
140		var link = $( this );
141		var container = link.closest( '.rl-gallery-container' );
142
143		// ajax type pagination?
144		if ( container.hasClass( 'rl-pagination-ajax' ) ) {
145			e.preventDefault();
146			e.stopPropagation();
147
148			var galleryId = container.data( 'gallery_id' );
149			var galleryNo = container.find( '.rl-gallery' ).data( 'gallery_no' );
150
151			// add loading class
152			container.addClass( 'rl-loading' );
153
154			$.post( rlArgs.ajaxurl, {
155				action: 'rl-get-gallery-page-content',
156				gallery_id: galleryId,
157				gallery_no: galleryNo,
158				post_id: rlArgs.postId,
159				page: parseQueryString( 'rl_page', link.prop( 'href' ) ),
160				nonce: rlArgs.nonce,
161				preview: rlArgs.preview ? 'true' : 'false',
162				lightbox: rlArgs.script
163			} ).done( function( response ) {
164				// replace container with new content
165				container.replaceWith( $( response ).removeClass( 'rl-loading' ) );
166
167				// trigger main event
168				$.event.trigger( {
169					type: 'doResponsiveLightbox',
170					script: rlArgs.script,
171					selector: rlArgs.selector,
172					args: rlArgs,
173					pagination_type: 'ajax',
174					gallery_id: galleryId,
175					gallery_no: galleryNo
176				} );
177			} ).always( function() {
178				container.removeClass( 'rl-loading' );
179			} );
180
181			return false;
182		}
183	} );
184
185	// this is similar to the WP function add_action();
186	$( document ).on( 'doResponsiveLightbox', function( event ) {
187		if ( typeof event.masonry !== 'undefined' && event.masonry === true )
188			return false;
189
190		var script = event.script;
191		var selector = event.selector;
192
193		if ( typeof script === 'undefined' || typeof selector === 'undefined' )
194			return false;
195
196		var args = event.args;
197		var delayLightbox = false;
198
199		if ( typeof event.delayLightbox !== 'undefined' && event.delayLightbox === true )
200			delayLightbox = true;
201
202		rl_view_image = function( script, url ) {
203			$.event.trigger( {
204				type: 'doLightboxViewImage',
205				script: script,
206				url: url
207			} );
208		}
209
210		rl_hide_image = function( script, url ) {
211			$.event.trigger( {
212				type: 'doLightboxHideImage',
213				script: script,
214				url: url
215			} );
216		}
217
218		// WooCommerce 3.0+ compatibility
219		setTimeout( function() {
220			var flex = $( '.flex-viewport' );
221
222			if ( args.woocommerce_gallery ) {
223				var gallery = $( '.woocommerce-product-gallery' );
224
225				if ( gallery.find( '.woocommerce-product-gallery__trigger' ).length === 0 ) {
226					gallery.prepend( '<a href="#" class="woocommerce-product-gallery__trigger">🔍</a>' );
227
228					gallery.on( 'click', '.woocommerce-product-gallery__trigger', function( e ) {
229						e.preventDefault();
230						e.stopPropagation();
231
232						if ( script === 'lightgallery' ) {
233							if ( flex.length ) {
234								var image = flex.find( '.flex-active-slide a[data-rel] img' );
235								var linkId = flex.find( '.flex-active-slide a[data-rel]' ).data( 'lg-id' );
236
237								image.trigger( 'click.lgcustom-item-' + linkId );
238							} else {
239								var link = gallery.find( 'a[data-rel]' ).first();
240								var image = link.find( 'img' );
241
242								image.trigger( 'click.lgcustom-item-' + link.data( 'lg-id' ) );
243							}
244						} else if ( script === 'fancybox_pro' ) {
245							if ( flex.length ) {
246								var index = flex.find( '.flex-active-slide' ).index();
247								var imageId = flex.find( '.flex-active-slide a[data-rel]' ).data( 'fancybox' );
248
249								Fancybox.fromOpener( '[data-fancybox="' + imageId + '"]', {
250									startIndex: index
251								} );
252							} else {
253								var link = gallery.find( 'a[data-rel]' ).first();
254
255								Fancybox.fromOpener( '[data-fancybox="' + link.data( 'fancybox' ) + '"]', {
256									startIndex: 0
257								} );
258							}
259						} else {
260							if ( flex.length )
261								flex.find( '.flex-active-slide a[data-rel]' ).trigger( 'click' );
262							else
263								gallery.find( 'a[data-rel]' ).first().trigger( 'click' );
264						}
265					} );
266				}
267			}
268		}, 10 );
269
270		if ( delayLightbox ) {
271			setTimeout( function() {
272				initLightbox( event );
273			}, 0 );
274		} else
275			initLightbox( event );
276	} );
277
278	/**
279	 * Initialize lightbox script.
280	 */
281	function initLightbox( event ) {
282		var script = event.script;
283		var selector = event.selector;
284		var args = event.args;
285
286		switch ( script ) {
287			case 'swipebox':
288				var slide = $( '#swipebox-overlay' ).find( '.slide.current' );
289				var imageSource = '';
290				var allowHide = false;
291				var closeExecuted = false;
292
293				$( 'a[rel*="' + selector + '"], a[data-rel*="' + selector + '"]' ).swipebox( {
294					useCSS: args.animation,
295					useSVG: args.useSVG,
296					hideCloseButtonOnMobile: args.hideCloseButtonOnMobile,
297					removeBarsOnMobile: args.removeBarsOnMobile,
298					hideBarsDelay: args.hideBars ? parseInt( args.hideBarsDelay ) : 0,
299					videoMaxWidth: parseInt( args.videoMaxWidth ),
300					loopAtEnd: args.loopAtEnd,
301					afterOpen: function() {
302						closeExecuted = false;
303
304						// update current slide container
305						slide = $( '#swipebox-overlay' ).find( '.slide.current' );
306
307						// get image source
308						var image = slide.find( 'img' ).attr( 'src' );
309
310						// valid image source?
311						if ( typeof image !== 'undefined' ) {
312							imageSource = image;
313
314							// trigger image view
315							rl_view_image( script, imageSource );
316						} else
317							imageSource = '';
318
319						// add current slide observer
320						observeContentChanges( document.getElementById( 'swipebox-slider' ), false, function() {
321							if ( imageSource === '' ) {
322								// get image source
323								var image = slide.find( 'img' ).attr( 'src' );
324
325								// valid image source?
326								if ( typeof image !== 'undefined' ) {
327									imageSource = image;
328
329									// trigger image view
330									rl_view_image( script, imageSource );
331								} else
332									imageSource = '';
333							}
334						} );
335					},
336					nextSlide: function() {
337						// update current slide container
338						slide = $( '#swipebox-overlay' ).find( '.slide.current' );
339
340						// get image source
341						var image = slide.find( 'img' ).attr( 'src' );
342
343						// valid image source?
344						if ( typeof image !== 'undefined' ) {
345							imageSource = image;
346
347							// trigger image view
348							rl_view_image( script, imageSource );
349						} else
350							imageSource = '';
351					},
352					prevSlide: function() {
353						// update current slide container
354						slide = $( '#swipebox-overlay' ).find( '.slide.current' );
355
356						// get image source
357						var image = slide.find( 'img' ).attr( 'src' );
358
359						// valid image source?
360						if ( typeof image !== 'undefined' ) {
361							imageSource = image;
362
363							// trigger image view
364							rl_view_image( script, imageSource );
365						} else
366							imageSource = '';
367					},
368					afterClose: function() {
369						// afterClose event executed
370						closeExecuted = true;
371
372						// allow to hide image?
373						if ( allowHide ) {
374							// trigger image hide
375							rl_hide_image( script, imageSource );
376
377							allowHide = false;
378						}
379					}
380				} );
381
382				// additional event to prevent rl_hide_image to execure while opening modal
383				$( window ).on( 'resize', function() {
384					if ( ! closeExecuted ) {
385						allowHide = true;
386					}
387				} );
388				break;
389
390			case 'prettyphoto':
391				var viewDisabled = false;
392				var lastImage = '';
393
394				$( 'a[rel*="' + selector + '"], a[data-rel*="' + selector + '"]' ).each( function() {
395					var el = $( this );
396					var title = el.data( 'rl_title' );
397					var caption = el.data( 'rl_caption' );
398
399					if ( ! title )
400						title = '';
401
402					if ( ! caption )
403						caption = '';
404
405					// set description
406					el.attr( 'title', caption );
407
408					// set title
409					el.find( 'img' ).attr( 'alt', title );
410				} );
411
412				$( 'a[rel*="' + selector + '"], a[data-rel*="' + selector + '"]' ).prettyPhoto( {
413					hook: 'data-rel',
414					animation_speed: args.animationSpeed,
415					slideshow: args.slideshow ? parseInt( args.slideshowDelay ) : false,
416					autoplay_slideshow: args.slideshowAutoplay,
417					opacity: args.opacity,
418					show_title: args.showTitle,
419					allow_resize: args.allowResize,
420					allow_expand: args.allowExpand,
421					default_width: parseInt( args.width ),
422					default_height: parseInt( args.height ),
423					counter_separator_label: args.separator,
424					theme: args.theme,
425					horizontal_padding: parseInt( args.horizontalPadding ),
426					hideflash: args.hideFlash,
427					wmode: args.wmode,
428					autoplay: args.videoAutoplay,
429					modal: args.modal,
430					deeplinking: args.deeplinking,
431					overlay_gallery: args.overlayGallery,
432					keyboard_shortcuts: args.keyboardShortcuts,
433					social_tools: args.social ? '<div class="pp_social"><div class="twitter"><a href="//twitter.com/share" class="twitter-share-button" data-count="none">Tweet</a><script type="text/javascript" src="//platform.twitter.com/widgets.js"></script></div><div class="facebook"><iframe src="//www.facebook.com/plugins/like.php?locale=en_US&href=' + location.href + '&amp;layout=button_count&amp;show_faces=true&amp;width=500&amp;action=like&amp;font&amp;colorscheme=light&amp;height=23" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:500px; height:23px;" allowTransparency="true"></iframe></div></div>' : '',
434					ie6_fallback: true,
435					changepicturecallback: function() {
436						// is view disabled?
437						if ( viewDisabled ) {
438							// enable view
439							viewDisabled = false;
440
441							return;
442						}
443
444						lastImage = $( '#pp_full_res' ).find( 'img' ).attr( 'src' );
445
446						// trigger image view
447						rl_view_image( script, lastImage );
448
449						// is expanding allowed?
450						if ( args.allowExpand ) {
451							// disable changepicturecallback event after expanding
452							$( 'a.pp_expand' ).on( 'click', function() {
453								viewDisabled = true;
454							} );
455						}
456					},
457					callback: function() {
458						// trigger image hide
459						rl_hide_image( script, lastImage );
460					}
461				} );
462				break;
463
464			case 'nivo':
465				$.each( $( 'a[rel*="' + selector + '"], a[data-rel*="' + selector + '"]' ), function() {
466					var attr = $( this ).attr( 'data-rel' );
467
468					// check data-rel attribute first
469					if ( typeof attr === 'undefined' || attr == false ) {
470						// if not found then try to check rel attribute for backward compatibility
471						attr = $( this ).attr( 'rel' );
472					}
473
474					// for some browsers, `attr` is undefined; for others, `attr` is false. Check for both.
475					if ( typeof attr !== 'undefined' && attr !== false ) {
476						var match = attr.match( new RegExp( selector + '\\-(gallery\\-(?:[\\da-z]{1,4}))', 'ig' ) );
477
478						if ( match !== null )
479							$( this ).attr( 'data-lightbox-gallery', match[0] );
480					}
481				} );
482
483				var observerInitialized = false;
484				var changeAllowed = true;
485				var lastImage = '';
486
487				$( 'a[rel*="' + selector + '"], a[data-rel*="' + selector + '"]' ).nivoLightbox( {
488					effect: args.effect,
489					clickOverlayToClose: args.clickOverlayToClose,
490					keyboardNav: args.keyboardNav,
491					errorMessage: args.errorMessage,
492					afterShowLightbox: function( lightbox ) {
493						var content = $( lightbox )[0].find( '.nivo-lightbox-content' );
494
495						// is observer initialized?
496						if ( ! observerInitialized ) {
497							// turn it off
498							observerInitialized = true;
499
500							// add content observer
501							observeContentChanges( document.getElementsByClassName( 'nivo-lightbox-content' )[0], true, function() {
502								if ( changeAllowed ) {
503									lastImage = content.find( '.nivo-lightbox-image img' ).attr( 'src' );
504
505									// trigger image view
506									rl_view_image( script, lastImage );
507
508									// disallow observer changes
509									changeAllowed = false;
510								}
511							} );
512						}
513					},
514					afterHideLightbox: function() {
515						// allow observer changes
516						changeAllowed = true;
517
518						// trigger image hide
519						rl_hide_image( script, lastImage );
520					},
521					onPrev: function( element ) {
522						// disallow observer changes
523						changeAllowed = false;
524
525						lastImage = element[0].attr( 'href' );
526
527						// trigger image view
528						rl_view_image( script, lastImage );
529					},
530					onNext: function( element ) {
531						// disallow observer changes
532						changeAllowed = false;
533
534						lastImage = element[0].attr( 'href' );
535
536						// trigger image view
537						rl_view_image( script, lastImage );
538					}
539				} );
540				break;
541
542			case 'imagelightbox':
543				var selectors = [];
544				var lastImage = '';
545
546				$( 'a[rel*="' + selector + '"], a[data-rel*="' + selector + '"]' ).each( function( i, item ) {
547					var attr = $( item ).attr( 'data-rel' );
548
549					// check data-rel attribute first
550					if ( typeof attr !== 'undefined' && attr !== false && attr !== 'norl' )
551						selectors.push( attr );
552					// if not found then try to check rel attribute for backward compatibility
553					else {
554						attr = $( item ).attr( 'rel' );
555
556						if ( typeof attr !== 'undefined' && attr !== false && attr !== 'norl' )
557							selectors.push( attr );
558					}
559				} );
560
561				if ( selectors.length > 0 ) {
562					// make unique
563					selectors = _.uniq( selectors );
564
565					$( selectors ).each( function( i, item ) {
566						if ( typeof event.pagination_type !== 'undefined' ) {
567							$( 'a[data-rel="' + item + '"], a[rel="' + item + '"]' ).each( function() {
568								$( this ).off( 'click.imageLightbox' );
569							} );
570						}
571
572						$( 'a[data-rel="' + item + '"], a[rel="' + item + '"]' ).imageLightbox( {
573							animationSpeed: parseInt( args.animationSpeed ),
574							preloadNext: args.preloadNext,
575							enableKeyboard: args.enableKeyboard,
576							quitOnEnd: args.quitOnEnd,
577							quitOnImgClick: args.quitOnImageClick,
578							quitOnDocClick: args.quitOnDocumentClick,
579							onLoadEnd: function() {
580								lastImage = $( '#imagelightbox' ).attr( 'src' );
581
582								// trigger image view
583								rl_view_image( script, lastImage );
584							},
585							onEnd: function() {
586								// trigger image hide
587								rl_hide_image( script, lastImage );
588							}
589						} );
590					} );
591				}
592				break;
593
594			case 'tosrus':
595				var selectors = [];
596				var lastImage = '';
597
598				$( 'a[rel*="' + selector + '"], a[data-rel*="' + selector + '"]' ).each( function( i, item ) {
599					var attr = $( item ).attr( 'data-rel' );
600
601					// check data-rel attribute first
602					if ( typeof attr !== 'undefined' && attr !== false && attr !== 'norl' )
603						selectors.push( attr );
604					// if not found then try to check rel attribute for backward compatibility
605					else {
606						attr = $( item ).attr( 'rel' );
607
608						if ( typeof attr !== 'undefined' && attr !== false && attr !== 'norl' )
609							selectors.push( attr );
610					}
611				} );
612
613				if ( selectors.length > 0 ) {
614					// make unique
615					selectors = _.uniq( selectors );
616
617					$( selectors ).each( function( i, item ) {
618						if ( typeof event.pagination_type !== 'undefined' ) {
619							$( 'body' ).find( '.tosrus-' + item ).remove();
620
621							$( 'a[data-rel="' + item + '"], a[rel="' + item + '"]' ).each( function() {
622								$( this ).off( 'click.tos' );
623							} );
624						}
625
626						var tos = $( 'a[data-rel="' + item + '"], a[rel="' + item + '"]' ).tosrus( {
627							infinite: args.infinite,
628							autoplay: {
629								play: args.autoplay,
630								pauseOnHover: args.pauseOnHover,
631								timeout: args.timeout
632							},
633							effect: args.effect,
634							keys: {
635								prev: args.keys,
636								next: args.keys,
637								close: args.keys
638							},
639							pagination: {
640								add: args.pagination,
641								type: args.paginationType
642							},
643							// forced
644							show: false,
645							buttons: true,
646							caption: {
647								add: true,
648								attributes: [ "title" ]
649							},
650							wrapper: {
651								classes: 'tosrus-' + item,
652								onClick: args.closeOnClick ? 'close' : 'toggleUI'
653							}
654						} );
655
656						tos.on( 'sliding.tos', function( event, number ) {
657							lastImage = $( $( event.target ).find( '.tos-slider .tos-slide' )[number] ).find( 'img' ).attr( 'src' );
658
659							// trigger image view
660							rl_view_image( script, lastImage );
661						} );
662
663						tos.on( 'closing.tos', function() {
664							// trigger image hide
665							rl_hide_image( script, lastImage );
666						} );
667					} );
668				}
669				break;
670
671			case 'featherlight':
672				delete $.featherlight.contentFilters.jquery;
673
674				$.extend( $.featherlight.contentFilters, {
675					html: {
676						regex: /[^]/, // it will also handle jquery and any unspecified content type
677						process: function( html ) {
678							return $( '<div>', { text: html } );
679						}
680					}
681				} );
682
683				var selectors = [];
684				var lastImage = '';
685
686				$( 'a[rel*="' + selector + '"], a[data-rel*="' + selector + '"]' ).each( function( i, item ) {
687					var attr = $( item ).attr( 'data-rel' );
688
689					// check data-rel attribute first
690					if ( typeof attr !== 'undefined' && attr !== false && attr !== 'norl' )
691						selectors.push( attr );
692					// if not found then try to check rel attribute for backward compatibility
693					else {
694						attr = $( item ).attr( 'rel' );
695
696						if ( typeof attr !== 'undefined' && attr !== false && attr !== 'norl' )
697							selectors.push( attr );
698					}
699				} );
700
701				if ( selectors.length > 0 ) {
702					// make unique
703					selectors = _.uniq( selectors );
704
705					// set defaults
706					$.extend( $.featherlight.defaults, {
707						contentFilters: ['image', 'html', 'ajax', 'iframe', 'text'],
708						openSpeed: parseInt( args.openSpeed ),
709						closeSpeed: parseInt( args.closeSpeed ),
710						closeOnClick: args.closeOnClick,
711						closeOnEsc: args.closeOnEsc,
712						afterOpen: function( event ) {
713							lastImage = event.currentTarget.href;
714
715							// trigger image view
716							rl_view_image( script, lastImage );
717						},
718						afterClose: function() {
719							// trigger image hide
720							rl_hide_image( script, lastImage );
721						}
722					} );
723
724					$( selectors ).each( function( i, item ) {
725						if ( typeof event.pagination_type !== 'undefined' ) {
726							$( 'a[data-rel="' + item + '"], a[rel="' + item + '"]' ).each( function() {
727								$( this ).off( 'click.featherlight' );
728							} );
729						}
730
731						// gallery?
732						if ( /-gallery-/.test( item ) ) {
733							$( 'a[data-rel="' + item + '"], a[rel="' + item + '"]' ).featherlightGallery( {
734								galleryFadeIn: parseInt( args.galleryFadeIn ),
735								galleryFadeOut: parseInt( args.galleryFadeOut ),
736								previousIcon: '&#10094;',
737								nextIcon: '&#10095;'
738							} );
739						// video?
740						} else if ( /-video-/.test( item ) ) {
741							$( 'a[data-rel="' + item + '"], a[rel="' + item + '"]' ).featherlight();
742						// single image?
743						} else {
744							$( 'a[data-rel="' + item + '"], a[rel="' + item + '"]' ).featherlight();
745						}
746					} );
747				}
748				break;
749
750			case 'magnific':
751				var selectors = [];
752				var lastImage = '';
753
754				$( 'a[rel*="' + selector + '"], a[data-rel*="' + selector + '"]' ).each( function( i, item ) {
755					var attr = $( item ).attr( 'data-rel' );
756
757					// check data-rel attribute first
758					if ( typeof attr !== 'undefined' && attr !== false && attr !== 'norl' )
759						selectors.push( attr );
760					// if not found then try to check rel attribute for backward compatibility
761					else {
762						attr = $( item ).attr( 'rel' );
763
764						if ( typeof attr !== 'undefined' && attr !== false && attr !== 'norl' )
765							selectors.push( attr );
766					}
767				} );
768
769				if ( selectors.length > 0 ) {
770					// make unique
771					selectors = _.uniq( selectors );
772
773					$( selectors ).each( function( i, item ) {
774						var subselector = $( 'a[data-rel="' + item + '"], a[rel="' + item + '"]' );
775						var element = $( subselector[0] );
776						var media_type = element.data( 'magnific_type' );
777						var content_type = element.data( 'rl_content' );
778
779						// check content type first
780						if ( typeof content_type !== 'undefined' )
781							media_type = content_type;
782
783						// then media type if needed
784						if ( typeof media_type === 'undefined' )
785							media_type = 'image';
786
787						var fixedContentPos = 'auto';
788						var fixedBgPos = 'auto';
789
790						if ( args.fixedContentPos === 'true' )
791							fixedContentPos = true;
792						else if ( args.fixedContentPos === 'false' )
793							fixedContentPos = false;
794
795						if ( args.fixedBgPos === 'true' )
796							fixedBgPos = true;
797						else if ( args.fixedBgPos === 'false' )
798							fixedBgPos = false;
799
800						subselector.magnificPopup( {
801							allowHTMLInStatusIndicator: false,
802							allowHTMLInTemplate: true,
803							type: media_type === 'gallery' ? 'image' : ( media_type === 'video' ? 'iframe' : media_type ),
804							disableOn: args.disableOn,
805							midClick: args.midClick,
806							preloader: args.preloader,
807							closeOnContentClick: args.closeOnContentClick,
808							closeOnBgClick: args.closeOnBgClick,
809							closeBtnInside: args.closeBtnInside,
810							showCloseBtn: args.showCloseBtn,
811							enableEscapeKey: args.enableEscapeKey,
812							alignTop: args.alignTop,
813							autoFocusLast: args.autoFocusLast,
814							fixedContentPos: fixedContentPos,
815							fixedBgPos: fixedBgPos,
816							image: {
817								titleSrc: function( item ) {
818									var title = item.el.data( 'rl_title' );
819									var caption = item.el.data( 'rl_caption' );
820
821									if ( ! title )
822										title = '';
823									else {
824										title = title.replace( /[^]/g, function( c ) {
825											return '&#' + c.charCodeAt( 0 ) + ';';
826										} );
827									}
828
829									if ( ! caption )
830										caption = '';
831									else {
832										caption = caption.replace( /[^]/g, function( c ) {
833											return '&#' + c.charCodeAt( 0 ) + ';';
834										} );
835									}
836
837									return title + '<small>' + caption + '</small>';
838								}
839							},
840							gallery: {
841								enabled: subselector.length > 1 && media_type === 'gallery',
842								navigateByImgClick: true,
843								preload: [0,1]
844							},
845							callbacks: {
846								close: function() {
847									rl_hide_image( script, this.currItem.src );
848								},
849								imageLoadComplete: function() {
850									// trigger image view
851									rl_view_image( script, this.currItem.src );
852								},
853								elementParse: function( item ) {
854									if ( item.src.trim().includes( '<' ) ) {
855										if ( item.type === 'inline' )
856											item.src = '<div>HTML is disallowed.</div>';
857										else if ( item.type === 'iframe' || item.type === 'ajax' )
858											item.src = '';
859									}
860								}
861							}
862						} );
863					} );
864				}
865				break;
866		}
867	}
868
869} )( 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.