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