1jQuery( document ).ready( function($) { 2 // This script is loaded both on the frontend page and in the Visual Builder. 3 $.fn.MasonryGalleryExtendedInsertAt = function( index, element ) { 4 let lastIndex = this.children().length; 5 if ( index < 0 ) { 6 index = Math.max(0, lastIndex + 1 + index); 7 } 8 this.append(element); 9 if ( index < lastIndex ) { 10 this.children().eq(index).before(this.children().last()); 11 } 12 return this; 13 } 14 $.fn.MasonryGalleryExtendedPagination = function( $options = {} ) { 15 let $defaults = { 16 paginationClass: 'el_masonry_gallery_pagination', 17 hideOnlyOnePage: true, 18 totalPages: 1, 19 visiblePages: 10, 20 startPage: 1, 21 initiateStartPageClick: false, 22 first: false, 23 last: false, 24 prev: false, 25 next: false, 26 }, 27 $pagination = this; 28 29 $pagination.twbsPagination( 'destroy' ); 30 31 $options = $.extend( {}, $defaults, $options ); 32 $pagination.twbsPagination( $options ); 33 } 34 35 // Masonry Gallery Script. 36 if ( $(document).find('.el_masonry_gallery').length > 0 ) { 37 $('.el_masonry_gallery').each( function() { 38 dge_init_masonry_gallery( $( this ) ); 39 } ); 40 } 41} ); 42 43// Init masonry gallery. 44function dge_init_masonry_gallery( $this ) { 45 let $ = jQuery, 46 $wrapper = $this.find('.el_masonry_gallery_wrapper'), 47 $inner = $this.find('.el_masonry_gallery_module__inner'); 48 $options = { 49 itemSelector: '.el_masonry_gallery_item', 50 layoutMode: 'masonry', 51 percentPosition: true, 52 resize: true, 53 transitionDuration: parseInt( $wrapper.data('isotope_transition_duration') ), 54 masonry: { 55 columnWidth: '.el_masonry_gallery_item', 56 gutter: '.el_masonry_gallery_item_gutter' 57 } 58 }; 59 60 let masonryLoadTrigger = false; 61 62 // Display again, if it hide due to pagination. 63 $wrapper.find( '.el_masonry_gallery_item' ).css( 'display', 'inline-block' ); 64 65 // Pagination Filter for Isotope. 66 if ( $this.find('.el_masonry_gallery_pagination_wrapper').length > 0 ) { 67 let $paginWrapper = $this.find( '.el_masonry_gallery_pagination_wrapper' ), 68 $perPage = $paginWrapper.attr( 'data-images_per_page' ); 69 70 $options.filter = function() { 71 let $index = $(this).index(); 72 return parseInt($index) > 0 && parseInt($index) <= $perPage; 73 } 74 } 75 76 let $gallery = $inner.isotope( $options ); 77 $gallery.imagesLoaded( function() { 78 $gallery.isotope( 'layout' ); 79 $gallery.isotope( 'reloadItems' ); 80 } ); 81 82 // Pagination. 83 if ( $this.find( '.el_masonry_gallery_pagination_wrapper ul' ).length > 0 ) { 84 let $paginWrapper = $this.find('.el_masonry_gallery_pagination_wrapper'), 85 $pagination = $paginWrapper.find('ul'), 86 $perPage = isNaN( $paginWrapper.attr('data-images_per_page') ) || 0 === parseInt( $paginWrapper.attr('data-images_per_page') ) ? 12 : parseInt( $paginWrapper.attr('data-images_per_page') ), 87 $totalPages = parseInt( Math.ceil( parseInt( $paginWrapper.data('total_images') ) / $perPage ) ), 88 $options = { 89 totalPages: $totalPages, 90 onPageClick: function (event, page) { 91 let $startIndex = 0; 92 let $endIndex = $perPage; 93 if ( 1 !== page ) { 94 $startIndex = ( $perPage * ( page - 1 ) ); 95 $endIndex = $perPage * page; 96 } 97 $gallery.isotope( { 98 filter: function() { 99 let $index = $(this).index(); 100 return parseInt($index) > $startIndex && parseInt($index) <= $endIndex; 101 } 102 } ).isotope( 'revealItemElements', $wrapper.find('.el_masonry_gallery_item').slice( $startIndex, $endIndex ) ).isotope('layout'); 103 104 if ( $this.offset().top > 0 ) { 105 let topHeaderHeight = 0, 106 mainHeaderHeight = 0, 107 tbHeaderHeight = 0; 108 109 if ( $('body').find('#top-header').length > 0 && $('body').hasClass('et_fixed_nav') ) { 110 topHeaderHeight = parseFloat( $('#top-header').innerHeight() ); 111 } 112 if ( $('body').find('#main-header').length > 0 && $('body').hasClass('et_fixed_nav') ) { 113 mainHeaderHeight = parseFloat( $('#main-header').innerHeight() ); 114 } 115 if ( $('body').find('.et-l--header').length > 0 && $('body').find('.et-l--header .et_builder_inner_content').hasClass('has_et_pb_sticky') ) { 116 tbHeaderHeight = parseFloat( $('.et-l--header').innerHeight() ); 117 } 118 119 let headerHeight = topHeaderHeight + mainHeaderHeight + tbHeaderHeight + 50; 120 $( 'html, body' ).animate( { 121 scrollTop: ( $this.offset().top - headerHeight ) 122 } ); 123 } 124 } 125 }; 126 127 if ( 'on' === $paginWrapper.attr('data-show_prev_next') ) { 128 $options.prev = $paginWrapper.attr('data-prev_text'); 129 $options.next = $paginWrapper.attr('data-next_text'); 130 } 131 if ( $perPage && '' !== $perPage && ! isNaN( $perPage ) ) { 132 $pagination.MasonryGalleryExtendedPagination( $options ); 133 } 134 } 135 136 // Load more button instead of pagination. 137 if ( $this.find('.el_masonry_gallery_pagination_wrapper .el-masonry-gallery-load-more').length > 0 ) { 138 const $paginWrapper = $this.find('.el_masonry_gallery_pagination_wrapper'); 139 const $perPage = isNaN( $paginWrapper.data('images_per_page') ) || 0 === parseInt( $paginWrapper.data('images_per_page') ) ? 12 : parseInt( $paginWrapper.data('images_per_page') ); 140
141 $this.on( 'click', '.el-masonry-gallery-load-more', function() { 142 143 // Check if active category. 144 const activeCat = $wrapper.find( '.el_masonry_gallery_filter_categories .el_masonry_gallery_active_category' ).attr( 'data-category' ); 145 146 // Get total images. 147 let totalImages = $paginWrapper.attr( 'data-total_images' ); 148 if ( activeCat && '' !== activeCat ) { 149 totalImages = $wrapper.find( '.el_masonry_gallery_item' ).length; 150 } 151 152 // Calculate total pages. 153 const $totalPages = parseInt( Math.ceil( parseInt( totalImages ) / $perPage ) ); 154 155 let page = parseInt( $paginWrapper.attr( 'data-load-page' ) ); 156 157 // If all pages are visibled. 158 if ( page > $totalPages ) { 159 $( this ).hide(); 160 return; 161 } 162 163 let $startIndex = 0; 164 let $endIndex = $perPage; 165 if ( 1 !== page ) { 166 $endIndex = $perPage * page; 167 } 168 169 $gallery.isotope( { 170 filter: function() { 171 let $index = $(this).index(); 172 return parseInt($index) > $startIndex && parseInt($index) <= $endIndex; 173 } 174 } ).isotope( 'revealItemElements', $wrapper.find('.el_masonry_gallery_item').slice( $startIndex, $endIndex ) ).isotope( 'layout' ); 175 176 // If all pages are visibled. 177 if ( page == $totalPages ) { 178 $( this ).hide(); 179 } 180 181 $paginWrapper.attr( 'data-load-page', ( parseInt( page ) + 1 ) ); 182 } ); 183 } 184 185 // Category Filter. 186 let $detachedImages = []; 187 let $detachedIndices = []; 188 $this.find( '.el_masonry_gallery_filter_categories li' ).on( 'click', function() { 189 if ( $(this).hasClass( 'el_masonry_gallery_active_category' ) ) { 190 return false; 191 } 192 193 if ( $detachedImages && $detachedIndices && $detachedIndices.length === $detachedImages.length ) { 194 $.map( $detachedImages, function( value, key ) { 195 $inner.MasonryGalleryExtendedInsertAt( $detachedIndices[key], $(value) ); 196 } ); 197 } else if ( $detachedImages ) { 198 $inner.append( $detachedImages ); 199 } 200 201 $(this).parent( '.el_masonry_gallery_filter_categories' ).find( 'li' ).removeClass( 'el_masonry_gallery_active_category' ); 202 $(this).addClass( 'el_masonry_gallery_active_category' ); 203 let $category = $(this).data( 'category' ); 204 205 if ( '' !== $category ) { 206 let $elements = []; 207 $inner.find( '.el_masonry_gallery_item img' ).each( function() { 208 if ( $(this).data('categories') ) { 209 let $imageCats = $(this).attr('data-categories').split(','); 210 $imageCats = $.map( $imageCats, function( a ) { 211 return parseInt(a); 212 } ); 213 if ( -1 === $.inArray( $category, $imageCats ) ) { 214 $detachedIndices.push( $(this).closest('.el_masonry_gallery_item').index() ); 215 } else { 216 $elements.push( $(this).closest('.el_masonry_gallery_item') ); 217 } 218 } else { 219 $detachedIndices.push( $(this).closest('.el_masonry_gallery_item').index() ); 220 } 221 } ); 222 223 $gallery.isotope( { 224 filter: function() { 225 if ( $(this).find('img').data('categories') ) { 226 let $imageCats = $(this).find('img').attr('data-categories').split(','); 227 $imageCats = $.map( $imageCats, function( a ) { 228 return parseInt( a ); 229 } ); 230 if ( -1 !== $.inArray( $category, $imageCats ) ) { 231 return $( this ); 232 } else { 233 $detachedImages.push( $(this).detach() ); 234 } 235 } else { 236 $detachedImages.push( $(this).detach() ); 237 } 238 } 239 } ).isotope( 'revealItemElements', $elements ).isotope( 'layout' ); 240 241 // Re-render Pagination. 242 if ( $this.find( '.el_masonry_gallery_pagination_wrapper ul' ).length > 0 ) { 243 let $paginWrapper = $this.find( '.el_masonry_gallery_pagination_wrapper' ), 244 $pagination = $paginWrapper.find('ul'), 245 $perPage = isNaN( $paginWrapper.attr('data-images_per_page') ) || 0 === parseInt( $paginWrapper.attr('data-images_per_page') ) ? 12 : parseInt( $paginWrapper.attr('data-images_per_page') ), 246 $totalPages = parseInt( Math.ceil( parseInt( $wrapper.find('.el_masonry_gallery_item').length ) / $perPage ) ), 247 $options = { 248 totalPages: $totalPages, 249 initiateStartPageClick: true, 250 onPageClick: function (event, page) { 251 let $startIndex = 0; 252 let $endIndex = $perPage; 253 if ( 1 !== page ) { 254 $startIndex = ( $perPage * ( page - 1 ) ); 255 $endIndex = $perPage * page; 256 } 257 $gallery.isotope({ 258 filter: function() { 259 let $index = $(this).index(); 260 return parseInt($index) > $startIndex && parseInt($index) <= $endIndex; 261 } 262 } ).isotope( 'revealItemElements', $wrapper.find('.el_masonry_gallery_item').slice( $startIndex, $endIndex ) ).isotope('layout'); 263 264 if ( $this.offset().top > 0 && masonryLoadTrigger === true ) { 265 let topHeaderHeight = 0, 266 mainHeaderHeight = 0, 267 tbHeaderHeight = 0; 268 269 if ( $('body').find('#top-header').length > 0 && $('body').hasClass('et_fixed_nav') ) { 270 topHeaderHeight = parseFloat( $('#top-header').innerHeight() ); 271 } 272 if ( $('body').find('#main-header').length > 0 && $('body').hasClass('et_fixed_nav') ) { 273 mainHeaderHeight = parseFloat( $('#main-header').innerHeight() ); 274 } 275 if ( $('body').find('.et-l--header').length > 0 && $('body').find('.et-l--header .et_builder_inner_content').hasClass('has_et_pb_sticky') ) { 276 tbHeaderHeight = parseFloat( $('.et-l--header').innerHeight() ); 277 } 278 279 let headerHeight = topHeaderHeight + mainHeaderHeight + tbHeaderHeight + 50; 280 $( 'html, body' ).animate( { 281 scrollTop: ( $this.offset().top - headerHeight ) 282 } ); 283 } 284 masonryLoadTrigger = true; 285 } 286 }; 287 288 if ( 'on' === $paginWrapper.attr('data-show_prev_next') ) { 289 $options.prev = $paginWrapper.attr('data-prev_text'); 290 $options.next = $paginWrapper.attr('data-next_text'); 291 } 292 293 $pagination.MasonryGalleryExtendedPagination( $options ); 294 295 } else if ( $this.find('.el_masonry_gallery_pagination_wrapper .el-masonry-gallery-load-more').length > 0 ) { 296 // Re-render Load more. 297 let $paginWrapper = $this.find( '.el_masonry_gallery_pagination_wrapper' ), 298 $pagination = $paginWrapper.find( '.el-masonry-gallery-load-more' ), 299 $perPage = isNaN( $paginWrapper.attr('data-images_per_page') ) || 0 === parseInt( $paginWrapper.attr('data-images_per_page') ) ? 12 : parseInt( $paginWrapper.attr('data-images_per_page') ), 300 $totalPages = parseInt( Math.ceil( parseInt( $wrapper.find('.el_masonry_gallery_item').length ) / $perPage ) ); 301 302 $pagination.hide(); 303 if ( $totalPages > 1 ) { 304 $paginWrapper.attr( 'data-total_images', parseInt( $wrapper.find('.el_masonry_gallery_item').length ) ); 305 $paginWrapper.attr( 'data-load-page', 2 ); 306 307 $gallery.isotope( { 308 filter: function() { 309 let $index = $(this).index(); 310 return parseInt($index) > 0 && parseInt($index) <= $perPage; 311 } 312 } ).isotope( 'revealItemElements', $wrapper.find('.el_masonry_gallery_item').slice( 0, $perPage ) ).isotope('layout'); 313 $pagination.show(); 314 } 315 } 316 } else { 317 318 $gallery.isotope( { filter: '*' } ); 319 320 // Re-render Pagination. 321 if ( $this.find( '.el_masonry_gallery_pagination_wrapper ul' ).length > 0 ) { 322 let $paginWrapper = $this.find( '.el_masonry_gallery_pagination_wrapper' ), 323 $pagination = $paginWrapper.find('ul'), 324 $perPage = isNaN( $paginWrapper.attr('data-images_per_page') ) || 0 === parseInt( $paginWrapper.attr('data-images_per_page') ) ? 12 : parseInt( $paginWrapper.attr('data-images_per_page') ), 325 $totalPages = parseInt( Math.ceil( parseInt( $paginWrapper.data('total_images') ) / $perPage ) ), 326 $options = { 327 totalPages: $totalPages, 328 initiateStartPageClick: true, 329 onPageClick: function (event, page) { 330 let $startIndex = 0; 331 let $endIndex = $perPage; 332 if ( 1 !== page ) { 333 $startIndex = ( $perPage * ( page - 1 ) ); 334 $endIndex = $perPage * page; 335 } 336 $gallery.isotope( { 337 filter: function() { 338 let $index = $(this).index(); 339 return parseInt($index) > $startIndex && parseInt($index) <= $endIndex; 340 } 341 } ).isotope( 'revealItemElements', $wrapper.find( '.el_masonry_gallery_item' ).slice( $startIndex, $endIndex ) ).isotope('layout'); 342 } 343 }; 344 345 if ( 'on' === $paginWrapper.attr('data-show_prev_next') ) { 346 $options.prev = $paginWrapper.attr('data-prev_text'); 347 $options.next = $paginWrapper.attr('data-next_text'); 348 } 349 350 $pagination.MasonryGalleryExtendedPagination( $options ); 351 } else if ( $this.find('.el_masonry_gallery_pagination_wrapper .el-masonry-gallery-load-more').length > 0 ) { 352 // Re-render Load more. 353 let $paginWrapper = $this.find( '.el_masonry_gallery_pagination_wrapper' ), 354 $pagination = $paginWrapper.find( '.el-masonry-gallery-load-more' ), 355 $perPage = isNaN( $paginWrapper.attr('data-images_per_page') ) || 0 === parseInt( $paginWrapper.attr('data-images_per_page') ) ? 12 : parseInt( $paginWrapper.attr('data-images_per_page') ), 356 $totalPages = parseInt( Math.ceil( parseInt( $wrapper.find('.el_masonry_gallery_item').length ) / $perPage ) ); 357 358 $pagination.hide(); 359 if ( $totalPages > 1 ) { 360 $paginWrapper.attr( 'data-total_images', parseInt( $wrapper.find('.el_masonry_gallery_item').length ) ); 361 $paginWrapper.attr( 'data-load-page', 2 ); 362 363 $gallery.isotope( { 364 filter: function() { 365 let $index = $(this).index(); 366 return parseInt($index) > 0 && parseInt($index) <= $perPage; 367 } 368 } ).isotope( 'revealItemElements', $wrapper.find('.el_masonry_gallery_item').slice( 0, $perPage ) ).isotope('layout'); 369 $pagination.show(); 370 } 371 } 372 } 373 } ); 374 375 // Lightbox. 376 if ( 'on' === $wrapper.data('click_trigger') || 'lightbox' === $wrapper.data('click_trigger') || 'zoom_n_link' === $wrapper.data('click_trigger') ) { 377 let $orderClass = $this.prop('class').match(/(el_masonry_gallery\_[^\s]*)/)[0] + '_lightbox', 378 $effect = $wrapper.data('lightbox_effect'), 379 $zoom = 'zoom' === $effect ? true : false, 380 $duration = 'none' !== $effect ? parseInt( $wrapper.data('lightbox_transition_duration') ) : 0, 381 $navigation = 'on' === $wrapper.data('enable_navigation') ? true : false, 382 $mainClass = 'mfp-img-mobile el_masonry_gallery_lightbox ' + $orderClass + ' dge_mfp_' + $effect, 383 $prependTo = $( 'body' ); 384 385 if ( $('body').hasClass('et-tb-has-template') ) { 386 if ( $orderClass.includes('_tb_header') ) { 387 $prependTo = $('body').find('#page-container').find('#et-boc .et-l--header'); 388 } else if ( $orderClass.includes('_tb_body') ) { 389 $prependTo = $('body').find('#page-container').find('#et-boc .et-l--body'); 390 } else if ( $orderClass.includes('_tb_footer') ) { 391 $prependTo = $('body').find('#page-container').find('#et-boc .et-l--footer'); 392 } 393 } 394 395 let clickDeligate = '.el_masonry_gallery_item'; 396 if ( 'zoom_n_link' === $wrapper.data('click_trigger') ) { 397 clickDeligate = '.dge-overlay-lightbox'; 398 } 399 400 $inner.on( 'click', '.el_masonry_gallery_item', function(e) { 401 e.stopPropagation(); 402 } ); 403 404 $inner.magnificPopup( { 405 delegate: clickDeligate, 406 type: 'image', 407 prependTo: $prependTo, 408 closeOnContentClick: false, 409 removalDelay: $duration, 410 closeBtnInside: false, 411 mainClass: $mainClass, 412 gallery: { 413 enabled: $navigation, 414 navigateByImgClick: false, 415 tPrev: '', 416 tNext: '', 417 tCounter: '' 418 }, 419 zoom: { 420 enabled: $zoom, 421 duration: $duration, 422 easing: 'ease-in-out', 423 opener: function(element) { 424 return element; 425 } 426 }, 427 image: { 428 markup: '<div class="mfp-figure">' + 429 '<div class="mfp-close"></div>' + 430 '<div class="mfp-img"></div>' + 431 '<div class="mfp-bottom-bar">' + 432 '<div class="mfp-title"></div>' + 433 '</div>' + 434 '</div>', 435 titleSrc: function(item) { 436 if ( 'zoom_n_link' === $wrapper.data('click_trigger') ) { 437 return item.el.parents( '.el_masonry_gallery_item' ).find('.el_masonry_gallery_title_caption_wrapper').length > 0 ? item.el.parents( '.el_masonry_gallery_item' ).find('.el_masonry_gallery_title_caption_wrapper').html() : ''; 438 } 439 return item.el.find('.el_masonry_gallery_title_caption_wrapper').length > 0 ? item.el.find('.el_masonry_gallery_title_caption_wrapper').html() : ''; 440 }, 441 tError: 'The <a href="%url%">image</a> could not be loaded.', 442 }, 443 } ); 444
445 let $magnificPopup = $.magnificPopup.instance; 446 let $current_page_navigate = ( $wrapper.data('lightbox_navigate_current') ) ? $wrapper.data('lightbox_navigate_current') : 'on'; 447 $magnificPopup.open = function(data) { 448 if ( '.el_masonry_gallery_item' === data.delegate ) { 449 let $items = []; 450 $.each( data.items, function( key, value ) { 451 if ( ( $(value).is(':visible') && 0 !== parseFloat( $(value).css('opacity') ) ) || 'on' !== $current_page_navigate ) { 452 $items.push(value); 453 } 454 } ); 455 data.items = $( $items ); 456 } 457 $.magnificPopup.proto.open.call( this, data ); 458 }; 459 460 $('body').on( 'swiperight', '.el_masonry_gallery_lightbox .mfp-img', function() { 461 $magnificPopup.prev(); 462 } ); 463 $('body').on( 'swipeleft', '.el_masonry_gallery_lightbox .mfp-img', function() { 464 $magnificPopup.next(); 465 } ); 466 } 467}
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.