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