PluginProbe ʕ •ᴥ•ʔ
Responsive Lightbox & Gallery / 2.4.0
Responsive Lightbox & Gallery v2.4.0
2.7.8 trunk 1.0.0 1.0.1 1.0.1.1 1.0.2 1.0.3 1.0.4 1.1.0 1.1.1 1.1.2 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.4.0 1.4.0.1 1.4.1 1.4.11 1.4.12 1.4.13 1.4.14 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.6.0 1.6.1 1.6.10 1.6.11 1.6.12 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 2.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.1 2.2.0 2.2.1 2.2.2 2.2.3 2.2.3.1 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.6.0 2.6.1 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7
responsive-lightbox / js / front.js
responsive-lightbox / js Last commit date
admin-folders.js 4 years ago admin-galleries.js 4 years ago admin-gallery.js 4 years ago admin-media.js 5 years ago admin-plugins.js 5 years ago admin-widgets.js 5 years ago admin.js 5 years ago front-basicmasonry.js 4 years ago front-basicslider.js 4 years ago front.js 4 years ago gutenberg.min.js 4 years ago
front.js
792 lines
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 for ( var i = 0; i < containers.length; i++ ) {
58 var container = containers[i];
59 var gallery = container.find( '.rl-gallery' );
60 var galleryId = parseInt( container.data( 'gallery_id' ) );
61 var galleryScrollType = container.find( '.rl-pagination-bottom' ).data( 'button' );
62 var galleryButton = typeof galleryScrollType !== 'undefined' && galleryScrollType === 'manually';
63
64 // initialize infinite scroll
65 gallery.infiniteScroll( {
66 path: '.rl-gallery-container[data-gallery_id="' + galleryId + '"] .rl-pagination-bottom .next',
67 append: '.rl-gallery-container[data-gallery_id="' + galleryId + '"] .rl-gallery-item',
68 status: false,
69 hideNav: '.rl-gallery-container[data-gallery_id="' + galleryId + '"] .rl-pagination-bottom',
70 prefill: ! galleryButton,
71 loadOnScroll: true,
72 scrollThreshold: galleryButton ? false : 400,
73 button: galleryButton ? '.rl-gallery-container[data-gallery_id="' + galleryId + '"] .rl-load-more' : false,
74 debug: true,
75 history: false,
76 responseBody: 'text',
77 onInit: function() {
78 // infinite with button?
79 if ( container.hasClass( 'rl-pagination-infinite' ) && galleryButton ) {
80 // remove loading class
81 container.removeClass( 'rl-loading' );
82 }
83
84 // store gallery ID for append event
85 var _galleryId = galleryId;
86
87 // request event
88 this.on( 'request', function() {
89 // add loading class
90 container.addClass( 'rl-loading' );
91 } );
92
93 // append event
94 this.on( 'append', function( body, path, items, response ) {
95 // remove loading class
96 container.removeClass( 'rl-loading' );
97
98 $.event.trigger( {
99 type: 'doResponsiveLightbox',
100 script: rlArgs.script,
101 selector: rlArgs.selector,
102 args: rlArgs,
103 pagination_type: 'infinite',
104 gallery_id: _galleryId,
105 masonry: gallery.hasClass( 'rl-masonry-gallery' ) || gallery.hasClass( 'rl-basicmasonry-gallery' ),
106 infinite: {
107 gallery: gallery,
108 body: body,
109 items: items,
110 response: response
111 }
112 } );
113 } );
114 }
115 } );
116 }
117 }
118
119 // initialize event
120 $.event.trigger( {
121 type: 'doResponsiveLightbox',
122 script: rlArgs.script,
123 selector: rlArgs.selector,
124 args: rlArgs
125 } );
126 }
127
128 // pagination
129 $( document ).on( 'click', '.rl-pagination a.page-numbers', function( e ) {
130 var link = $( this );
131 var container = link.closest( '.rl-gallery-container' );
132
133 // ajax type pagination?
134 if ( container.hasClass( 'rl-pagination-ajax' ) ) {
135 e.preventDefault();
136 e.stopPropagation();
137
138 var galleryId = container.data( 'gallery_id' );
139 var galleryNo = container.find( '.rl-gallery' ).data( 'gallery_no' );
140
141 // add loading class
142 container.addClass( 'rl-loading' );
143
144 $.post( rlArgs.ajaxurl, {
145 action: 'rl-get-gallery-page-content',
146 gallery_id: galleryId,
147 gallery_no: galleryNo,
148 post_id: rlArgs.postId,
149 page: parseQueryString( 'rl_page', link.prop( 'href' ) ),
150 nonce: rlArgs.nonce,
151 preview: rlArgs.preview
152 } ).done( function( response ) {
153 // replace container with new content
154 container.replaceWith( $( response ).removeClass( 'rl-loading' ) );
155
156 // trigger main event
157 $.event.trigger( {
158 type: 'doResponsiveLightbox',
159 script: rlArgs.script,
160 selector: rlArgs.selector,
161 args: rlArgs,
162 pagination_type: 'ajax',
163 gallery_id: galleryId,
164 gallery_no: galleryNo
165 } );
166 } ).always( function() {
167 container.removeClass( 'rl-loading' );
168 } );
169
170 return false;
171 }
172 } );
173
174 // this is similar to the WP function add_action();
175 $( document ).on( 'doResponsiveLightbox', function( event ) {
176 if ( typeof event.masonry !== 'undefined' && event.masonry === true )
177 return false;
178
179 var script = event.script;
180 var selector = event.selector;
181 var args = event.args;
182
183 if ( typeof script === 'undefined' || typeof selector === 'undefined' )
184 return false;
185
186 rl_view_image = function( script, url ) {
187 $.event.trigger( {
188 type: 'doLightboxViewImage',
189 script: script,
190 url: url
191 } );
192 }
193
194 rl_hide_image = function( script, url ) {
195 $.event.trigger( {
196 type: 'doLightboxHideImage',
197 script: script,
198 url: url
199 } );
200 }
201
202 // WooCommerce 3.0+ compatibility
203 setTimeout( function() {
204 var flex = $( '.flex-viewport' );
205
206 if ( args.woocommerce_gallery === '1' ) {
207 var gallery = $( '.woocommerce-product-gallery' );
208
209 if ( gallery.find( '.woocommerce-product-gallery__trigger' ).length === 0 ) {
210 gallery.prepend( '<a href="#" class="woocommerce-product-gallery__trigger">🔍</a>' );
211
212 gallery.on( 'click', '.woocommerce-product-gallery__trigger', function( e ) {
213 e.preventDefault();
214 e.stopPropagation();
215
216 if ( flex.length )
217 flex.find( '.flex-active-slide a[data-rel]' ).trigger( 'click' );
218 else
219 gallery.find( 'a[data-rel]' ).first().trigger( 'click' );
220 } );
221 }
222 }
223 }, 10 );
224
225 // initialize lightbox
226 switch ( script ) {
227 case 'swipebox':
228 var slide = $( '#swipebox-overlay' ).find( '.slide.current' );
229 var imageSource = '';
230 var allowHide = false;
231 var closeExecuted = false;
232
233 $( 'a[rel*="' + selector + '"], a[data-rel*="' + selector + '"]' ).swipebox( {
234 useCSS: ( args.animation === '1' ? true : false ),
235 useSVG: ( args.useSVG === '1' ? true : false ),
236 hideCloseButtonOnMobile: ( args.hideCloseButtonOnMobile === '1' ? true : false ),
237 removeBarsOnMobile: ( args.removeBarsOnMobile === '1' ? true : false ),
238 hideBarsDelay: ( args.hideBars === '1' ? parseInt( args.hideBarsDelay ) : 0 ),
239 videoMaxWidth: parseInt( args.videoMaxWidth ),
240 loopAtEnd: ( args.loopAtEnd === '1' ? true : false ),
241 afterOpen: function() {
242 closeExecuted = false;
243
244 // update current slide container
245 slide = $( '#swipebox-overlay' ).find( '.slide.current' );
246
247 // get image source
248 var image = slide.find( 'img' ).attr( 'src' );
249
250 // valid image source?
251 if ( typeof image !== 'undefined' ) {
252 imageSource = image;
253
254 // trigger image view
255 rl_view_image( script, imageSource );
256 } else
257 imageSource = '';
258
259 // add current slide observer
260 observeContentChanges( document.getElementById( 'swipebox-slider' ), false, function() {
261 if ( imageSource === '' ) {
262 // get image source
263 var image = slide.find( 'img' ).attr( 'src' );
264
265 // valid image source?
266 if ( typeof image !== 'undefined' ) {
267 imageSource = image;
268
269 // trigger image view
270 rl_view_image( script, imageSource );
271 } else
272 imageSource = '';
273 }
274 } );
275 },
276 nextSlide: function() {
277 // update current slide container
278 slide = $( '#swipebox-overlay' ).find( '.slide.current' );
279
280 // get image source
281 var image = slide.find( 'img' ).attr( 'src' );
282
283 // valid image source?
284 if ( typeof image !== 'undefined' ) {
285 imageSource = image;
286
287 // trigger image view
288 rl_view_image( script, imageSource );
289 } else
290 imageSource = '';
291 },
292 prevSlide: function() {
293 // update current slide container
294 slide = $( '#swipebox-overlay' ).find( '.slide.current' );
295
296 // get image source
297 var image = slide.find( 'img' ).attr( 'src' );
298
299 // valid image source?
300 if ( typeof image !== 'undefined' ) {
301 imageSource = image;
302
303 // trigger image view
304 rl_view_image( script, imageSource );
305 } else
306 imageSource = '';
307 },
308 afterClose: function() {
309 // afterClose event executed
310 closeExecuted = true;
311
312 // allow to hide image?
313 if ( allowHide ) {
314 // trigger image hide
315 rl_hide_image( script, imageSource );
316
317 allowHide = false;
318 }
319 }
320 } );
321
322 // additional event to prevent rl_hide_image to execure while opening modal
323 $( window ).on( 'resize', function() {
324 if ( ! closeExecuted ) {
325 allowHide = true;
326 }
327 } );
328 break;
329
330 case 'prettyphoto':
331 var viewDisabled = false;
332 var lastImage = '';
333
334 $( 'a[rel*="' + selector + '"], a[data-rel*="' + selector + '"]' ).each( function() {
335 var el = $( this );
336
337 // set description
338 el.attr( 'title', el.data( 'rl_caption' ) );
339
340 // set title
341 el.find( 'img' ).attr( 'alt', el.data( 'rl_title' ) );
342 } );
343
344 $( 'a[rel*="' + selector + '"], a[data-rel*="' + selector + '"]' ).prettyPhoto( {
345 hook: 'data-rel',
346 animation_speed: args.animationSpeed,
347 slideshow: ( args.slideshow === '1' ? parseInt( args.slideshowDelay ) : false ),
348 autoplay_slideshow: ( args.slideshowAutoplay === '1' ? true : false ),
349 opacity: args.opacity,
350 show_title: ( args.showTitle === '1' ? true : false ),
351 allow_resize: ( args.allowResize === '1' ? true : false ),
352 allow_expand: ( args.allowExpand === '1' ? true : false ),
353 default_width: parseInt( args.width ),
354 default_height: parseInt( args.height ),
355 counter_separator_label: args.separator,
356 theme: args.theme,
357 horizontal_padding: parseInt( args.horizontalPadding ),
358 hideflash: ( args.hideFlash === '1' ? true : false ),
359 wmode: args.wmode,
360 autoplay: ( args.videoAutoplay === '1' ? true : false ),
361 modal: ( args.modal === '1' ? true : false ),
362 deeplinking: ( args.deeplinking === '1' ? true : false ),
363 overlay_gallery: ( args.overlayGallery === '1' ? true : false ),
364 keyboard_shortcuts: ( args.keyboardShortcuts === '1' ? true : false ),
365 social_tools: ( args.social === '1' ? '<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>' : '' ),
366 ie6_fallback: true,
367 changepicturecallback: function() {
368 // is view disabled?
369 if ( viewDisabled ) {
370 // enable view
371 viewDisabled = false;
372
373 return;
374 }
375
376 lastImage = $( '#pp_full_res' ).find( 'img' ).attr( 'src' );
377
378 // trigger image view
379 rl_view_image( script, lastImage );
380
381 // is expanding allowed?
382 if ( args.allowExpand === '1' ) {
383 // disable changepicturecallback event after expanding
384 $( 'a.pp_expand' ).on( 'click', function() {
385 viewDisabled = true;
386 } );
387 }
388 },
389 callback: function() {
390 // trigger image hide
391 rl_hide_image( script, lastImage );
392 }
393 } );
394 break;
395
396 case 'fancybox':
397 var lastImage = '';
398
399 $( 'a[rel*="' + selector + '"], a[data-rel*="' + selector + '"]' ).fancybox( {
400 modal: ( args.modal === '1' ? true : false ),
401 overlayShow: ( args.showOverlay === '1' ? true : false ),
402 showCloseButton: ( args.showCloseButton === '1' ? true : false ),
403 enableEscapeButton: ( args.enableEscapeButton === '1' ? true : false ),
404 hideOnOverlayClick: ( args.hideOnOverlayClick === '1' ? true : false ),
405 hideOnContentClick: ( args.hideOnContentClick === '1' ? true : false ),
406 cyclic: ( args.cyclic === '1' ? true : false ),
407 showNavArrows: ( args.showNavArrows === '1' ? true : false ),
408 autoScale: ( args.autoScale === '1' ? true : false ),
409 scrolling: args.scrolling,
410 centerOnScroll: ( args.centerOnScroll === '1' ? true : false ),
411 opacity: ( args.opacity === '1' ? true : false ),
412 overlayOpacity: parseFloat( args.overlayOpacity / 100 ),
413 overlayColor: args.overlayColor,
414 titleShow: ( args.titleShow === '1' ? true : false ),
415 titlePosition: args.titlePosition,
416 transitionIn: args.transitions,
417 transitionOut: args.transitions,
418 easingIn: args.easings,
419 easingOut: args.easings,
420 speedIn: parseInt( args.speeds ),
421 speedOut: parseInt( args.speeds ),
422 changeSpeed: parseInt( args.changeSpeed ),
423 changeFade: parseInt( args.changeFade ),
424 padding: parseInt( args.padding ),
425 margin: parseInt( args.margin ),
426 width: parseInt( args.videoWidth ),
427 height: parseInt( args.videoHeight ),
428 onComplete: function() {
429 lastImage = $( '#fancybox-content' ).find( 'img' ).attr( 'src' );
430
431 // trigger image view
432 rl_view_image( script, lastImage );
433 },
434 onClosed: function() {
435 // trigger image hide
436 rl_hide_image( script, lastImage );
437 }
438 } );
439 break;
440
441 case 'nivo':
442 $.each( $( 'a[rel*="' + selector + '"], a[data-rel*="' + selector + '"]' ), function() {
443 var attr = $( this ).attr( 'data-rel' );
444
445 // check data-rel attribute first
446 if ( typeof attr === 'undefined' || attr == false ) {
447 // if not found then try to check rel attribute for backward compatibility
448 attr = $( this ).attr( 'rel' );
449 }
450
451 // for some browsers, `attr` is undefined; for others, `attr` is false. Check for both.
452 if ( typeof attr !== 'undefined' && attr !== false ) {
453 var match = attr.match( new RegExp( selector + '\\-(gallery\\-(?:[\\da-z]{1,4}))', 'ig' ) );
454
455 if ( match !== null )
456 $( this ).attr( 'data-lightbox-gallery', match[0] );
457 }
458 } );
459
460 var observerInitialized = false;
461 var changeAllowed = true;
462 var lastImage = '';
463
464 $( 'a[rel*="' + selector + '"], a[data-rel*="' + selector + '"]' ).nivoLightbox( {
465 effect: args.effect,
466 clickOverlayToClose: ( args.clickOverlayToClose === '1' ? true : false ),
467 keyboardNav: ( args.keyboardNav === '1' ? true : false ),
468 errorMessage: args.errorMessage,
469 afterShowLightbox: function( lightbox ) {
470 var content = $( lightbox )[0].find( '.nivo-lightbox-content' );
471
472 // is observer initialized?
473 if ( ! observerInitialized ) {
474 // turn it off
475 observerInitialized = true;
476
477 // add content observer
478 observeContentChanges( document.getElementsByClassName( 'nivo-lightbox-content' )[0], true, function() {
479 if ( changeAllowed ) {
480 lastImage = content.find( '.nivo-lightbox-image img' ).attr( 'src' );
481
482 // trigger image view
483 rl_view_image( script, lastImage );
484
485 // disallow observer changes
486 changeAllowed = false;
487 }
488 } );
489 }
490 },
491 afterHideLightbox: function() {
492 // allow observer changes
493 changeAllowed = true;
494
495 // trigger image hide
496 rl_hide_image( script, lastImage );
497 },
498 onPrev: function( element ) {
499 // disallow observer changes
500 changeAllowed = false;
501
502 lastImage = element[0].attr( 'href' );
503
504 // trigger image view
505 rl_view_image( script, lastImage );
506 },
507 onNext: function( element ) {
508 // disallow observer changes
509 changeAllowed = false;
510
511 lastImage = element[0].attr( 'href' );
512
513 // trigger image view
514 rl_view_image( script, lastImage );
515 }
516 } );
517 break;
518
519 case 'imagelightbox':
520 var selectors = [];
521 var lastImage = '';
522
523 $( 'a[rel*="' + selector + '"], a[data-rel*="' + selector + '"]' ).each( function( i, item ) {
524 var attr = $( item ).attr( 'data-rel' );
525
526 // check data-rel attribute first
527 if ( typeof attr !== 'undefined' && attr !== false && attr !== 'norl' )
528 selectors.push( attr );
529 // if not found then try to check rel attribute for backward compatibility
530 else {
531 attr = $( item ).attr( 'rel' );
532
533 if ( typeof attr !== 'undefined' && attr !== false && attr !== 'norl' )
534 selectors.push( attr );
535 }
536 } );
537
538 if ( selectors.length > 0 ) {
539 // make unique
540 selectors = _.uniq( selectors );
541
542 $( selectors ).each( function( i, item ) {
543 if ( typeof event.pagination_type !== 'undefined' ) {
544 $( 'a[data-rel="' + item + '"], a[rel="' + item + '"]' ).each( function() {
545 $( this ).off( 'click.imageLightbox' );
546 } );
547 }
548
549 $( 'a[data-rel="' + item + '"], a[rel="' + item + '"]' ).imageLightbox( {
550 animationSpeed: parseInt( args.animationSpeed ),
551 preloadNext: ( args.preloadNext === '1' ? true : false ),
552 enableKeyboard: ( args.enableKeyboard === '1' ? true : false ),
553 quitOnEnd: ( args.quitOnEnd === '1' ? true : false ),
554 quitOnImgClick: ( args.quitOnImageClick === '1' ? true : false ),
555 quitOnDocClick: ( args.quitOnDocumentClick === '1' ? true : false ),
556 onLoadEnd: function() {
557 lastImage = $( '#imagelightbox' ).attr( 'src' );
558
559 // trigger image view
560 rl_view_image( script, lastImage );
561 },
562 onEnd: function() {
563 // trigger image hide
564 rl_hide_image( script, lastImage );
565 }
566 } );
567 } );
568 }
569 break;
570
571 case 'tosrus':
572 var selectors = [];
573 var lastImage = '';
574
575 $( 'a[rel*="' + selector + '"], a[data-rel*="' + selector + '"]' ).each( function( i, item ) {
576 var attr = $( item ).attr( 'data-rel' );
577
578 // check data-rel attribute first
579 if ( typeof attr !== 'undefined' && attr !== false && attr !== 'norl' )
580 selectors.push( attr );
581 // if not found then try to check rel attribute for backward compatibility
582 else {
583 attr = $( item ).attr( 'rel' );
584
585 if ( typeof attr !== 'undefined' && attr !== false && attr !== 'norl' )
586 selectors.push( attr );
587 }
588 } );
589
590 if ( selectors.length > 0 ) {
591 // make unique
592 selectors = _.uniq( selectors );
593
594 $( selectors ).each( function( i, item ) {
595 if ( typeof event.pagination_type !== 'undefined' ) {
596 $( 'body' ).find( '.tosrus-' + item ).remove();
597
598 $( 'a[data-rel="' + item + '"], a[rel="' + item + '"]' ).each( function() {
599 $( this ).off( 'click.tos' );
600 } );
601 }
602
603 var tos = $( 'a[data-rel="' + item + '"], a[rel="' + item + '"]' ).tosrus( {
604 infinite: ( args.infinite === '1' ? true : false ),
605 autoplay: {
606 play: ( args.autoplay === '1' ? true : false ),
607 pauseOnHover: ( args.pauseOnHover === '1' ? true : false ),
608 timeout: args.timeout
609 },
610 effect: args.effect,
611 keys: {
612 prev: ( args.keys === '1' ? true : false ),
613 next: ( args.keys === '1' ? true : false ),
614 close: ( args.keys === '1' ? true : false )
615 },
616 pagination: {
617 add: ( args.pagination === '1' ? true : false ),
618 type: args.paginationType
619 },
620 // forced
621 show: false,
622 buttons: true,
623 caption: {
624 add: true,
625 attributes: [ "title" ]
626 },
627 wrapper: {
628 classes: 'tosrus-' + item,
629 onClick: args.closeOnClick === '1' ? 'close' : 'toggleUI'
630 }
631 } );
632
633 tos.on( 'sliding.tos', function( event, number ) {
634 lastImage = $( $( event.target ).find( '.tos-slider .tos-slide' )[number] ).find( 'img' ).attr( 'src' );
635
636 // trigger image view
637 rl_view_image( script, lastImage );
638 } );
639
640 tos.on( 'closing.tos', function() {
641 // trigger image hide
642 rl_hide_image( script, lastImage );
643 } );
644 } );
645 }
646 break;
647
648 case 'featherlight':
649 var selectors = [];
650 var lastImage = '';
651
652 $( 'a[rel*="' + selector + '"], a[data-rel*="' + selector + '"]' ).each( function( i, item ) {
653 var attr = $( item ).attr( 'data-rel' );
654
655 // check data-rel attribute first
656 if ( typeof attr !== 'undefined' && attr !== false && attr !== 'norl' )
657 selectors.push( attr );
658 // if not found then try to check rel attribute for backward compatibility
659 else {
660 attr = $( item ).attr( 'rel' );
661
662 if ( typeof attr !== 'undefined' && attr !== false && attr !== 'norl' )
663 selectors.push( attr );
664 }
665 } );
666
667 if ( selectors.length > 0 ) {
668 // make unique
669 selectors = _.uniq( selectors );
670
671 // set defaults
672 $.extend( $.featherlight.defaults, {
673 openSpeed: parseInt( args.openSpeed ),
674 closeSpeed: parseInt( args.closeSpeed ),
675 closeOnClick: args.closeOnClick,
676 closeOnEsc: ( args.closeOnEsc === '1' ? true : false ),
677 afterOpen: function( event ) {
678 lastImage = event.currentTarget.href;
679
680 // trigger image view
681 rl_view_image( script, lastImage );
682 },
683 afterClose: function() {
684 // trigger image hide
685 rl_hide_image( script, lastImage );
686 }
687 } );
688
689 $( selectors ).each( function( i, item ) {
690 if ( typeof event.pagination_type !== 'undefined' ) {
691 $( 'a[data-rel="' + item + '"], a[rel="' + item + '"]' ).each( function() {
692 $( this ).off( 'click.featherlight' );
693 } );
694 }
695
696 // gallery?
697 if ( /-gallery-/.test( item ) ) {
698 $( 'a[data-rel="' + item + '"], a[rel="' + item + '"]' ).featherlightGallery( {
699 galleryFadeIn: parseInt( args.galleryFadeIn ),
700 galleryFadeOut: parseInt( args.galleryFadeOut ),
701 previousIcon: '&#10094;',
702 nextIcon: '&#10095;'
703 } );
704 // video?
705 } else if ( /-video-/.test( item ) ) {
706 $( 'a[data-rel="' + item + '"], a[rel="' + item + '"]' ).featherlight();
707 // single image?
708 } else {
709 $( 'a[data-rel="' + item + '"], a[rel="' + item + '"]' ).featherlight();
710 }
711 } );
712 }
713 break;
714
715 case 'magnific':
716 var selectors = [];
717 var lastImage = '';
718
719 $( 'a[rel*="' + selector + '"], a[data-rel*="' + selector + '"]' ).each( function( i, item ) {
720 var attr = $( item ).attr( 'data-rel' );
721
722 // check data-rel attribute first
723 if ( typeof attr !== 'undefined' && attr !== false && attr !== 'norl' )
724 selectors.push( attr );
725 // if not found then try to check rel attribute for backward compatibility
726 else {
727 attr = $( item ).attr( 'rel' );
728
729 if ( typeof attr !== 'undefined' && attr !== false && attr !== 'norl' )
730 selectors.push( attr );
731 }
732 } );
733
734 if ( selectors.length > 0 ) {
735 // make unique
736 selectors = _.uniq( selectors );
737
738 $( selectors ).each( function( i, item ) {
739 var subselector = $( 'a[data-rel="' + item + '"], a[rel="' + item + '"]' );
740 var element = $( subselector[0] );
741 var media_type = element.data( 'magnific_type' );
742 var content_type = element.data( 'rl_content' );
743
744 // check content type first
745 if ( typeof content_type !== 'undefined' )
746 media_type = content_type;
747
748 // then media type if needed
749 if ( typeof media_type === 'undefined' )
750 media_type = 'image';
751
752 subselector.magnificPopup( {
753 type: media_type === 'gallery' ? 'image' : ( media_type === 'video' ? 'iframe' : media_type ),
754 disableOn: args.disableOn,
755 midClick: args.midClick === '1',
756 preloader: args.preloader === '1',
757 closeOnContentClick: args.closeOnContentClick === '1',
758 closeOnBgClick: args.closeOnBgClick === '1',
759 closeBtnInside: args.closeBtnInside === '1',
760 showCloseBtn: args.showCloseBtn === '1',
761 enableEscapeKey: args.enableEscapeKey === '1',
762 alignTop: args.alignTop === '1',
763 autoFocusLast: args.autoFocusLast === '1',
764 fixedContentPos: args.fixedContentPos === 'auto' ? 'auto' : ( args.fixedContentPos === '1' ),
765 fixedBgPos: args.fixedBgPos === 'auto' ? 'auto' : ( args.fixedBgPos === '1' ),
766 image: {
767 titleSrc: function( item ) {
768 return item.el.attr( 'data-rl_title' ) + '<small>' + item.el.attr( 'data-rl_caption' ) + '</small>';
769 }
770 },
771 gallery: {
772 enabled: subselector.length > 1 && media_type === 'gallery',
773 navigateByImgClick: true,
774 preload: [0,1]
775 },
776 callbacks: {
777 close: function() {
778 rl_hide_image( script, this.currItem.src );
779 },
780 imageLoadComplete: function() {
781 // trigger image view
782 rl_view_image( script, this.currItem.src );
783 }
784 }
785 } );
786 } );
787 }
788 break;
789 }
790 } );
791
792 } )( jQuery );