PluginProbe ʕ •ᴥ•ʔ
Responsive Lightbox & Gallery / 2.4.6
Responsive Lightbox & Gallery v2.4.6
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 2 years ago admin-galleries.js 2 years ago admin-gallery.js 2 years ago admin-media.js 5 years ago admin-plugins.js 2 years ago admin-widgets.js 2 years ago admin.js 2 years ago front-basicmasonry.js 2 years ago front-basicslider.js 2 years ago front.js 2 years ago gutenberg.min.js 4 years ago
front.js
882 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 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 'fancybox':
465 var lastImage = '';
466
467 $( 'a[rel*="' + selector + '"], a[data-rel*="' + selector + '"]' ).fancybox( {
468 modal: args.modal,
469 overlayShow: args.showOverlay,
470 showCloseButton: args.showCloseButton,
471 enableEscapeButton: args.enableEscapeButton,
472 hideOnOverlayClick: args.hideOnOverlayClick,
473 hideOnContentClick: args.hideOnContentClick,
474 cyclic: args.cyclic,
475 showNavArrows: args.showNavArrows,
476 autoScale: args.autoScale,
477 scrolling: args.scrolling,
478 centerOnScroll: args.centerOnScroll,
479 opacity: args.opacity,
480 overlayOpacity: parseFloat( args.overlayOpacity / 100 ),
481 overlayColor: args.overlayColor,
482 titleShow: args.titleShow,
483 titlePosition: args.titlePosition,
484 transitionIn: args.transitions,
485 transitionOut: args.transitions,
486 easingIn: args.easings,
487 easingOut: args.easings,
488 speedIn: parseInt( args.speeds ),
489 speedOut: parseInt( args.speeds ),
490 changeSpeed: parseInt( args.changeSpeed ),
491 changeFade: parseInt( args.changeFade ),
492 padding: parseInt( args.padding ),
493 margin: parseInt( args.margin ),
494 width: parseInt( args.videoWidth ),
495 height: parseInt( args.videoHeight ),
496 onComplete: function() {
497 lastImage = $( '#fancybox-content' ).find( 'img' ).attr( 'src' );
498
499 // trigger image view
500 rl_view_image( script, lastImage );
501 },
502 onClosed: function() {
503 // trigger image hide
504 rl_hide_image( script, lastImage );
505 }
506 } );
507 break;
508
509 case 'nivo':
510 $.each( $( 'a[rel*="' + selector + '"], a[data-rel*="' + selector + '"]' ), function() {
511 var attr = $( this ).attr( 'data-rel' );
512
513 // check data-rel attribute first
514 if ( typeof attr === 'undefined' || attr == false ) {
515 // if not found then try to check rel attribute for backward compatibility
516 attr = $( this ).attr( 'rel' );
517 }
518
519 // for some browsers, `attr` is undefined; for others, `attr` is false. Check for both.
520 if ( typeof attr !== 'undefined' && attr !== false ) {
521 var match = attr.match( new RegExp( selector + '\\-(gallery\\-(?:[\\da-z]{1,4}))', 'ig' ) );
522
523 if ( match !== null )
524 $( this ).attr( 'data-lightbox-gallery', match[0] );
525 }
526 } );
527
528 var observerInitialized = false;
529 var changeAllowed = true;
530 var lastImage = '';
531
532 $( 'a[rel*="' + selector + '"], a[data-rel*="' + selector + '"]' ).nivoLightbox( {
533 effect: args.effect,
534 clickOverlayToClose: args.clickOverlayToClose,
535 keyboardNav: args.keyboardNav,
536 errorMessage: args.errorMessage,
537 afterShowLightbox: function( lightbox ) {
538 var content = $( lightbox )[0].find( '.nivo-lightbox-content' );
539
540 // is observer initialized?
541 if ( ! observerInitialized ) {
542 // turn it off
543 observerInitialized = true;
544
545 // add content observer
546 observeContentChanges( document.getElementsByClassName( 'nivo-lightbox-content' )[0], true, function() {
547 if ( changeAllowed ) {
548 lastImage = content.find( '.nivo-lightbox-image img' ).attr( 'src' );
549
550 // trigger image view
551 rl_view_image( script, lastImage );
552
553 // disallow observer changes
554 changeAllowed = false;
555 }
556 } );
557 }
558 },
559 afterHideLightbox: function() {
560 // allow observer changes
561 changeAllowed = true;
562
563 // trigger image hide
564 rl_hide_image( script, lastImage );
565 },
566 onPrev: function( element ) {
567 // disallow observer changes
568 changeAllowed = false;
569
570 lastImage = element[0].attr( 'href' );
571
572 // trigger image view
573 rl_view_image( script, lastImage );
574 },
575 onNext: function( element ) {
576 // disallow observer changes
577 changeAllowed = false;
578
579 lastImage = element[0].attr( 'href' );
580
581 // trigger image view
582 rl_view_image( script, lastImage );
583 }
584 } );
585 break;
586
587 case 'imagelightbox':
588 var selectors = [];
589 var lastImage = '';
590
591 $( 'a[rel*="' + selector + '"], a[data-rel*="' + selector + '"]' ).each( function( i, item ) {
592 var attr = $( item ).attr( 'data-rel' );
593
594 // check data-rel attribute first
595 if ( typeof attr !== 'undefined' && attr !== false && attr !== 'norl' )
596 selectors.push( attr );
597 // if not found then try to check rel attribute for backward compatibility
598 else {
599 attr = $( item ).attr( 'rel' );
600
601 if ( typeof attr !== 'undefined' && attr !== false && attr !== 'norl' )
602 selectors.push( attr );
603 }
604 } );
605
606 if ( selectors.length > 0 ) {
607 // make unique
608 selectors = _.uniq( selectors );
609
610 $( selectors ).each( function( i, item ) {
611 if ( typeof event.pagination_type !== 'undefined' ) {
612 $( 'a[data-rel="' + item + '"], a[rel="' + item + '"]' ).each( function() {
613 $( this ).off( 'click.imageLightbox' );
614 } );
615 }
616
617 $( 'a[data-rel="' + item + '"], a[rel="' + item + '"]' ).imageLightbox( {
618 animationSpeed: parseInt( args.animationSpeed ),
619 preloadNext: args.preloadNext,
620 enableKeyboard: args.enableKeyboard,
621 quitOnEnd: args.quitOnEnd,
622 quitOnImgClick: args.quitOnImageClick,
623 quitOnDocClick: args.quitOnDocumentClick,
624 onLoadEnd: function() {
625 lastImage = $( '#imagelightbox' ).attr( 'src' );
626
627 // trigger image view
628 rl_view_image( script, lastImage );
629 },
630 onEnd: function() {
631 // trigger image hide
632 rl_hide_image( script, lastImage );
633 }
634 } );
635 } );
636 }
637 break;
638
639 case 'tosrus':
640 var selectors = [];
641 var lastImage = '';
642
643 $( 'a[rel*="' + selector + '"], a[data-rel*="' + selector + '"]' ).each( function( i, item ) {
644 var attr = $( item ).attr( 'data-rel' );
645
646 // check data-rel attribute first
647 if ( typeof attr !== 'undefined' && attr !== false && attr !== 'norl' )
648 selectors.push( attr );
649 // if not found then try to check rel attribute for backward compatibility
650 else {
651 attr = $( item ).attr( 'rel' );
652
653 if ( typeof attr !== 'undefined' && attr !== false && attr !== 'norl' )
654 selectors.push( attr );
655 }
656 } );
657
658 if ( selectors.length > 0 ) {
659 // make unique
660 selectors = _.uniq( selectors );
661
662 $( selectors ).each( function( i, item ) {
663 if ( typeof event.pagination_type !== 'undefined' ) {
664 $( 'body' ).find( '.tosrus-' + item ).remove();
665
666 $( 'a[data-rel="' + item + '"], a[rel="' + item + '"]' ).each( function() {
667 $( this ).off( 'click.tos' );
668 } );
669 }
670
671 var tos = $( 'a[data-rel="' + item + '"], a[rel="' + item + '"]' ).tosrus( {
672 infinite: args.infinite,
673 autoplay: {
674 play: args.autoplay,
675 pauseOnHover: args.pauseOnHover,
676 timeout: args.timeout
677 },
678 effect: args.effect,
679 keys: {
680 prev: args.keys,
681 next: args.keys,
682 close: args.keys
683 },
684 pagination: {
685 add: args.pagination,
686 type: args.paginationType
687 },
688 // forced
689 show: false,
690 buttons: true,
691 caption: {
692 add: true,
693 attributes: [ "title" ]
694 },
695 wrapper: {
696 classes: 'tosrus-' + item,
697 onClick: args.closeOnClick ? 'close' : 'toggleUI'
698 }
699 } );
700
701 tos.on( 'sliding.tos', function( event, number ) {
702 lastImage = $( $( event.target ).find( '.tos-slider .tos-slide' )[number] ).find( 'img' ).attr( 'src' );
703
704 // trigger image view
705 rl_view_image( script, lastImage );
706 } );
707
708 tos.on( 'closing.tos', function() {
709 // trigger image hide
710 rl_hide_image( script, lastImage );
711 } );
712 } );
713 }
714 break;
715
716 case 'featherlight':
717 var selectors = [];
718 var lastImage = '';
719
720 $( 'a[rel*="' + selector + '"], a[data-rel*="' + selector + '"]' ).each( function( i, item ) {
721 var attr = $( item ).attr( 'data-rel' );
722
723 // check data-rel attribute first
724 if ( typeof attr !== 'undefined' && attr !== false && attr !== 'norl' )
725 selectors.push( attr );
726 // if not found then try to check rel attribute for backward compatibility
727 else {
728 attr = $( item ).attr( 'rel' );
729
730 if ( typeof attr !== 'undefined' && attr !== false && attr !== 'norl' )
731 selectors.push( attr );
732 }
733 } );
734
735 if ( selectors.length > 0 ) {
736 // make unique
737 selectors = _.uniq( selectors );
738
739 // set defaults
740 $.extend( $.featherlight.defaults, {
741 openSpeed: parseInt( args.openSpeed ),
742 closeSpeed: parseInt( args.closeSpeed ),
743 closeOnClick: args.closeOnClick,
744 closeOnEsc: args.closeOnEsc,
745 afterOpen: function( event ) {
746 lastImage = event.currentTarget.href;
747
748 // trigger image view
749 rl_view_image( script, lastImage );
750 },
751 afterClose: function() {
752 // trigger image hide
753 rl_hide_image( script, lastImage );
754 }
755 } );
756
757 $( selectors ).each( function( i, item ) {
758 if ( typeof event.pagination_type !== 'undefined' ) {
759 $( 'a[data-rel="' + item + '"], a[rel="' + item + '"]' ).each( function() {
760 $( this ).off( 'click.featherlight' );
761 } );
762 }
763
764 // gallery?
765 if ( /-gallery-/.test( item ) ) {
766 $( 'a[data-rel="' + item + '"], a[rel="' + item + '"]' ).featherlightGallery( {
767 galleryFadeIn: parseInt( args.galleryFadeIn ),
768 galleryFadeOut: parseInt( args.galleryFadeOut ),
769 previousIcon: '&#10094;',
770 nextIcon: '&#10095;'
771 } );
772 // video?
773 } else if ( /-video-/.test( item ) ) {
774 $( 'a[data-rel="' + item + '"], a[rel="' + item + '"]' ).featherlight();
775 // single image?
776 } else {
777 $( 'a[data-rel="' + item + '"], a[rel="' + item + '"]' ).featherlight();
778 }
779 } );
780 }
781 break;
782
783 case 'magnific':
784 var selectors = [];
785 var lastImage = '';
786
787 $( 'a[rel*="' + selector + '"], a[data-rel*="' + selector + '"]' ).each( function( i, item ) {
788 var attr = $( item ).attr( 'data-rel' );
789
790 // check data-rel attribute first
791 if ( typeof attr !== 'undefined' && attr !== false && attr !== 'norl' )
792 selectors.push( attr );
793 // if not found then try to check rel attribute for backward compatibility
794 else {
795 attr = $( item ).attr( 'rel' );
796
797 if ( typeof attr !== 'undefined' && attr !== false && attr !== 'norl' )
798 selectors.push( attr );
799 }
800 } );
801
802 if ( selectors.length > 0 ) {
803 // make unique
804 selectors = _.uniq( selectors );
805
806 $( selectors ).each( function( i, item ) {
807 var subselector = $( 'a[data-rel="' + item + '"], a[rel="' + item + '"]' );
808 var element = $( subselector[0] );
809 var media_type = element.data( 'magnific_type' );
810 var content_type = element.data( 'rl_content' );
811
812 // check content type first
813 if ( typeof content_type !== 'undefined' )
814 media_type = content_type;
815
816 // then media type if needed
817 if ( typeof media_type === 'undefined' )
818 media_type = 'image';
819
820 var fixedContentPos = 'auto';
821 var fixedBgPos = 'auto';
822
823 if ( args.fixedContentPos === 'true' )
824 fixedContentPos = true;
825 else if ( args.fixedContentPos === 'false' )
826 fixedContentPos = false;
827
828 if ( args.fixedBgPos === 'true' )
829 fixedBgPos = true;
830 else if ( args.fixedBgPos === 'false' )
831 fixedBgPos = false;
832
833 subselector.magnificPopup( {
834 type: media_type === 'gallery' ? 'image' : ( media_type === 'video' ? 'iframe' : media_type ),
835 disableOn: args.disableOn,
836 midClick: args.midClick,
837 preloader: args.preloader,
838 closeOnContentClick: args.closeOnContentClick,
839 closeOnBgClick: args.closeOnBgClick,
840 closeBtnInside: args.closeBtnInside,
841 showCloseBtn: args.showCloseBtn,
842 enableEscapeKey: args.enableEscapeKey,
843 alignTop: args.alignTop,
844 autoFocusLast: args.autoFocusLast,
845 fixedContentPos: fixedContentPos,
846 fixedBgPos: fixedBgPos,
847 image: {
848 titleSrc: function( item ) {
849 var title = item.el.data( 'rl_title' );
850 var caption = item.el.data( 'rl_caption' );
851
852 if ( ! title )
853 title = '';
854
855 if ( ! caption )
856 caption = '';
857
858 return title + '<small>' + caption + '</small>';
859 }
860 },
861 gallery: {
862 enabled: subselector.length > 1 && media_type === 'gallery',
863 navigateByImgClick: true,
864 preload: [0,1]
865 },
866 callbacks: {
867 close: function() {
868 rl_hide_image( script, this.currItem.src );
869 },
870 imageLoadComplete: function() {
871 // trigger image view
872 rl_view_image( script, this.currItem.src );
873 }
874 }
875 } );
876 } );
877 }
878 break;
879 }
880 }
881
882 } )( jQuery );