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