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