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