1( function( $ ) { 2 3 // parse query string 4 var parse_str = 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 observe_script_dom = ( function() { 13 var MutationObserver = window.MutationObserver || window.WebKitMutationObserver; 14 var 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 // ready event 41 $( function() { 42 init_rl(); 43 } ); 44 45 // custom events trigger 46 $( document ).on( rlArgs.customEvents, function() { 47 init_rl(); 48 } ); 49 50 function init_rl() { 51 var containers = []; 52 53 // check for infinite galleries 54 $( '.rl-gallery-container' ).each( function() { 55 var container = $( this ); 56 57 // is it ifinite scroll gallery? 58 if ( container.hasClass( 'rl-pagination-infinite' ) ) 59 containers.push( container ); 60 // remove loading class 61 else 62 container.removeClass( 'rl-loading' ); 63 } ); 64 65 // any infinite galleries? 66 if ( containers.length > 0 ) { 67 for ( var i = 0; i < containers.length; i++ ) { 68 var container = containers[i]; 69 var gallery = container.find( '.rl-gallery' ); 70 var gallery_id = parseInt( container.data( 'gallery_id' ) ); 71 var gallery_scroll_type = container.find( '.rl-pagination-bottom' ).data( 'button' ); 72 var gallery_button = typeof gallery_scroll_type !== 'undefined' && gallery_scroll_type === 'manually'; 73 74 // initialize infinite scroll 75 gallery.infiniteScroll( { 76 path: '.rl-gallery-container[data-gallery_id="' + gallery_id + '"] .rl-pagination-bottom .next', 77 append: '.rl-gallery-container[data-gallery_id="' + gallery_id + '"] .rl-gallery-item' + ( gallery.hasClass( 'rl-masonry-gallery' ) || gallery.hasClass( 'rl-basicmasonry-gallery' ) ? '-no-append' : '' ), 78 status: false, 79 hideNav: '.rl-gallery-container[data-gallery_id="' + gallery_id + '"] .rl-pagination-bottom', 80 prefill: ! gallery_button, 81 loadOnScroll: true, 82 scrollThreshold: gallery_button ? false : 0, 83 button: gallery_button ? '.rl-gallery-container[data-gallery_id="' + gallery_id + '"] .rl-load-more' : false, 84 debug: false, 85 history: false, 86 onInit: function() { 87 // infinite with button? 88 if ( container.hasClass( 'rl-pagination-infinite' ) && gallery_button ) { 89 // remove loading class 90 container.removeClass( 'rl-loading' ); 91 } 92 93 // store gallery ID for append event 94 var _gallery_id = gallery_id; 95 96 // request event 97 this.on( 'request', function( path ) { 98 // add loading class 99 container.addClass( 'rl-loading' ); 100 } ); 101 102 // append event 103 this.on( 'append', function( response, path, items ) { 104 // remove loading class 105 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: _gallery_id, 114 masonry: gallery.hasClass( 'rl-masonry-gallery' ) || gallery.hasClass( 'rl-basicmasonry-gallery' ), 115 infinite: { 116 gallery: gallery, 117 response: response, 118 items: items 119 } 120 } ); 121 } ); 122 } 123 } ); 124 } 125 } 126 127 // initialize event 128 $.event.trigger( { 129 type: 'doResponsiveLightbox', 130 script: rlArgs.script, 131 selector: rlArgs.selector, 132 args: rlArgs 133 } ); 134 } 135 136 // pagination 137 $( document ).on( 'click', '.rl-pagination a.page-numbers', function( e ) { 138 var link = $( this ); 139 var container = link.closest( '.rl-gallery-container' ); 140 141 // ajax type pagination? 142 if ( container.hasClass( 'rl-pagination-ajax' ) ) { 143 e.preventDefault(); 144 e.stopPropagation(); 145 146 var gallery_id = container.data( 'gallery_id' ); 147 148 // add loading class 149 container.addClass( 'rl-loading' ); 150 151 $.post( rlArgs.ajaxurl, { 152 action: 'rl-get-gallery-page-content', 153 gallery_id: gallery_id, 154 page: parse_str( 'rl_page', link.prop( 'href' ) ), 155 nonce: rlArgs.nonce 156 } ).done( function( response ) { 157 // replace container with new content 158 container.replaceWith( $( response ).removeClass( 'rl-loading' ) ); 159 160 // trigger main event 161 $.event.trigger( { 162 type: 'doResponsiveLightbox', 163 script: rlArgs.script, 164 selector: rlArgs.selector, 165 args: rlArgs, 166 pagination_type: 'ajax', 167 gallery_id: gallery_id 168 } ); 169 } ).fail( function() { 170 container.removeClass( 'rl-loading' ); 171 } ); 172 173 return false; 174 } 175 } ); 176 177 // this is similar to the WP function add_action(); 178 $( document ).on( 'doResponsiveLightbox', function( event ) { 179 if ( typeof event.masonry !== 'undefined' && event.masonry === true ) 180 return false; 181 182 var script = event.script; 183 var selector = event.selector; 184 var args = event.args; 185 186 if ( typeof script === 'undefined' || typeof selector === 'undefined' ) 187 return false; 188 189 rl_view_image = function( script, url ) { 190 $.event.trigger( { 191 type: 'doLightboxViewImage', 192 script: script, 193 url: url 194 } ); 195 } 196 197 rl_hide_image = function( script, url ) { 198 $.event.trigger( { 199 type: 'doLightboxHideImage', 200 script: script, 201 url: url 202 } ); 203 } 204 205 // WooCommerce 3.0+ compatibility 206 setTimeout( function() { 207 var flex = $( '.flex-viewport' ); 208 209 if ( args.woocommerce_gallery === '1' ) { 210 var gallery = $( '.woocommerce-product-gallery' ); 211 212 if ( gallery.find( '.woocommerce-product-gallery__trigger' ).length === 0 ) { 213 gallery.prepend( '<a href="#" class="woocommerce-product-gallery__trigger">ð</a>' ); 214 215 gallery.on( 'click', '.woocommerce-product-gallery__trigger', function( e ) { 216 e.preventDefault(); 217 e.stopPropagation(); 218 219 if ( flex.length ) 220 flex.find( '.flex-active-slide a[data-rel]' ).trigger( 'click' ); 221 else 222 gallery.find( 'a[data-rel]' ).first().trigger( 'click' ); 223 } ); 224 } 225 } 226 }, 10 ); 227 228 // init lightbox 229 switch ( script ) { 230 case 'swipebox': 231 var slide = $( '#swipebox-overlay' ).find( '.slide.current' ); 232 var image_source = ''; 233 var allow_hide = false; 234 var close_executed = false; 235 236 $( 'a[rel*="' + selector + '"], a[data-rel*="' + selector + '"]' ).swipebox( { 237 useCSS: ( args.animation === '1' ? true : false ), 238 useSVG: ( args.useSVG === '1' ? true : false ), 239 hideCloseButtonOnMobile: ( args.hideCloseButtonOnMobile === '1' ? true : false ), 240 removeBarsOnMobile: ( args.removeBarsOnMobile === '1' ? true : false ), 241 hideBarsDelay: ( args.hideBars === '1' ? parseInt( args.hideBarsDelay ) : 0 ), 242 videoMaxWidth: parseInt( args.videoMaxWidth ), 243 loopAtEnd: ( args.loopAtEnd === '1' ? true : false ), 244 afterOpen: function() { 245 close_executed = false; 246 247 // update current slide container 248 slide = $( '#swipebox-overlay' ).find( '.slide.current' ); 249 250 // get image source
251 var image = slide.find( 'img' ).attr( 'src' ); 252 253 // valid image source? 254 if ( typeof image !== 'undefined' ) { 255 image_source = image; 256 257 // trigger image view 258 rl_view_image( script, image_source ); 259 } else { 260 image_source = ''; 261 } 262 263 // add current slide observer 264 observe_script_dom( document.getElementById( 'swipebox-slider' ), false, function() { 265 if ( image_source === '' ) { 266 // get image source 267 var image = slide.find( 'img' ).attr( 'src' ); 268 269 // valid image source? 270 if ( typeof image !== 'undefined' ) { 271 image_source = image; 272 273 // trigger image view 274 rl_view_image( script, image_source ); 275 } else { 276 image_source = ''; 277 } 278 } 279 } ); 280 }, 281 nextSlide: function() { 282 // update current slide container 283 slide = $( '#swipebox-overlay' ).find( '.slide.current' ); 284 285 // get image source 286 var image = slide.find( 'img' ).attr( 'src' ); 287 288 // valid image source? 289 if ( typeof image !== 'undefined' ) { 290 image_source = image; 291 292 // trigger image view 293 rl_view_image( script, image_source ); 294 } else { 295 image_source = ''; 296 } 297 }, 298 prevSlide: function() { 299 // update current slide container 300 slide = $( '#swipebox-overlay' ).find( '.slide.current' ); 301 302 // get image source 303 var image = slide.find( 'img' ).attr( 'src' ); 304 305 // valid image source? 306 if ( typeof image !== 'undefined' ) { 307 image_source = image; 308 309 // trigger image view 310 rl_view_image( script, image_source ); 311 } else { 312 image_source = ''; 313 } 314 }, 315 afterClose: function() { 316 // afterClose event executed 317 close_executed = true; 318 319 // allow to hide image? 320 if ( allow_hide ) { 321 // trigger image hide 322 rl_hide_image( script, image_source ); 323 324 allow_hide = false; 325 } 326 } 327 } ); 328 329 // additional event to prevent rl_hide_image to execure while opening modal 330 $( window ).on( 'resize', function() { 331 if ( ! close_executed ) { 332 allow_hide = true; 333 } 334 } ); 335 break; 336 337 case 'prettyphoto': 338 var view_disabled = false; 339 var last_image = ''; 340 341 $( 'a[rel*="' + selector + '"], a[data-rel*="' + selector + '"]' ).each( function() { 342 var el = $( this ); 343 344 // set description 345 el.attr( 'title', el.data( 'rl_caption' ) ); 346 347 // set title
348 el.find( 'img' ).attr( 'alt', el.data( 'rl_title' ) ); 349 } ); 350 351 $( 'a[rel*="' + selector + '"], a[data-rel*="' + selector + '"]' ).prettyPhoto( { 352 hook: 'data-rel', 353 animation_speed: args.animationSpeed, 354 slideshow: ( args.slideshow === '1' ? parseInt( args.slideshowDelay ) : false ), 355 autoplay_slideshow: ( args.slideshowAutoplay === '1' ? true : false ), 356 opacity: args.opacity, 357 show_title: ( args.showTitle === '1' ? true : false ), 358 allow_resize: ( args.allowResize === '1' ? true : false ), 359 allow_expand: ( args.allowExpand === '1' ? true : false ), 360 default_width: parseInt( args.width ), 361 default_height: parseInt( args.height ), 362 counter_separator_label: args.separator, 363 theme: args.theme, 364 horizontal_padding: parseInt( args.horizontalPadding ), 365 hideflash: ( args.hideFlash === '1' ? true : false ), 366 wmode: args.wmode, 367 autoplay: ( args.videoAutoplay === '1' ? true : false ), 368 modal: ( args.modal === '1' ? true : false ), 369 deeplinking: ( args.deeplinking === '1' ? true : false ), 370 overlay_gallery: ( args.overlayGallery === '1' ? true : false ), 371 keyboard_shortcuts: ( args.keyboardShortcuts === '1' ? true : false ), 372 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 + '&layout=button_count&show_faces=true&width=500&action=like&font&colorscheme=light&height=23" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:500px; height:23px;" allowTransparency="true"></iframe></div></div>' : '' ), 373 ie6_fallback: true, 374 changepicturecallback: function() { 375 // is view disabled? 376 if ( view_disabled ) { 377 // enable view 378 view_disabled = false; 379 380 return; 381 } 382 383 last_image = $( '#pp_full_res' ).find( 'img' ).attr( 'src' ); 384 385 // trigger image view 386 rl_view_image( script, last_image ); 387 388 // is expanding allowed? 389 if ( args.allowExpand === '1' ) { 390 // disable changepicturecallback event after expanding 391 $( 'a.pp_expand' ).on( 'click', function() { 392 view_disabled = true; 393 } ); 394 } 395 }, 396 callback: function() { 397 // trigger image hide 398 rl_hide_image( script, last_image ); 399 } 400 } ); 401 break; 402 403 case 'fancybox': 404 var last_image = ''; 405 406 $( 'a[rel*="' + selector + '"], a[data-rel*="' + selector + '"]' ).fancybox( { 407 modal: ( args.modal === '1' ? true : false ), 408 overlayShow: ( args.showOverlay === '1' ? true : false ), 409 showCloseButton: ( args.showCloseButton === '1' ? true : false ), 410 enableEscapeButton: ( args.enableEscapeButton === '1' ? true : false ), 411 hideOnOverlayClick: ( args.hideOnOverlayClick === '1' ? true : false ), 412 hideOnContentClick: ( args.hideOnContentClick === '1' ? true : false ), 413 cyclic: ( args.cyclic === '1' ? true : false ), 414 showNavArrows: ( args.showNavArrows === '1' ? true : false ), 415 autoScale: ( args.autoScale === '1' ? true : false ), 416 scrolling: args.scrolling, 417 centerOnScroll: ( args.centerOnScroll === '1' ? true : false ), 418 opacity: ( args.opacity === '1' ? true : false ), 419 overlayOpacity: parseFloat( args.overlayOpacity / 100 ), 420 overlayColor: args.overlayColor, 421 titleShow: ( args.titleShow === '1' ? true : false ), 422 titlePosition: args.titlePosition, 423 transitionIn: args.transitions, 424 transitionOut: args.transitions, 425 easingIn: args.easings, 426 easingOut: args.easings, 427 speedIn: parseInt( args.speeds ), 428 speedOut: parseInt( args.speeds ), 429 changeSpeed: parseInt( args.changeSpeed ), 430 changeFade: parseInt( args.changeFade ), 431 padding: parseInt( args.padding ), 432 margin: parseInt( args.margin ), 433 width: parseInt( args.videoWidth ), 434 height: parseInt( args.videoHeight ), 435 onComplete: function() { 436 last_image = $( '#fancybox-content' ).find( 'img' ).attr( 'src' ); 437 438 // trigger image view 439 rl_view_image( script, last_image ); 440 }, 441 onClosed: function() { 442 // trigger image hide 443 rl_hide_image( script, last_image ); 444 } 445 } ); 446 447 break; 448 449 case 'nivo': 450 $.each( $( 'a[rel*="' + selector + '"], a[data-rel*="' + selector + '"]' ), function() { 451 var attr = $( this ).attr( 'data-rel' ); 452 453 // check data-rel attribute first 454 if ( typeof attr === 'undefined' || attr == false ) { 455 // if not found then try to check rel attribute for backward compatibility 456 attr = $( this ).attr( 'rel' ); 457 } 458 459 // for some browsers, `attr` is undefined; for others, `attr` is false. Check for both. 460 if ( typeof attr !== 'undefined' && attr !== false ) { 461 var match = attr.match( new RegExp( selector + '\\-(gallery\\-(?:[\\da-z]{1,4}))', 'ig' ) ); 462 463 if ( match !== null ) 464 $( this ).attr( 'data-lightbox-gallery', match[0] ); 465 } 466 } ); 467 468 var observer_initialized = false; 469 var change_allowed = true; 470 var 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 var 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 = _.uniq( 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 var 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 = _.uniq( 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.on( '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.on( '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 var 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 = _.uniq( 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: '❮', 710 nextIcon: '❯' 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 var 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 = _.uniq( selectors ); 746 747 $( selectors ).each( function( i, item ) { 748 var subselector = $( 'a[data-rel="' + item + '"], a[rel="' + item + '"]' ); 749 var element = $( subselector[0] ); 750 var media_type = element.data( 'magnific_type' ); 751 var 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 // then media type if needed 758 if ( typeof media_type === 'undefined' ) 759 media_type = 'image'; 760 761 subselector.magnificPopup( { 762 type: media_type === 'gallery' ? 'image' : ( media_type === 'video' ? 'iframe' : media_type ), 763 disableOn: args.disableOn, 764 midClick: args.midClick === '1', 765 preloader: args.preloader === '1', 766 closeOnContentClick: args.closeOnContentClick === '1', 767 closeOnBgClick: args.closeOnBgClick === '1', 768 closeBtnInside: args.closeBtnInside === '1', 769 showCloseBtn: args.showCloseBtn === '1', 770 enableEscapeKey: args.enableEscapeKey === '1', 771 alignTop: args.alignTop === '1', 772 autoFocusLast: args.autoFocusLast === '1', 773 fixedContentPos: args.fixedContentPos === 'auto' ? 'auto' : ( args.fixedContentPos === '1' ), 774 fixedBgPos: args.fixedBgPos === 'auto' ? 'auto' : ( args.fixedBgPos === '1' ), 775 image: { 776 titleSrc: function( item ) { 777 return item.el.attr( 'data-rl_title' ) + '<small>' + item.el.attr( 'data-rl_caption' ) + '</small>'; 778 } 779 }, 780 gallery: { 781 enabled: subselector.length > 1 && media_type === 'gallery', 782 navigateByImgClick: true, 783 preload: [0,1] 784 }, 785 callbacks: { 786 close: function() { 787 rl_hide_image( script, this.currItem.src ); 788 }, 789 imageLoadComplete: function() { 790 // trigger image view 791 rl_view_image( script, this.currItem.src ); 792 } 793 } 794 } ); 795 } ); 796 } 797 break; 798 } 799 } ); 800 801} )( jQuery );
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.