1(function ($) { 2 "use strict"; 3 // animations 4 window.bt_bb_animate_elements = function () { 5 var $elems = $('.animate:not(.animated)'); 6 $elems.each(function () { 7 var $elm = $(this); 8 if (isOnScreen($elm)) { 9 $elm.addClass('animated'); 10 if ($elm.hasClass('bt_bb_counter')) { 11 bt_bb_animate_counter($elm); 12 } 13 if (typeof window.local_bt_bb_animate_elements == 'function') { 14 local_bt_bb_animate_elements($elm); 15 } 16 } 17 }); 18 bt_bb_lazy_load_images(); 19 $('.slick-slider .slick-slide:not(.slick-active) .animate').removeClass('animated'); 20 } 21 22 window.bt_bb_animate_elements_optim = function () { 23 24 const options = { 25 root: null, 26 rootMargin: "0px", 27 treshold: 0, 28 }; 29 30 const targetElements_anim = document.querySelectorAll( 31 ".animate:not(.animated)" 32 ); 33 34 const observer_animation = new IntersectionObserver(function ( 35 entries, 36 observer 37 ) { 38 entries.forEach((entry) => { 39 if (entry.isIntersecting) { 40 $(entry.target).addClass("animated"); 41 if ($(entry.target).hasClass("bt_bb_counter")) { 42 bt_bb_animate_counter($(entry.target)); 43 } 44 if (typeof window.local_bt_bb_animate_elements == "function") { 45 local_bt_bb_animate_elements($(entry.target)); 46 } 47 48 observer_animation.unobserve(entry.target); 49 } 50 }); 51 }, 52 options); 53 54 targetElements_anim.forEach((element) => { 55 observer_animation.observe(element); 56 }); 57 58 //bt_bb_lazy_load_images(); 59 $(".slick-slider .slick-slide:not(.slick-active) .animate").removeClass( 60 "animated" 61 ); 62 }; 63 64 // lazy image load 65 window.bt_bb_lazy_load_images = function () { 66 var $elems = $('img.btLazyLoadImage:not(.btLazyLoaded)'); 67 $elems.each(function () { 68 var $elm = $(this); 69 if (isOnScreen($elm, -200)) { 70 $elm.addClass('btLazyLoaded'); 71 $elm.attr('src', $elm.data('image_src')); 72 } 73 }); 74 var $elems = $('image.btLazyLoadImage:not(.btLazyLoaded)'); 75 $elems.each(function () { 76 var $elm = $(this); 77 if (isOnScreen($elm, -200)) { 78 $elm.addClass('btLazyLoaded'); 79 $elm.attr('xlink:href', $elm.data('image_src')); 80 } 81 }); 82 var $elems = $('.btLazyLoadBackground:not(.btLazyLoaded)'); 83 $elems.each(function () { 84 var $elm = $(this); 85 if (isOnScreen($elm, -200)) { 86 $elm.addClass('btLazyLoaded'); 87 $elm.css('background-image', 'url(' + $elm.data('background_image_src') + ')'); 88 } 89 }); 90 } 91 92 window.bt_bb_lazy_load_images_optim = function () { 93 94 const options = { 95 root: null, 96 rootMargin: "200px", 97 treshold: 0, 98 }; 99 100 const targetElements1_load = document.querySelectorAll( 101 "img.btLazyLoadImage:not(.btLazyLoaded)" 102 ); 103 104 const observer1_load = new IntersectionObserver(function ( 105 entries, 106 observer 107 ) { 108 entries.forEach((entry) => { 109 if (entry.isIntersecting) { 110 111 $(entry.target).addClass("btLazyLoaded"); 112 $(entry.target).attr("src", $(entry.target).data("image_src")); 113 114 observer1_load.unobserve(entry.target); 115 } 116 }); 117 }, 118 options); 119 120 targetElements1_load.forEach((element) => { 121 observer1_load.observe(element); 122 }); 123 124 const targetElements2_load = document.querySelectorAll( 125 "image.btLazyLoadImage:not(.btLazyLoaded)" 126 ); 127 128 const observer2_load = new IntersectionObserver(function ( 129 entries, 130 observer 131 ) { 132 entries.forEach((entry) => { 133 if (entry.isIntersecting) { 134 135 $(entry.target).addClass("btLazyLoaded"); 136 $(entry.target).attr("xlink:href", $(entry.target).data("image_src")); 137 138 observer2_load.unobserve(entry.target); 139 } 140 }); 141 }, 142 options); 143 144 targetElements2_load.forEach((element) => { 145 observer2_load.observe(element); 146 }); 147 148 const targetElements3_load = document.querySelectorAll( 149 ".btLazyLoadBackground:not(.btLazyLoaded)" 150 ); 151 152 const observer3_load = new IntersectionObserver(function ( 153 entries, 154 observer 155 ) { 156 entries.forEach((entry) => { 157 if (entry.isIntersecting) { 158 159 $(entry.target).addClass("btLazyLoaded"); 160 $(entry.target).css( 161 "background-image", 162 "url(" + $(entry.target).data("background_image_src") + ")" 163 ); 164 165 observer3_load.unobserve(entry.target); 166 } 167 }); 168 }, 169 options); 170
171 targetElements3_load.forEach((element) => { 172 observer3_load.observe(element); 173 }); 174 }; 175 176 // css image grid lighbox 177 178 window.bt_bb_init_css_image_grid_lightbox = function () { 179 $('.bt_bb_css_image_grid').not('.bt_bb_no_lightbox').each(function () { 180 $(this).magnificPopup({ 181 delegate: '.bt_bb_css_image_grid_item', 182 type: 'image', 183 gallery: { 184 enabled: true 185 }, 186 callbacks: { 187 elementParse: function (item) { item.src = item.el.data('src-full'); } 188 }, 189 closeBtnInside: false, 190 fixedContentPos: false 191 }); 192 }); 193 } 194 195 // new startup 196 197 window.bt_bb_init_css_image_grid_lightbox_startup = function () { 198 const options = { 199 root: null, 200 rootMargin: "200px", 201 treshold: 0, 202 }; 203 204 const targetElements_imageGridLightBox = document.querySelectorAll( 205 ".bt_bb_css_image_grid:not(.bt_bb_no_lightbox)" 206 ); 207 208 const observer_imageGridLightBox = new IntersectionObserver(function ( 209 entries, 210 observer 211 ) { 212 entries.forEach((entry) => { 213 if (entry.isIntersecting) { 214 215 $(entry.target).magnificPopup({ 216 delegate: ".bt_bb_css_image_grid_item", 217 type: "image", 218 gallery: { 219 enabled: true, 220 }, 221 callbacks: { 222 elementParse: function (item) { 223 item.src = item.el.data("src-full"); 224 }, 225 }, 226 closeBtnInside: false, 227 fixedContentPos: false, 228 }); 229 230 observer_imageGridLightBox.unobserve(entry.target); 231 } 232 }); 233 }, 234 options); 235 236 targetElements_imageGridLightBox.forEach((element) => { 237 observer_imageGridLightBox.observe(element); 238 }); 239 }; 240 241 // tabs 242 243 window.bt_bb_init_tabs = function () { 244 $('.bt_bb_tabs').not('.bt_bb__inited').each(function () { 245 $(this).addClass('bt_bb__inited'); 246 $(this).find('.bt_bb_tabs_header').on('click', 'li', function () { 247 $(this).siblings().removeClass('on'); 248 $(this).addClass('on'); 249 $(this).closest('.bt_bb_tabs').children('.bt_bb_tabs_tabs').children('.bt_bb_tab_item').removeClass('on'); 250 $(this).closest('.bt_bb_tabs').children('.bt_bb_tabs_tabs').children('.bt_bb_tab_item').eq($(this).index()).addClass('on'); 251 }); 252 $(this).find('li').first().trigger('click'); 253 }); 254 } 255 256 // new startup 257 258 window.bt_bb_init_tabs_startup = function () { 259 const options = { 260 root: null, 261 rootMargin: "200px", 262 treshold: 0, 263 }; 264 265 const targetElements_Tabs = document.querySelectorAll( 266 ".bt_bb_tabs:not(.bt_bb__inited)" 267 ); 268 269 const observer_Tabs = new IntersectionObserver(function ( 270 entries, 271 observer 272 ) { 273 entries.forEach((entry) => { 274 if (entry.isIntersecting) { 275 276 $(entry.target).addClass("bt_bb__inited"); 277 $(entry.target) 278 .find(".bt_bb_tabs_header") 279 .on("click", "li", function () { 280 $(this).siblings().removeClass("on"); 281 $(this).addClass("on"); 282 $(this) 283 .closest(".bt_bb_tabs") 284 .children(".bt_bb_tabs_tabs") 285 .children(".bt_bb_tab_item") 286 .removeClass("on"); 287 $(this) 288 .closest(".bt_bb_tabs") 289 .children(".bt_bb_tabs_tabs") 290 .children(".bt_bb_tab_item") 291 .eq($(this).index()) 292 .addClass("on"); 293 }); 294 $(entry.target).find("li").first().trigger("click"); 295 296 observer_Tabs.unobserve(entry.target); 297 } 298 }); 299 }, 300 options); 301 302 targetElements_Tabs.forEach((element) => { 303 observer_Tabs.observe(element); 304 }); 305 }; 306 307 // isOnScreen fixed 308 309 function iOSversion() { 310 if (/iP(hone|od|ad)/.test(navigator.platform)) { 311 // supports iOS 2.0 and later: <http://bit.ly/TJjs1V> 312 var v = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/); 313 return [parseInt(v[1], 10), parseInt(v[2], 10), parseInt(v[3] || 0, 10)]; 314 } else { 315 return false; 316 } 317 } 318 319 var ver = iOSversion(); 320 321 // isOnScreen 322 323 function isOnScreen(elem, top_offset) { 324 if (ver && ver[0] == 13) return true; 325 top_offset = (top_offset === undefined) ? 75 : top_offset; 326 var element = elem.get(0); 327 if (element == undefined) return false; 328 var bounds = element.getBoundingClientRect(); 329 var output = bounds.top + top_offset < window.innerHeight && bounds.bottom > 0; 330 // alert(output); 331 return output; 332 } 333 334 // animate counter 335 336 function bt_bb_animate_counter($elm) { 337 var number_length = $elm.data('digit-length'); 338 for (var i = parseInt(number_length); i > 0; i--) { 339 var digit = parseInt($elm.children('.p' + i).data('digit')); 340 if (digit == 0) digit = 10; 341 if (isNaN(digit)) digit = 10; 342 for (var j = 0; j <= digit; j++) { 343 $elm.children('.p' + i).css('transform', 'translateY(-' + digit * $elm.outerHeight() + 'px)'); 344 } 345 $elm.addClass('animated'); 346 } 347 348 return false;
349 } 350 351 // paralax helpers 352 353 window.bt_bb_requestAnimFrame = function () { 354 return ( 355 window.requestAnimationFrame || 356 window.webkitRequestAnimationFrame || 357 window.mozRequestAnimationFrame || 358 window.oRequestAnimationFrame || 359 window.msRequestAnimationFrame || 360 function (callback) { 361 window.setTimeout(callback, 1000 / 60); 362 } 363 ); 364 }(); 365 366 function bt_clamp_number(val, min, max) { 367 return val > max ? max : val < min ? min : val; 368 } 369 370 var is_edge = navigator.userAgent.indexOf('Edge') > -1; 371 var is_chrome = navigator.userAgent.indexOf('Chrome') > -1; 372 var is_safari = navigator.userAgent.indexOf('Safari') > -1; 373 var is_firefox = navigator.userAgent.indexOf('Firefox') > -1; 374 if (is_chrome && is_safari) window.is_safari = false; 375 var chrome_version = false; 376 // alert( navigator.userAgent ); 377 // if ( is_chrome ) chrome_version = /Chrome\/([0-9]+)/.exec(navigator.userAgent)[1]; 378 379 window.bt_bb_raf_loop = function () { 380 var win_w = window.innerWidth; 381 var win_h = window.innerHeight; 382 const SPEED_DELTA = 0.0001; 383 384 $('html.bt_bb_backgroud_fixed_supported .bt_bb_parallax').each(function () { 385 if ( window.bt_bb_res !== 'xxl' && window.bt_bb_res !== 'xl') { 386 $(this)[0].style.backgroundPosition = 'center center'; 387 return false; 388 } else { 389 var bounds = $(this).hasClass('bt_bb_background_image_holder') ? this.parentElement.getBoundingClientRect() : this.getBoundingClientRect(); 390 391 if (bounds.top < win_h && bounds.bottom > 0) { 392 var speed = parseFloat($(this).attr('data-parallax')) + SPEED_DELTA; 393 if (speed == 2 + SPEED_DELTA) { 394 // if ( false ) { 395 // skip parallax, use fixed background 396 $(this)[0].style.backgroundAttachment = 'fixed'; 397 } else { 398 399 var offset = parseFloat($(this).attr('data-parallax-offset')); 400 var ypos = offset - bounds.top * speed / 2; 401 ypos = (ypos > -0.5 && ypos < 0.5) ? 0 : ypos; 402 403 $(this)[0].style.backgroundPositionY = Math.round(ypos) + 'px'; 404 } 405 406 // temp if, to support old sections 407 if ($(this).hasClass('bt_bb_background_image_holder')) { 408 409 var bounds_mid = (bounds.top + bounds.bottom) / 2; 410 var scroll_distance = (bounds_mid - win_h / 2) / (win_h); 411 scroll_distance = bt_clamp_number(scroll_distance, 0, 1); 412 413 var ZOOM_START = parseFloat($(this).attr('data-parallax-zoom-start')); 414 var ZOOM_END = parseFloat($(this).attr('data-parallax-zoom-end')); 415 416 if (ZOOM_START >= 0 && ZOOM_END >= 0 && (ZOOM_START != 1 || ZOOM_END != 1)) { 417 var zoom = ZOOM_START + (ZOOM_END - ZOOM_START) * (1 - scroll_distance); 418 $(this)[0].style.transform = ' scale(' + zoom + ')'; 419 } 420 421 var BLUR_START = parseFloat($(this).attr('data-parallax-blur-start')); 422 var BLUR_END = parseFloat($(this).attr('data-parallax-blur-end')); 423 424 if (BLUR_START >= 0 && BLUR_END >= 0 && (BLUR_START != 0 || BLUR_END != 0)) { 425 var blur = BLUR_START + (BLUR_END - BLUR_START) * (1 - scroll_distance); 426 $(this)[0].style.filter = ' blur(' + blur + 'px)'; 427 } 428 429 var OPACITY_START = parseFloat($(this).attr('data-parallax-opacity-start')); 430 var OPACITY_END = parseFloat($(this).attr('data-parallax-opacity-end')); 431 432 if (OPACITY_START >= 0 && OPACITY_END >= 0 && (OPACITY_START != 1 || OPACITY_END != 1)) { 433 var opacity = OPACITY_START + (OPACITY_END - OPACITY_START) * (1 - scroll_distance); 434 $(this)[0].style.opacity = opacity; 435 } 436 } 437 } 438 } 439 }); 440 window.bt_bb_raf_lock = false; 441 } 442 443 // touch screen detect 444 445 window.bt_detect_touch = function () { 446 if (typeof window !== 'undefined') { 447 var bt_has_touch = Boolean( 448 'ontouchstart' in window || 449 window.navigator.maxTouchPoints > 0 || 450 window.navigator.msMaxTouchPoints > 0 || 451 window.DocumentTouch && document instanceof DocumentTouch 452 ); 453 if (bt_has_touch) $('html').addClass('bt_bb_touch'); 454 // Mobile device detection 455 if (/Mobi|Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) { 456 $('html').addClass('bt_bb_mobile'); 457 } 458 } 459 } 460 461 // screen detect 462 463 window.bt_bb_get_screen_resolution = function ( not_resize = false ) { 464 var width = Math.max( document.documentElement.clientWidth, window.innerWidth || 0 ); 465 var res = 'xxl'; 466 if ( width <= 1400 ) res = 'xl'; 467 if ( width <= 1200 ) res = 'lg'; 468 if ( width <= 992) res = 'md'; 469 if ( width <= 768 ) res = 'sm'; 470 if ( width <= 480 ) res = 'xs'; 471 472 window.bt_bb_res = res; 473 474 $( 'html' ).attr( 'data-bt_bb_screen_resolution', window.bt_bb_res ); 475 476 $( '[data-bt-override-class]' ).each(function() { 477 var override_classes = $( this ).data( 'bt-override-class' ); 478 for ( var prefix in override_classes ) { 479 if ( override_classes[ prefix ][ window.bt_bb_res ] !== undefined ) { 480 var new_class = prefix + override_classes[ prefix ][ window.bt_bb_res ]; 481 } else { 482 var new_class = prefix + override_classes[ prefix ]['def']; 483 } 484 $( this ).removeClass( override_classes[ prefix ]['current_class'] ); 485 var animate = false;
486 if ( new_class.includes( ' animate' ) ) { 487 animate = true; 488 if ( not_resize ) $( this ).css( 'transition', 'none' ); 489 } 490 $( this ).addClass( new_class ); 491 if ( animate ) { 492 setTimeout( () => { 493 $( this ).css( 'transition', '' ); 494 }, 0 ); 495 } 496 override_classes[ prefix ]['current_class'] = new_class; 497 $( this ).data( 'override_classes', override_classes ); 498 }; 499 500 }); 501 502 } 503 504 // Test fixed background support for iOS devices 505 506 window.bt_bb_check_ios_fixed_background_support = function () { 507 return (/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream) || 508 (/MacIntel/.test(navigator.platform) && $('html').hasClass('bt_bb_touch')); 509 510 /* /MacIntel/... <- checks iPadPro */ 511 } 512 513 // Test fixed background support 514 515 window.bt_bb_check_fixed_background = function () { 516 var el = document.createElement('div'); 517 try { 518 if (!('backgroundAttachment' in el.style) || bt_bb_check_ios_fixed_background_support()) { 519 $('html').removeClass('bt_bb_backgroud_fixed_supported'); 520 return false; 521 } 522 el.style.backgroundAttachment = 'fixed'; 523 if (('fixed' === el.style.backgroundAttachment)) { 524 $('html').addClass('bt_bb_backgroud_fixed_supported'); 525 return true; 526 } 527 } 528 catch (e) { 529 $('html').removeClass('bt_bb_backgroud_fixed_supported'); 530 return false; 531 } 532 } 533 534 // Countdown timer helpers 535 536 window.bt_bb_countdown = function (elem, selector, i, arr, arr_prev) { 537 538 if (arr[i] !== arr_prev[i] || elem.find(selector).children().eq(0).html() == '') { 539 elem.find(selector).children().addClass('countdown_anim'); 540 elem.find(selector).children().eq(0).html(arr[i]); 541 elem.find(selector).children().eq(1).html(arr_prev[i]); 542 setTimeout(function () { 543 elem.find(selector).children().eq(1).html(elem.find(selector).children().eq(0).html()); 544 elem.find(selector).children().removeClass('countdown_anim'); 545 }, 300); 546 } 547 } 548 549 window.bt_bb_countdown_output = function (elem) { 550 551 var s = elem.attr('data-init-seconds'); 552 if (isNaN(s)) { 553 s = 0; 554 } 555 var delta = s; 556 557 var days = Math.floor(delta / 86400); 558 delta -= days * 86400; 559 560 var hours = Math.floor(delta / 3600) % 24; 561 delta -= hours * 3600; 562 563 var minutes = Math.floor(delta / 60) % 60; 564 delta -= minutes * 60; 565 566 var seconds = delta; 567 568 if (hours < 10) { 569 hours = '0' + hours; 570 } 571 572 if (minutes < 10) { 573 minutes = '0' + minutes; 574 } 575 576 if (seconds < 10) { 577 seconds = '0' + seconds; 578 } 579 580 var seconds_arr_prev = seconds.toString().split(''); 581 var minutes_arr_prev = minutes.toString().split(''); 582 var hours_arr_prev = hours.toString().split(''); 583 584 s = s - 1; 585 if (s < 0) { 586 s = 0; 587 } 588 589 var delta = s; 590 591 var days = Math.floor(delta / 86400); 592 delta -= days * 86400; 593 594 var hours = Math.floor(delta / 3600) % 24; 595 delta -= hours * 3600; 596 597 var minutes = Math.floor(delta / 60) % 60; 598 delta -= minutes * 60; 599 600 var seconds = delta; 601 602 if (hours < 10) { 603 hours = '0' + hours; 604 } 605 606 if (minutes < 10) { 607 minutes = '0' + minutes; 608 } 609 610 if (seconds < 10) { 611 seconds = '0' + seconds; 612 } 613 614 var seconds_arr = seconds.toString().split(''); 615 var minutes_arr = minutes.toString().split(''); 616 var hours_arr = hours.toString().split(''); 617 618 for (var i = 0; i <= 1; i++) { 619 bt_bb_countdown(elem, '.seconds .n' + i, i, seconds_arr, seconds_arr_prev); 620 bt_bb_countdown(elem, '.minutes .n' + i, i, minutes_arr, minutes_arr_prev); 621 bt_bb_countdown(elem, '.hours .n' + i, i, hours_arr, hours_arr_prev); 622 } 623 624 var days_arr = days.toString().split(''); 625 626 var days_html = ''; 627 for (var i = 0; i < days_arr.length; i++) { 628 days_html += '<span>' + days_arr[i] + '</span>'; 629 } 630 631 // Create a text node instead of inserting raw HTML 632 elem.find('.days').html(days_html + '<span class="days_text"><span></span></span>'); 633 634 // Then safely set the text content (not HTML) of the inner span 635 var textContent = elem.find('.days').data('text'); 636 elem.find('.days_text span').text(textContent); // .text() escapes HTML automatically 637 638 elem.attr('data-init-seconds', s); 639 640 } 641 642 function bt_bb_fix_slider_heights() { 643 $('.bt_bb_content_slider.bt_bb_height_keep-height .slick-slider').each(function (index) { 644 $(this).find('.slick-slide').height('auto'); 645 var slickTrack = $(this).find('.slick-track'); 646 var slickTrackHeight = $(slickTrack).height(); 647 $(this).find('.slick-slide').css('height', slickTrackHeight + 'px'); 648 }); 649 } 650 651 function bt_bb_init_elements() { 652 // get row structure 653 654 const options = { 655 root: null, 656 rootMargin: "200px", 657 treshold: 0, 658 }; 659 660 // .bt_bb_section .bt_bb_row 661 662 const targetElements_Row = document.querySelectorAll( 663 ".bt_bb_section .bt_bb_row" 664 ); 665 666 const observer_Row = new IntersectionObserver(function (entries, observer) {
667 entries.forEach((entry) => { 668 if (entry.isIntersecting) { 669 var data_structure = []; 670 $(entry.target).data("structure", "0"); 671 $(entry.target) 672 .find(".bt_bb_column") 673 .each(function (index) { 674 data_structure.push($(this).data("width")); 675 }); 676 677 $(entry.target).attr("data-structure", data_structure.join("-")); 678 679 observer_Row.unobserve(entry.target); 680 } 681 }); 682 }, options); 683 684 targetElements_Row.forEach((element) => { 685 observer_Row.observe(element); 686 }); 687 688 // .bt_bb_row_inner 689 690 const targetElements_RowInner = 691 document.querySelectorAll(".bt_bb_row_inner"); 692 693 const observer_RowInner = new IntersectionObserver(function ( 694 entries, 695 observer 696 ) { 697 entries.forEach((entry) => { 698 if (entry.isIntersecting) { 699 var data_structure = []; 700 $(entry.target).data("structure", "0"); 701 $(entry.target) 702 .find(".bt_bb_column_inner") 703 .each(function (index) { 704 data_structure.push($(this).data("width")); 705 }); 706 $(entry.target).attr("data-structure", data_structure.join("-")); 707 708 observer_RowInner.unobserve(entry.target); 709 } 710 }); 711 }, 712 options); 713 714 targetElements_RowInner.forEach((element) => { 715 observer_RowInner.observe(element); 716 }); 717 718 // slick hands prevArrow, nextArrow, appendArrows and appendDots straight to 719 // jQuery, which builds any string starting with "<" as markup. The PHP side 720 // strips markup out of the "Additional settings" field before it can reach 721 // data-slick, but theme forks of the slider elements carry their own copy of 722 // that code and may not, so re-check here before slick reads the attribute. 723 // The settings slick hands to jQuery, either as markup or as a selector. 724 const bt_bb_slick_jquery_keys = [ 725 "prevArrow", 726 "nextArrow", 727 "appendArrows", 728 "appendDots", 729 "asNavFor", 730 ]; 731 const bt_bb_slick_allowed_tags = ["BUTTON", "DIV", "SPAN", "I", "A"]; 732 const bt_bb_slick_allowed_attrs = [ 733 "type", 734 "class", 735 "aria-label", 736 "tabindex", 737 "role", 738 "title", 739 ]; 740 741 function bt_bb_slick_safe_markup(html) { 742 // A <template> is inert: setting innerHTML parses the markup without 743 // fetching or running anything, so no onerror fires while we clean it. 744 const tpl = document.createElement("template"); 745 tpl.innerHTML = html; 746 747 const walk = function (node) { 748 Array.prototype.slice.call(node.children).forEach(function (el) { 749 if (bt_bb_slick_allowed_tags.indexOf(el.tagName) === -1) { 750 el.parentNode.removeChild(el); 751 return; 752 } 753 Array.prototype.slice.call(el.attributes).forEach(function (attr) { 754 const name = attr.name.toLowerCase(); 755 if ( 756 bt_bb_slick_allowed_attrs.indexOf(name) === -1 && 757 name.indexOf("data-") !== 0 758 ) { 759 el.removeAttribute(attr.name); 760 } 761 }); 762 walk(el); 763 }); 764 }; 765 766 walk(tpl.content); 767 768 return tpl.innerHTML; 769 } 770 771 function bt_bb_sanitize_slick_data(settings) { 772 // A data-slick that is not valid JSON comes back from .data() as a 773 // string; there is nothing for slick to read in it, so leave it alone. 774 if (!settings || typeof settings !== "object") { 775 return settings; 776 } 777 778 Object.keys(settings).forEach(function (key) { 779 const value = settings[key]; 780 781 if (value && typeof value === "object") { 782 bt_bb_sanitize_slick_data(value); // "responsive" nests settings 783 return; 784 } 785 786 if (typeof value !== "string") { 787 return; 788 } 789 790 if (bt_bb_slick_jquery_keys.indexOf(key) !== -1) { 791 if (value.indexOf("<") !== -1) { 792 const safe = bt_bb_slick_safe_markup(value); 793 // Nothing survived the allow list, so there is no arrow to 794 // build. Drop the key and let slick use its own default. 795 if (safe.indexOf("<") === -1) { 796 delete settings[key]; 797 return; 798 } 799 settings[key] = safe; 800 return; 801 } 802 803 // No "<", so jQuery reads it as a CSS selector. A value that is 804 // not one -- including anything the PHP side stripped its markup 805 // out of -- throws inside Sizzle, and that exception escapes 806 // .slick() and stops every later slider on the page from
807 // initialising. Check it here and drop it if it is unusable. 808 try { 809 $(value); 810 } catch (e) { 811 delete settings[key]; 812 } 813 return; 814 } 815 816 // Nothing else in a slick config is meant to be markup. Drop the key 817 // rather than blanking it, so slick falls back to its own default. 818 if (value.indexOf("<") !== -1) { 819 delete settings[key]; 820 } 821 }); 822 823 return settings; 824 } 825 826 // .slick-slider 827 828 const targetElements_Slick = document.querySelectorAll(".slick-slider"); 829 830 const observer_Slick = new IntersectionObserver(function ( 831 entries, 832 observer 833 ) { 834 entries.forEach((entry) => { 835 if (entry.isIntersecting) { 836 bt_bb_sanitize_slick_data($(entry.target).data("slick")); 837 try { 838 $(entry.target).slick(); 839 } catch (e) { 840 // slick throws on a configuration it cannot use. Contain it here so 841 // one bad slider does not stop every later one on the page. 842 if (window.console && window.console.warn) { 843 window.console.warn("bt_bb: slider init failed", e); 844 } 845 } 846 847 $(entry.target) 848 .find(".slick-prev") 849 .on("click", function () { 850 $(this).closest(".slick-slider").slick("slickPause"); 851 }); 852 853 $(entry.target) 854 .find(".slick-next") 855 .on("click", function () { 856 $(this).closest(".slick-slider").slick("slickPause"); 857 }); 858 859 $(entry.target) 860 .find(".slick-dots li") 861 .on("click", function () { 862 $(this).closest(".slick-slider").slick("slickPause"); 863 }); 864 865 $( 866 ".bt_bb_slider.bt_bb_use_lightbox .slick-slider .bt_bb_slider_item" 867 ).on("click", function () { 868 $(this).closest(".slick-slider").slick("slickPause"); 869 }); 870 871 observer_Slick.unobserve(entry.target); 872 } 873 }); 874 }, 875 options); 876 877 targetElements_Slick.forEach((element) => { 878 observer_Slick.observe(element); 879 }); 880 881 // .bt_bb_slider.bt_bb_use_lightbox 882 883 const targetElements_lightBox = document.querySelectorAll( 884 ".bt_bb_slider.bt_bb_use_lightbox" 885 ); 886 887 const observer_lightBox = new IntersectionObserver(function ( 888 entries, 889 observer 890 ) { 891 entries.forEach((entry) => { 892 if (entry.isIntersecting) { 893 894 $(entry.target).magnificPopup({ 895 delegate: ".bt_bb_slider_item:not(.slick-cloned)", 896 type: "image", 897 gallery: { 898 enabled: true, 899 }, 900 callbacks: { 901 elementParse: function (item) { 902 item.src = item.el.data("src-full"); 903 }, 904 }, 905 closeBtnInside: false, 906 fixedContentPos: false, 907 }); 908 909 observer_lightBox.unobserve(entry.target); 910 } 911 }); 912 }, 913 options); 914 915 targetElements_lightBox.forEach((element) => { 916 observer_lightBox.observe(element); 917 }); 918 919 // .bt_bb_masonry_image_grid 920 921 const targetElements_masonryImageGrid = document.querySelectorAll( 922 ".bt_bb_masonry_image_grid:not(.bt_bb_no_lightbox)" 923 ); 924 925 const observer_masonryImageGrid = new IntersectionObserver(function ( 926 entries, 927 observer 928 ) { 929 entries.forEach((entry) => { 930 if (entry.isIntersecting) { 931 932 $(entry.target).magnificPopup({ 933 delegate: ".bt_bb_grid_item", 934 type: "image", 935 gallery: { 936 enabled: true, 937 }, 938 callbacks: { 939 elementParse: function (item) { 940 item.src = item.el.data("src-full"); 941 }, 942 }, 943 closeBtnInside: false, 944 fixedContentPos: false, 945 }); 946 947 observer_masonryImageGrid.unobserve(entry.target); 948 } 949 }); 950 }, 951 options); 952 953 targetElements_masonryImageGrid.forEach((element) => { 954 observer_masonryImageGrid.observe(element); 955 }); 956 957 // css image grid lighbox 958 959 window.bt_bb_init_css_image_grid_lightbox_startup(); 960 961 // image lightbox 962 963 $(document).on("click", ".bt_bb_image.bt_bb_use_lightbox a", function () { 964 var url = $(this).attr("href").trim(); 965 966 if (url != "" && url != "#" && url != "#lightbox") { 967 var contentType = 968 url.toLowerCase().includes(".jpg") || 969 url.toLowerCase().includes(".jpeg") || 970 url.toLowerCase().includes(".png") 971 ? "image" 972 : "iframe"; 973 $.magnificPopup.open({ 974 type: contentType, 975 items: { 976 src: url, 977 title: $(this).attr("title"), 978 }, 979 closeBtnInside: false, 980 }); 981 } else { 982 var url = $(this).find("img").attr("data-full_image_src"); 983 $.magnificPopup.open({ 984 type: "image", 985 items: { 986 src: url, 987 title: $(this).attr("title"), 988 }, 989 closeBtnInside: false,
990 fixedContentPos: false, 991 }); 992 return false; 993 } 994 return false; 995 }); 996 997 // button, icon, service lightbox 998 999 $(document).on( 1000 "click", 1001 ".bt_bb_button.bt_bb_use_lightbox a, .bt_bb_icon.bt_bb_use_lightbox a, .bt_bb_service.bt_bb_use_lightbox a", 1002 function () { 1003 var url = $(this).attr("href"); 1004 var contentType = 1005 url.toLowerCase().includes(".jpg") || 1006 url.toLowerCase().includes(".jpeg") || 1007 url.toLowerCase().includes(".png") 1008 ? "image" 1009 : "iframe"; 1010 1011 $.magnificPopup.open({ 1012 type: contentType, 1013 items: { 1014 src: url, 1015 title: $(this).attr("title"), 1016 }, 1017 closeBtnInside: false, 1018 }); 1019 1020 return false; 1021 } 1022 ); 1023 1024 // force slider item equal height when keep height is active 1025 1026 $(".bt_bb_content_slider.bt_bb_height_keep-height .slick-slider").on( 1027 "setPosition", 1028 function () { 1029 bt_bb_fix_slider_heights(); 1030 $(this) 1031 .find("*[aria-hidden=true] a, *[aria-hidden=true] button") 1032 .attr("tabindex", -1); 1033 $(this) 1034 .find("*[aria-hidden=false] a, *[aria-hidden=false] button") 1035 .removeAttr("tabindex"); 1036 } 1037 ); 1038 $(window).on("resize", function (e) { 1039 bt_bb_fix_slider_heights(); 1040 bt_bb_get_screen_resolution(); 1041 }); 1042 1043 // bt_bb_elements.js resets animated class 1044 $(".slick-slider").on( 1045 "beforeChange", 1046 function (event, slick, currentSlide, nextSlide) { 1047 $(this).find(".slick-slide .animated").removeClass("animated"); 1048 $(this) 1049 .find(".slick-slide[data-slick-index=" + nextSlide + "] .animate") 1050 .addClass("animated"); 1051 } 1052 ); 1053 1054 // tabs 1055 1056 window.bt_bb_init_tabs_startup(); 1057 1058 // Detect touch 1059 1060 setTimeout(() => { 1061 bt_detect_touch(); 1062 }, 0); 1063 1064 // parallax 1065 1066 bt_bb_check_fixed_background(); 1067 1068 if ($("html.bt_bb_backgroud_fixed_supported .bt_bb_parallax").length > 0) { 1069 window.bt_bb_raf_lock = false; 1070 1071 $(window).on("mousewheel", function (e) { }); 1072 1073 $(window).on("scroll", function () { 1074 if (!window.bt_bb_raf_lock) { 1075 window.bt_bb_raf_lock = true; 1076 bt_bb_requestAnimFrame(bt_bb_raf_loop); 1077 } 1078 }); 1079 1080 //qbt_bb_requestAnimFrame(bt_bb_raf_loop); 1081 1082 $(window).on("load", function () { 1083 bt_bb_requestAnimFrame(bt_bb_raf_loop); 1084 }); 1085 } 1086 1087 // Countdown 1088 1089 const options_Countdown = { 1090 root: null, 1091 rootMargin: "1000px", 1092 treshold: 0, 1093 }; 1094 1095 const targetElements_Countdown = 1096 document.querySelectorAll(".btCountdownHolder"); 1097 1098 const observer_Countdown = new IntersectionObserver(function ( 1099 entries, 1100 observer 1101 ) { 1102 entries.forEach((entry) => { 1103 if (entry.isIntersecting) { 1104 1105 setInterval(function () { 1106 bt_bb_countdown_output($(entry.target)); 1107 }, 1000); 1108 1109 observer_Countdown.unobserve(entry.target); 1110 } 1111 }); 1112 }, 1113 options_Countdown); 1114 1115 targetElements_Countdown.forEach((element) => { 1116 observer_Countdown.observe(element); 1117 }); 1118 1119 // Accordion 1120 1121 $(".bt_bb_wrapper").on("click", ".bt_bb_accordion_item_title", function () { 1122 var $item = $(this).closest(".bt_bb_accordion_item"); 1123 if (!$item.hasClass("on")) { 1124 $(this) 1125 .closest(".bt_bb_accordion") 1126 .find(".bt_bb_accordion_item.on") 1127 .removeClass("on"); 1128 $item.addClass("on"); 1129 if (!window.bt_bb_initialaccordion) { 1130 var top_of_element = $item.offset().top; 1131 var bottom_of_element = 1132 $item.offset().top + $("#element").outerHeight(); 1133 var bottom_of_screen = 1134 $(window).scrollTop() + $(window).innerHeight(); 1135 var top_of_screen = $(window).scrollTop(); 1136 var diff = top_of_screen - top_of_element; 1137 if (diff > 0) { 1138 $("html").scrollTop($("html").scrollTop() - diff - 15); 1139 } 1140 } else { 1141 window.bt_bb_initialaccordion = false; 1142 } 1143 } else { 1144 $(this).closest(".bt_bb_accordion_item").removeClass("on"); 1145 } 1146 }); 1147 1148 const targetElements_Accordion = 1149 document.querySelectorAll(".bt_bb_accordion"); 1150 1151 const observer_Accordion = new IntersectionObserver(function ( 1152 entries, 1153 observer 1154 ) { 1155 entries.forEach((entry) => { 1156 if (entry.isIntersecting) { 1157 1158 if ($(entry.target).data("closed") != "closed") { 1159 window.bt_bb_initialaccordion = true; 1160 $(entry.target)
1161 .find(".bt_bb_accordion_item_title") 1162 .first() 1163 .click(); 1164 } 1165 1166 observer_Accordion.unobserve(entry.target); 1167 } 1168 }); 1169 }, 1170 options); 1171 1172 targetElements_Accordion.forEach((element) => { 1173 observer_Accordion.observe(element); 1174 }); 1175 } 1176 1177 // google maps 1178 1179 window.bt_bb_gmap_init_static_new = function (map_id) { 1180 var mapElement_jQuery = jQuery('#' + map_id); 1181 if (mapElement_jQuery.data('init-finished') == true) return false; 1182 var zoom = (typeof mapElement_jQuery.data('zoom') !== 'undefined') ? mapElement_jQuery.data('zoom') : 8; 1183 var custom_style = (typeof mapElement_jQuery.data('custom-style') !== 'undefined') ? mapElement_jQuery.data('custom-style').trim() : ''; 1184 var api_key = (typeof mapElement_jQuery.data('api-key') !== 'undefined') ? mapElement_jQuery.data('api-key') : ''; 1185 var height = (typeof mapElement_jQuery.data('height') !== 'undefined') ? mapElement_jQuery.data('height') : 0; 1186 bt_bb_gmap_init_static(map_id, zoom, custom_style, height, api_key); 1187 mapElement_jQuery.data('init-finished', true); 1188 1189 } 1190 1191 window.bt_bb_gmap_init_new = function (map_id) { 1192 var mapElement_jQuery = jQuery('#' + map_id); 1193 if (mapElement_jQuery.data('init-finished') == true) return false; 1194 var zoom = (typeof mapElement_jQuery.data('zoom') !== 'undefined') ? mapElement_jQuery.data('zoom') : 8; 1195 var custom_style = (typeof mapElement_jQuery.data('custom-style') !== 'undefined') ? mapElement_jQuery.data('custom-style').trim() : ''; 1196 bt_bb_gmap_init(map_id, zoom, custom_style); 1197 mapElement_jQuery.data('init-finished', true); 1198 } 1199 1200 document.addEventListener('readystatechange', function () { 1201 if ((document.readyState === 'complete')) { 1202 if (typeof (bt_bb_init_all_maps) !== 'function') { 1203 return false; 1204 } 1205 window.bt_bb_init_all_maps(); 1206 }; 1207 }, false); 1208 1209 // callback from gmaps api 1210 window.bt_bb_init_all_maps = function () { 1211 jQuery('.bt_bb_google_maps_map').each(function (index) { 1212 if (jQuery(this).data('map-type') != 'static') { 1213 bt_bb_gmap_init_new(jQuery(this).attr('id')); 1214 } else { 1215 bt_bb_gmap_init_static_new(jQuery(this).attr('id')); 1216 }; 1217 }); 1218 }; 1219 1220 window.bt_bb_gmap_init_static = function (map_id, zoom, custom_style, height, api_key) { 1221 1222 if (parseInt(height) <= 0) height = 400; 1223 1224 var container = jQuery('#' + map_id).parent(); 1225 var googleApiMapId = document.getElementById(map_id).id; 1226 1227 var locations = container.find('.bt_bb_map_location'); 1228 1229 var center_map = container.data('center'); 1230 if (center_map == 'no') { 1231 center_map = false; 1232 } else { 1233 center_map = true; 1234 } 1235 1236 var lat_sum = 0; 1237 var lng_sum = 0; 1238 var markerStr = ''; 1239 var n = 0; 1240 var colors = ['blue', 'green', 'red', 'purple', 'yellow', 'gray', 'orange', 'white', 'black', 'brown']; 1241 1242 var centerLatLng; 1243 1244 locations.each(function () { 1245 1246 var lat = jQuery(this).data('lat'); 1247 var lng = jQuery(this).data('lng'); 1248 var iconStr = jQuery(this).data('icon') != "" ? 'scale:2%7Cicon:' + jQuery(this).data('icon') : 'size:mid%7Ccolor:' + colors[n]; 1249 1250 lat_sum += parseFloat(lat); 1251 lng_sum += parseFloat(lng); 1252 1253 markerStr += '&markers=' + iconStr + '%7C' + lat + ',' + lng; 1254 1255 centerLatLng = [lat, lng]; 1256 1257 n++; 1258 }); 1259 1260 if (center_map) { 1261 centerLatLng = [lat_sum / n, lng_sum / n]; 1262 } 1263 1264 if (atob(custom_style).startsWith('[')) custom_style = ''; 1265 1266 var img_src = '<img src="https://maps.googleapis.com/maps/api/staticmap?center=' + centerLatLng.toString() + '&zoom=' + zoom + markerStr + '&size=640x' + height + '&scale=2&style=' + atob(custom_style) + '&key=' + api_key + '">'; 1267 container.find('.bt_bb_google_maps_map.bt_bb_map_map').append(img_src).on('click', function () { 1268 1269 var parent = $(this).parent(); 1270 var locations = parent.find('.bt_bb_map_location'); 1271 var active = locations.filter('.bt_bb_map_location_show'); 1272 1273 // OFF state â turn on first 1274 if (active.length === 0) { 1275 locations.first().addClass('bt_bb_map_location_show'); 1276 return; 1277 } 1278 1279 // Last active â turn everything OFF 1280 if (active.is(locations.last())) { 1281 locations.removeClass('bt_bb_map_location_show'); 1282 return; 1283 } 1284 1285 // Normal rotation â next 1286 active 1287 .removeClass('bt_bb_map_location_show') 1288 .next('.bt_bb_map_location') 1289 .addClass('bt_bb_map_location_show'); 1290 }); 1291 1292 locations.eq(0).addClass('bt_bb_map_location_show'); 1293 1294 jQuery('#' + map_id).data('init-finished', true); 1295 1296 } 1297 1298 window.bt_bb_gmap_init = function (map_id, zoom, custom_style) { 1299 1300 var mapElement = document.getElementById(map_id); 1301 1302 var myLatLng = new google.maps.LatLng(0, 0); 1303 1304 var googleApiMapId = mapElement.id; 1305 1306 var mapOptions = { 1307 mapId: googleApiMapId, 1308 zoom: zoom, 1309 center: myLatLng, 1310 scrollwheel: false, 1311 scaleControl: true, 1312 zoomControl: true, 1313 zoomControlOptions: { 1314 style: google.maps.ZoomControlStyle.SMALL, 1315 position: google.maps.ControlPosition.RIGHT_CENTER 1316 }, 1317 streetViewControl: true, 1318 mapTypeControl: true 1319 } 1320 1321 if (mapElement) { 1322 var map = new google.maps.Map(mapElement, mapOptions); 1323 1324 if (custom_style != '' && atob(custom_style).startsWith('[')) { 1325 1326 var style_array = []; 1327 1328 if (custom_style != '') { 1329 style_array = JSON.parse(atob(custom_style)); 1330 } 1331 1332 var customMapType = new google.maps.StyledMapType(style_array, { 1333 name: 'Custom Style' 1334 }); 1335 1336 var customMapTypeId = 'custom_style'; 1337 map.mapTypes.set(customMapTypeId, customMapType); 1338 map.setMapTypeId(customMapTypeId); 1339 } else { 1340 1341 } 1342 1343 var n = 0; 1344 1345 var container = jQuery('#' + map_id).parent(); 1346 1347 var locations = container.find('.bt_bb_map_location'); 1348 1349 var center_map = container.data('center'); 1350 if (center_map == 'no') { 1351 center_map = false;
1352 } else { 1353 center_map = true; 1354 } 1355 1356 var lat_sum = 0; 1357 var lng_sum = 0; 1358 1359 locations.each(function () { 1360 1361 var lat = jQuery(this).data('lat'); 1362 var lng = jQuery(this).data('lng'); 1363 var icon = jQuery(this).data('icon'); 1364 1365 lat_sum += parseFloat(lat); 1366 lng_sum += parseFloat(lng); 1367 1368 var myGlyphImg = document.createElement("img"); 1369 myGlyphImg.src = icon; 1370 myGlyphImg.count = n; 1371 var myLatLng = new google.maps.LatLng(lat, lng); 1372 // console.log( myLatLng ); 1373 // var myLatLng = { lat: -25.344, lng: 131.031 }; 1374 // console.log( map ); 1375 // console.log( myLatLng ); 1376 var marker = new google.maps.marker.AdvancedMarkerElement({ 1377 map, 1378 position: myLatLng, 1379 content: myGlyphImg, 1380 // count: n 1381 }); 1382 marker.count = n; 1383 1384 if (!center_map && n == 0) { 1385 map.setCenter(myLatLng); 1386 } 1387 1388 locations.eq(0).addClass('bt_bb_map_location_show'); 1389 1390 marker.addListener('click', () => { 1391 //map.setZoom( zoom ); 1392 //map.setCenter( marker.getPosition() ); 1393 //console.log( marker.count ); 1394 var reload = true; 1395 if (locations.eq(marker.count).hasClass('bt_bb_map_location_show') && !container.hasClass('bt_bb_map_no_overlay')) reload = false; 1396 container.removeClass('bt_bb_map_no_overlay'); 1397 locations.removeClass('bt_bb_map_location_show'); 1398 if (reload) locations.eq(marker.count).addClass('bt_bb_map_location_show'); 1399 }); 1400 1401 n++; 1402 }); 1403 1404 if (center_map) { 1405 var centerLatLng = new google.maps.LatLng(lat_sum / n, lng_sum / n); 1406 map.setCenter(centerLatLng); 1407 } 1408 } 1409 1410 jQuery('#' + map_id).data('init-finished', true); 1411 1412 } 1413 1414 // leaflet map init 1415 1416 var map = null; 1417 1418 window.bt_bb_leaflet_init = function (map_id, zoom, max_zoom, predefined_style, scroll_wheel, custom_style, zoom_control) { 1419 onImagesLoaded($('#' + map_id).parent(), function () { 1420 bt_bb_leaflet_init_late(map_id, zoom, max_zoom, predefined_style, scroll_wheel, custom_style, zoom_control); 1421 }); 1422 1423 } 1424 1425 window.bt_bb_leaflet_init_late_all = function () { 1426 jQuery('.bt_bb_leaflet_map_map').not('.leaflet-container').each(function () { 1427 window.bt_bb_leaflet_init_late(jQuery(this).attr('id'), jQuery(this).data('zoom'), jQuery(this).data('max_zoom'), jQuery(this).data('predefined_style'), jQuery(this).data('custom_style'), jQuery(this).data('scroll_wheel'), jQuery(this).data('zoom_control')); 1428 }); 1429 } 1430 1431 window.bt_bb_leaflet_init_late = function (map_id, zoom, max_zoom, predefined_style, custom_style, scroll_wheel, zoom_control) { 1432 1433 var lat_center = 0; 1434 var lng_center = 0; 1435 1436 var container = jQuery('#' + map_id).parent(); 1437 var locations = container.find('.bt_bb_leaflet_map_location'); 1438 1439 var center_map = container.data('center'); 1440 1441 if (center_map == 'no') { 1442 center_map = false; 1443 } else { 1444 center_map = true; 1445 } 1446 1447 var markerClusters = L.markerClusterGroup(); 1448 1449 var lat_sum = 0; 1450 var lng_sum = 0; 1451 var n = 0; 1452 1453 locations.each(function () { 1454 1455 var lat = jQuery(this).data('lat'); 1456 var lng = jQuery(this).data('lng'); 1457 var icon = jQuery(this).data('icon'); 1458 lat_sum += parseFloat(lat); 1459 lng_sum += parseFloat(lng); 1460 1461 if (n == 0) { 1462 lat_center = lat; 1463 lng_center = lng; 1464 } 1465 locations.eq(0).addClass('bt_bb_map_location_show'); 1466 locations.eq(0).addClass('bt_bb_map_location_show'); 1467 1468 var myIcon = L.icon({ 1469 iconUrl: icon, 1470 iconRetinaUrl: icon, 1471 iconSize: [45, 58], 1472 iconAnchor: [22, 58], 1473 popupAnchor: [0, -14] 1474 }); 1475 1476 var m = L.marker([lat, lng], { icon: myIcon, id: n, lat: lat, lng: lng }).on("click", markerOnClick); 1477 markerClusters.addLayer(m); 1478 1479 n++; 1480 }); 1481 1482 if (center_map) { 1483 lat_center = lat_sum / n; 1484 lng_center = lng_sum / n; 1485 } 1486 1487 map = L.map(document.getElementById(map_id)).setView([lat_center, lng_center], zoom); 1488 1489 var tiles_arr = []; 1490 1491 if (parseInt(predefined_style) > 0) { 1492 tiles_arr = tiles_arr.concat(map_leaflet_source_arr[predefined_style]); 1493 } 1494 1495 if (custom_style != '') { 1496 custom_style = atob(custom_style); 1497 var tmp_arr = custom_style.split('\n'); 1498 $.each(tmp_arr, function (index, tmp) { 1499 1500 tiles_arr = tiles_arr.concat([tmp.split(',')]); 1501 }); 1502 } 1503 1504 $.each(tiles_arr, function (index, tile) { 1505 L.tileLayer( 1506 tile[0], 1507 { 1508 attribution: tile[1], 1509 maxZoom: max_zoom, 1510 subdomains: ['a', 'b', 'c'] 1511 } 1512 ).addTo(map); 1513 }); 1514 1515 map.addLayer(markerClusters); 1516 1517 if (scroll_wheel == '') { 1518 map.scrollWheelZoom.disable(); 1519 } 1520 1521 map.removeControl(map.zoomControl); 1522 1523 if (zoom_control) { 1524 L.control.zoom({ 1525 position: 'topright' 1526 }).addTo(map); 1527 } 1528 1529 function markerOnClick(e) { 1530 var attributes = e.target.options; 1531 var id = attributes.id; 1532 var reload = true; 1533 if (locations.eq(id).hasClass('bt_bb_leaflet_map_location_show') && !container.hasClass('bt_bb_leaflet_map_no_overlay')) reload = false;
1534 container.removeClass('bt_bb_leaflet_map_no_overlay'); 1535 locations.removeClass('bt_bb_leaflet_map_location_show'); 1536 if (reload) locations.eq(id).addClass('bt_bb_leaflet_map_location_show'); 1537 1538 if (locations.eq(id).hasClass('bt_bb_map_location_show') && !container.hasClass('bt_bb_map_no_overlay')) reload = false; 1539 container.removeClass('bt_bb_map_no_overlay'); 1540 locations.removeClass('bt_bb_map_location_show'); 1541 if (reload) locations.eq(id).addClass('bt_bb_map_location_show'); 1542 } 1543 } 1544 1545 // do event if all images in container are loaded 1546 1547 function onImagesLoaded(container, event) { 1548 var images = container.find('.bt_bb_leaflet_map_content img'); 1549 var loaded = images.length; 1550 if (loaded > 0) { 1551 for (var i = 0; i < images.length; i++) { 1552 if (images[i].complete) { 1553 loaded--; 1554 if (loaded == 0) { 1555 event(); 1556 } 1557 } else { 1558 images[i].addEventListener('load', function () { 1559 loaded--; 1560 if (loaded == 0) { 1561 event(); 1562 } 1563 }); 1564 setTimeout(function () { loaded--; console.log('Image loaded without proof: ' + loaded); if (loaded == 0) { event(); } }, 3000); 1565 } 1566 } 1567 } else { 1568 event(); 1569 } 1570 } 1571 1572 // general init 1573 1574 var bt_bb_init_finished = false; 1575 1576 document.addEventListener('readystatechange', function () { 1577 if (!bt_bb_init_finished && (document.readyState === 'interactive' || document.readyState === 'complete')) { 1578 bt_bb_init_elements(); 1579 1580 window.addEventListener("load", (event) => { 1581 1582 if (!$('body').hasClass('bodyPreloader')) { 1583 bt_bb_animate_elements_optim(); 1584 } else { 1585 setTimeout(function () { 1586 bt_bb_animate_elements_optim(); 1587 }, 500); 1588 } 1589 1590 bt_bb_lazy_load_images_optim(); 1591 1592 if ($('body').hasClass('logged-in') && $('.bt_bb_wrapper').length) { 1593 $(window).on('scroll', function () { 1594 bt_bb_animate_elements(); 1595 }); 1596 } 1597 1598 $(window).on('resize', function (e) { 1599 setTimeout(function () { 1600 var $elems = $('.bt_bb_counter.animated'); 1601 $elems.each(function () { 1602 var $elm = $(this); 1603 $elm.removeClass('animated'); 1604 bt_bb_animate_counter($elm); 1605 }); 1606 }, 1000); 1607 }); 1608 }); 1609 1610 bt_bb_init_finished = true; 1611 1612 } 1613 1614 }, false); 1615 1616 // magnificPopup swipe 1617 1618 function mfp_swipe() { 1619 var touch_start = false;
1620 var touch_end = false; 1621 var one_finger = true; 1622 $(document).on('touchstart', '.mfp-figure figure', function (e) { 1623 const touches = e.changedTouches; 1624 if (touches.length == 1) { 1625 touch_start = touches[0].clientX; 1626 } else { 1627 one_finger = false; 1628 } 1629 }); 1630 $(document).on('touchmove', '.mfp-figure figure', function (e) { 1631 const touches = e.changedTouches; 1632 if (touches.length > 1) { 1633 one_finger = false; 1634 } 1635 }); 1636 $(document).on('touchend', '.mfp-figure figure', function (e) { 1637 const touches = e.changedTouches; 1638 if (touches.length == 1 && one_finger) { 1639 touch_end = touches[0].clientX; 1640 if (touch_start - touch_end < -50) { 1641 $('.mfp-arrow-left').click(); 1642 } else if (touch_start - touch_end > 50) { 1643 $('.mfp-arrow-right').click(); 1644 } 1645 } 1646 one_finger = true; 1647 }); 1648 } 1649 mfp_swipe(); 1650 1651}(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.