1(function () { 2 var $, isBuilder; 3 var isJQuery = typeof jQuery == 'function'; 4 if (isJQuery) $ = jQuery; 5 $ ? isBuilder = $('html').hasClass('is-builder') 6 : isBuilder = document.querySelector('html').classList.contains('is-builder'); 7 8 function outerFind(el, selector) { 9 var elements = Array.from(el.querySelectorAll(selector)); 10 if (el.matches && el.matches(selector)) elements.splice(0, 0, el); 11 return elements; 12 }; 13 14 function offset(el) { 15 var box = el.getBoundingClientRect(), 16 docElem = document.documentElement; 17 return { 18 top: box.top + window.pageYOffset - docElem.clientTop, 19 left: box.left + window.pageXOffset - docElem.clientLeft 20 }; 21 }; 22 23 24 function getHeight(el) { 25 return parseFloat(getComputedStyle(el, null).height.replace('px', '')); 26 }; 27 28 function getWidth(el) { 29 return parseFloat(getComputedStyle(el, null).width.replace('px', '')); 30 }; 31 32 function ready(fn) { 33 if (document.readyState != 'loading'){ 34 fn(); 35 } else { 36 document.addEventListener('DOMContentLoaded', fn); 37 } 38 } 39 40 function getIndex(el) { 41 if (!el) return -1; 42 var i = 0; 43 do { 44 i++; 45 } while (el = el.previousElementSibling); 46 return i; 47 } 48 49 // fadeIn and fadeOut functions from https://only-to-top.ru/blog/coding/2019-09-24-jquery-to-js.html 50 function fadeOut(el) { 51 (function fade() { 52 if ((el.style.opacity -= .1) < 0) { 53 el.style.display = 'none'; 54 } else { 55 requestAnimationFrame(fade); 56 } 57 })(); 58 }; 59 60 function fadeIn(el) { 61 el.style.display = 'block'; 62 (function fade() { 63 var val = parseFloat(el.style.opacity); 64 if (!((val += .1) > 1)) { 65 el.style.opacity = val; 66 requestAnimationFrame(fade); 67 } 68 })(); 69 }; 70 71 // get parents function from https://gist.github.com/ziggi/2f15832b57398649ee9b 72 Element.prototype.parents = function(selector) { 73 var elements = []; 74 var elem = this; 75 var ishaveselector = selector !== undefined; 76 77 while ((elem = elem.parentElement) !== null) { 78 if (elem.nodeType !== Node.ELEMENT_NODE) { 79 continue; 80 } 81 82 if (!ishaveselector || elem.matches(selector)) { 83 elements.push(elem); 84 } 85 } 86 87 return elements; 88 }; 89 90 91 Element.prototype.footerReveal = function() { 92 var _this = this; 93 var prev = _this.previousElementSibling; 94 var isIE = !!document.documentMode; 95 function initReveal() { 96 if (!isIE && _this.offsetHeight <= window.outerHeight) { 97 _this.style.zIndex = '-999'; 98 _this.style.position = 'fixed'; 99 _this.style.bottom = '0'; 100 _this.style.width = prev.offsetWidth+'px'; 101 prev.style.marginBottom = _this.offsetHeight+'px'; 102 } else { 103 _this.style.zIndex = ''; 104 _this.style.position = ''; 105 _this.style.bottom = ''; 106 _this.style.width = ''; 107 prev.style.marginBottom = ''; 108 } 109 } 110 111 initReveal(); 112 113 window.addEventListener('resize', function() {initReveal()}); 114 window.addEventListener('load', function() {initReveal()}); 115 116 return _this; 117 }; 118 119 120 (function (sr) { 121 // debouncing function from John Hann 122 // http://unscriptable.com/index.php/2009/03/20/debouncing-javascript-methods/ 123 var debounce = function (func, threshold, execAsap) { 124 var timeout; 125 126 return function debounced() { 127 var obj = this, 128 args = arguments; 129 130 function delayed() { 131 if (!execAsap) func.apply(obj, args); 132 timeout = null; 133 } 134 135 if (timeout) clearTimeout(timeout); 136 else if (execAsap) func.apply(obj, args); 137 138 timeout = setTimeout(delayed, threshold || 100); 139 }; 140 }; 141 // smartresize 142 window[sr] = function (fn) { 143 var ev = new CustomEvent(sr); 144 return fn ? this.addEventListener('resize', debounce(fn)) : this.dispatchEvent(ev); 145 }; 146 147 })('smartresize'); 148 149 150 (function () { 151 152 var scrollbarWidth = 0, 153 originalMargin, touchHandler = function (event) { 154 event.preventDefault(); 155 }; 156 157 function getScrollbarWidth() { 158 if (scrollbarWidth) return scrollbarWidth; 159 var scrollDiv = document.createElement('div'); 160 var props = { 161 top: '-9999px', 162 width: '50px', 163 height: '50px', 164 overflow: 'scroll', 165 position: 'absolute' 166 } 167 for (var prop in props) { 168 scrollDiv.style[prop] = props[prop]; 169 } 170 document.querySelector('body').appendChild(scrollDiv); 171 scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth; 172 document.querySelector('body').removeChild(scrollDiv); 173 return scrollbarWidth; 174 } 175 176 })(); 177 178 179 function isMobile (type) { 180 var reg = []; 181 var any = { 182 blackberry: 'BlackBerry', 183 android: 'Android', 184 windows: 'IEMobile', 185 opera: 'Opera Mini', 186 ios: 'iPhone|iPad|iPod' 187 }; 188 type = 'undefined' == typeof(type) ? '*' : type.toLowerCase(); 189 if ('*' === type) reg = Object.values(any); 190 else if (type in any) reg.push(any[type]); 191 return !!(reg.length && navigator.userAgent.match(new RegExp(reg.join('|'), 'i'))); 192 }; 193 194 var isSupportViewportUnits = (function () { 195 // modernizr implementation 196 var div = document.createElement('div'); 197 var body = document.querySelector('body');
198 div.setAttribute('style', 'height: 50vh; position: absolute; top: -1000px; left: -1000px;'); 199 body.appendChild(div); 200 var height = parseInt(window.innerHeight / 2, 10); 201 var compStyle = parseInt((window.getComputedStyle ? getComputedStyle(div, null) : div.currentStyle)['height'], 10); 202 body.removeChild(div); 203 return compStyle == height; 204 }()); 205 206 207 208 ready(function () { 209 document.querySelector('html').classList.add(isMobile() ? 'mobile' : 'desktop'); 210 211 // .mbr-navbar--sticky 212 213 // needs some check 214 window.addEventListener('scroll', function() { 215 document.querySelectorAll('.mbr-navbar--sticky').forEach(function(el) { 216 var method = window.scrollTop > 10 ? 'add' : 'remove'; 217 el.classList[method]('mbr-navbar--stuck'); 218 if (!el.classList.contains('.mbr-navbar--open')) el.classList[method]('mbr-navbar--short'); 219 }) 220 }); 221 222 if (isMobile() && navigator.userAgent.match(/Chrome/i)) { // simple fix for Chrome's scrolling 223 (function (width, height) { 224 var deviceSize = [width, width]; 225 deviceSize[height > width ? 0 : 1] = height; 226 window.smartresize(function () { 227 var windowHeight = window.innerHeight; 228 if (deviceSize.indexOf(windowHeight) < 0) 229 windowHeight = deviceSize[window.innerWidth > windowHeight ? 1 : 0]; 230 var el = document.querySelector('.mbr-section--full-height'); 231 if (!el) return; 232 el.style.height = windowHeight + 'px'; 233 }); 234 })(window.innerWidth, window.innerHeight); 235 } else if (!isSupportViewportUnits) { // fallback for .mbr-section--full-height 236 window.smartresize(function () { 237 var el = document.querySelector('.mbr-section--full-height'); 238 if (!el) return; 239 el.style.height = window.innerHeight + 'px'; 240 }); 241 // $(document).on('add.cards', function (event) { 242 document.addEventListener('add.cards', function (event) { 243 if (document.querySelector('html').classList.contains('mbr-site-loaded') && outerFind(event.target, '.mbr-section--full-height').length) 244 window.dispatchEvent(new CustomEvent('resize')); 245 }); 246 } 247 248 // .mbr-section--16by9 (16 by 9 blocks autoheight) 249 250 function calculate16by9(el) { 251 el.style.height = getWidth(el.parentNode) * 9 / 16 + 'px'; 252 } 253 window.addEventListener('smartresize', function () { 254 document.querySelectorAll('.mbr-section--16by9').forEach(calculate16by9); 255 }); 256 if (isJQuery) $(document).on('add.cards changeParameter.cards', function (event) { 257 //document.addEventListener('add.cards changeParameter.cards', function (event) { 258 var enabled = outerFind(event.target, '.mbr-section--16by9'); 259 if (enabled.length) { 260 enabled.forEach(function(el) { 261 el.setAttribute('data-16by9', 'true'); 262 calculate16by9(el); 263 }) 264 } else { 265 outerFind(event.target, '[data-16by9]').forEach(function (el) { 266 el.styles.height = ''; 267 el.removeAttribute('data-16by9'); 268 }) 269 } 270 }); 271 272 273 // .mbr-parallax-background 274 275 // plugin needs replacement: Parallax 276 277 function initParallax(card) { 278 setTimeout(function () { 279 outerFind(card, '.mbr-parallax-background').forEach(function(el) { 280 if (jarallax) { 281 jarallax(el, {speed: 0.6}) 282 el.style.position = 'relative'; 283 } 284 }) 285 286 }, 0); 287 } 288 289 290 function destroyParallax(card) { 291 if (jarallax) jarallax(card, ('destroy')); 292 card.style.position = ''; 293 } 294 295 if ((typeof jarallax !== 'undefined') && !isMobile()) { 296 window.addEventListener('update.parallax', function (event) { 297 setTimeout(function () { 298 if (!jarallax) return; 299 var jarallax = document.querySelector('.mbr-parallax-background'); 300 301 jarallax.jarallax('coverImage'); 302 jarallax.jarallax('clipContainer'); 303 jarallax.jarallax('onScroll'); 304 }, 0); 305 }); 306 307 if (isBuilder) { 308 if (!isJQuery) return; 309 $(document).on('add.cards', function (event) { 310 initParallax(event.target); 311 $(window).trigger('update.parallax'); 312 }); 313 314 $(document).on('changeParameter.cards', function (event, paramName, value, key) { 315 if (paramName === 'bg') { 316 destroyParallax(event.target); 317 $(event.target).find('.mbr-background-video-preview').remove(); 318 $(event.target).find('.mbr-background-video').remove(); 319 switch (key) { 320 case 'type': 321 if (value.parallax === true) { 322 initParallax(event.target); 323 } 324 break; 325 case 'value': 326 if (value.type === 'image' && value.parallax === true) { 327 initParallax(event.target); 328 } 329 break; 330 case 'parallax': 331 if (value.parallax === true) { 332 initParallax(event.target); 333 } 334 } 335 } 336 337 $(window).trigger('update.parallax'); 338 }); 339 } else { 340 initParallax(document.body); 341 } 342 343 // for Tabs 344 window.addEventListener('shown.bs.tab', function () { 345 window.dispatchEvent(new CustomEvent('update.parallax')); 346 }); 347 } 348 349 // .mbr-fixed-top 350 351 var fixedTopTimeout, scrollTimeout, prevScrollTop = 0, 352 fixedTop = null, 353 isDesktop = !isMobile(); 354 window.addEventListener('scroll', function () { 355 if (scrollTimeout) clearTimeout(scrollTimeout); 356 var scrollTop = document.documentElement.scrollTop; 357 var scrollUp = scrollTop <= prevScrollTop || isDesktop; 358 prevScrollTop = scrollTop; 359 if (fixedTop) { 360 var fixed = scrollTop > fixedTop.breakPoint; 361 if (scrollUp) { 362 if (fixed != fixedTop.fixed) { 363 if (isDesktop) { 364 fixedTop.fixed = fixed; 365 fixedTop.elm.classList.toggle('is-fixed'); 366 } else { 367 scrollTimeout = setTimeout(function () { 368 fixedTop.fixed = fixed; 369 fixedTop.elm.classList.toggle('is-fixed'); 370 }, 40); 371 } 372 } 373 } else { 374 fixedTop.fixed = false; 375 fixedTop.elm.classList.remove('is-fixed'); 376 } 377 } 378 }); 379 380 if (isJQuery) $(document).on('add.cards delete.cards', function (event) { 381 // document.addEventListener('add.cards delete.cards', function () { 382 if (fixedTopTimeout) clearTimeout(fixedTopTimeout); 383 fixedTopTimeout = setTimeout(function () { 384 if (fixedTop) { 385 fixedTop.fixed = false; 386 fixedTop.elm.classList.remove('is-fixed'); 387 } 388 var elm = document.querySelector('.mbr-fixed-top'); 389 if (elm) { 390 fixedTop = { 391 breakPoint: offset(elm).top + getHeight(elm) * 3, 392 fixed: false, 393 elm 394 }; 395 elm.dispatchEvent(new CustomEvent('scroll')); 396 } 397 }, 650); 398 }); 399 400 401 // embedded videos 402 403 window.smartresize(function () { 404 document.querySelectorAll('.mbr-embedded-video').forEach(function (el) { 405 el.style.height = (getWidth(el) * parseInt(el.getAttribute('height') || 315) / parseInt(el.getAttribute('width') || 560)).toFixed() + 'px'; 406 }); 407 }); 408 if (isJQuery) $(document).on('add.cards', function (event) { 409 // document.addEventListener('add.cards', function (event) { 410 if (document.querySelector('html').classList.contains('mbr-site-loaded') && outerFind(event.target, 'iframe').length) 411 window.dispatchEvent(new CustomEvent('resize')); 412 }); 413 414 // background video 415 416 function videoParser(card) { 417 outerFind(card, '[data-bg-video]').forEach(function (el) { 418 var videoURL = el.getAttribute('data-bg-video'); 419 if (!videoURL) return; 420 421 var searchParams = new URLSearchParams(videoURL); 422 var startAt = Number(searchParams.has('t') ? searchParams.get('t') : 0) || 0; 423 var parsedUrl = videoURL.match(/(http:\/\/|https:\/\/|)?(player.|www.)?(vimeo\.com|youtu(be\.com|\.be|be\.googleapis\.com))\/(shorts\/|video\/|embed\/|watch\?v=|v\/)?([A-Za-z0-9._%-]*)(&\S+)?/); 424 425 var img = el.querySelector('.mbr-background-video-preview') || document.createElement('div'); 426 427 img.classList.add('mbr-background-video-preview'); 428 img.style.display = 'none'; 429 img.style.backgroundSize = 'cover'; 430 img.style.backgroundPosition = 'center'; 431 432 if (!el.querySelector('.mbr-background-video-preview')) el.childNodes[0].before(img); 433 434 const optimizeDisplay = function (player, iframe) { 435 let vid = {}; 436 let win = {}; 437 win.width = window.outerWidth; 438 win.height = window.outerHeight; 439 440 let ratio = player._opts.width / player._opts.height; 441 442 vid.width = win.width;
443 vid.height = Math.ceil(vid.width / ratio); 444 vid.marginTop = Math.ceil(-((vid.height - win.height) / 2)); 445 let lowest = vid.height < win.height; 446 447 if (lowest) { 448 vid.height = win.height; 449 vid.width = Math.ceil(vid.height * ratio); 450 vid.marginLeft = Math.ceil(-((vid.width - win.width) / 2)) 451 } 452 player.setSize(vid.width, vid.height); 453 }; 454 455 // youtube or vimeo 456 if (parsedUrl && (/youtu\.?be/g.test(parsedUrl[3]) || /vimeo/g.test(parsedUrl[3]))) { 457 // youtube 458 if (parsedUrl && /youtu\.?be/g.test(parsedUrl[3])) { 459 parsedUrl[6] = parsedUrl[6].replace('shorts', 'embed') 460 var previewURL = 'http' + ('https:' === location.protocol ? 's' : '') + ':'; 461 previewURL += '//img.youtube.com/vi/' + parsedUrl[6] + '/maxresdefault.jpg'; 462 var image = new Image(); 463 464 image.onload = function () { 465 466 if (120 === (image.naturalWidth || image.width)) { 467 // selection of preview in the best quality 468 var file = image.src.split('/').pop(); 469 470 switch (file) { 471 case 'maxresdefault.jpg': 472 image.src = image.src.replace(file, 'sddefault.jpg'); 473 break; 474 case 'sddefault.jpg': 475 image.src = image.src.replace(file, 'hqdefault.jpg'); 476 break; 477 default: // image not found 478 if (isBuilder) { 479 img.style.backgroundImage = 'url("images/no-video.jpg")'; 480 img.style.display = 'block'; 481 } 482 } 483 } else { 484 img.style.backgroundImage = 'url("' + image.src + '")'; 485 img.style.display = 'block'; 486 } 487 488 if (el.querySelector('.mbr-background-video')) el.querySelector('.mbr-background-video').remove(); 489 490 var videoElement = document.createElement('div'); 491 const wrapperBackground = document.createElement('div'); 492 const videoBackground = document.createElement('div') 493 const videoForeground = document.createElement('div') 494 495 videoForeground.classList.add('mbr-video-foreground'); 496 497 videoForeground.appendChild(videoElement) 498 videoBackground.appendChild(videoForeground) 499 wrapperBackground.appendChild(videoBackground) 500 501 videoElement.classList.add('mbr-background-video'); 502 503 var playerEl = el.childNodes[1].before(wrapperBackground); 504 505 var imageResolution = { 506 height: image.naturalHeight, 507 width: image.naturalWidth, 508 scale: image.naturalHeight / image.naturalWidth 509 }; 510 511 var sectionResolution = { 512 height: videoElement.parentNode.clientHeight, 513 width: videoElement.parentNode.clientWidth, 514 scale: videoElement.parentNode.clientHeight / videoElement.parentNode.clientWidth, 515 }; 516
517 var videoResolution = { 518 height: imageResolution.height < sectionResolution.height ? imageResolution.height : sectionResolution.height, 519 width: imageResolution.width > sectionResolution.width ? imageResolution.width : sectionResolution.width 520 }; 521 if (videoResolution.height/videoResolution.width != imageResolution.scale) { 522 videoResolution.height = videoResolution.width * imageResolution.scale 523 } 524 var options = { 525 // height: videoResolution.height, 526 // width: videoResolution.width, 527 modestBranding: true, 528 autoplay: true, 529 controls: false, 530 origin: '*', 531 iv_load_policy: false, 532 keyboard: false, 533 captions: false, 534 annotations: false, 535 related: false, 536 start: startAt 537 } 538 539 var player = new YouTubePlayer(videoElement, options); 540 541 wrapperBackground.style.overflow = 'hidden'; 542 wrapperBackground.style.position = 'absolute'; 543 wrapperBackground.style.width = '100%'; 544 wrapperBackground.style.height = '100%'; 545 wrapperBackground.style.top = '0'; 546 wrapperBackground.style.left = '0'; 547 548 videoBackground.style.background = '#000'; 549 videoBackground.style.top = '0'; 550 videoBackground.style.right = '0'; 551 videoBackground.style.bottom = '0'; 552 videoBackground.style.left = '0'; 553 554 videoForeground.style.position = 'absolute'; 555 videoForeground.style.top = '0'; 556 videoForeground.style.left = '0'; 557 videoForeground.style.width = '100%'; 558 videoForeground.style.height = '100%'; 559 videoForeground.style.pointerEvents = 'none'; 560 561 videoElement.style.marginTop = '0'; 562 videoElement.style.maxWidth = 'initial'; 563 videoElement.style.transitionProperty = 'opacity'; 564 videoElement.style.transitionDuration = '1000ms'; 565 videoElement.style.pointerEvents = 'none'; 566 videoElement.style.position = 'absolute'; 567 videoElement.style.top = '0'; 568 videoElement.style.left = '0'; 569 videoElement.style.width = '100%'; 570 videoElement.style.height = '100%'; 571 videoElement.style.transform = 'scale(1.2)'; 572 573 player.load(parsedUrl[6], true, startAt); 574 player.play(); 575 //player.loadPlaylist(); 576 player.setLoop(true); 577 player.mute(); 578 player.on('ended', () => player.play()); 579 580 optimizeDisplay(player); 581 } 582 image.setAttribute('src', previewURL); 583 } else if (parsedUrl && /vimeo/g.test(parsedUrl[3])) { // vimeo 584 var request = new XMLHttpRequest(); 585 request.open('GET', 'https://vimeo.com/api/v2/video/' + parsedUrl[6] + '.json', true); 586 request.onreadystatechange = function () { 587 if (this.readyState === 4) { 588 if (this.status >= 200 && this.status < 400) { 589 var response = JSON.parse(this.responseText); 590 img.style.backgroundImage = 'url("' + response[0].thumbnail_large + '")'; 591 img.style.display = 'block'; 592 } else if (isBuilder) { // image not found 593 img.style.backgroundImage = 'url("images/no-video.jpg")'; 594 img.style.display = 'block'; 595 } 596 } 597 }; 598 request.send(); 599 request = null; 600 601 if (el.querySelector('.mbr-background-video')) el.querySelector('.mbr-background-video').remove(); 602 603 var videoElement = document.createElement('div'); 604 videoElement.classList.add('mbr-background-video'); 605 606 var playerEl = el.childNodes[1].before(videoElement); 607 608 var options = { 609 id: videoURL, 610 loop: true, 611 background: true, 612 responsive: true, 613 autoplay: true, 614 byline: false, 615 title: false, 616 muted: true, 617 controls: false 618 } 619 620 var player = new Vimeo.Player(videoElement, options); 621 var playerParent = player.element.parentNode; 622 623 playerParent.style.overflow = 'hidden'; 624 player.element.style.pointerEvents = 'none'; 625 player.element.style.marginLeft = '-'+(player.element.scrollWidth - playerParent.scrollWidth)/2+'px'; 626 player.element.style.minHeight = '100vh'; 627 player.element.style.minWidth = '177.77vh'; 628 } 629 } else if (isBuilder) { // neither youtube nor vimeo 630 img.style.backgroundImage = 'url("images/video-placeholder.jpg")'; 631 img.style.display = 'block'; 632 } else if (!isBuilder) { 633 var videoElement = document.createElement('video'); 634 var sourceElement = document.createElement('source'); 635 636 videoElement.append(sourceElement) 637 638 el.childNodes[1].before(videoElement); 639 640 sourceElement.src = videoURL; 641 videoElement.autoplay = true; 642 videoElement.loop = true; 643 644 videoElement.muted = true; 645 videoElement.setAttribute('muted', ''); 646 647 videoElement.playsinline = true; 648 videoElement.setAttribute('playsinline', ''); 649 650 videoElement.style.position = 'absolute'; 651 videoElement.style.left = '50%'; 652 videoElement.style.top = '50%'; 653 videoElement.style.bottom = '0'; 654 videoElement.style.right = '0'; 655 videoElement.style.minWidth = '100%'; 656 videoElement.style.minHeight = '100%'; 657 videoElement.style.transform = 'translateX(-50%) translateY(-50%)'; 658 659 let placeholder = ''; 660 661 if (el.querySelector('.mbr-fallback-image')) { 662 placeholder = window.getComputedStyle(el.querySelector('.mbr-fallback-image')).backgroundImage; 663 placeholder = placeholder.match(/\((.*?)\)/)[1].replace(/('|")/g,''); 664 videoElement.setAttribute('poster', placeholder); 665 } 666 667 videoElement.parentNode.style.overflow = 'hidden'; 668 } 669 }); 670 } 671 672 if (isBuilder) { 673 if (!isJQuery) return; 674 var targets = []; 675 $(document).on('add.cards', function (event) { 676 if (targets.some(el => el === event.target) || !event.target.hasAttribute('mbr-data-bg-video')) return; 677 targets.push(event.target); 678 videoParser(event.target); 679 }); 680 } else { 681 videoParser(document.body); 682 } 683 684 if (isBuilder) $(document).on('changeParameter.cards', function (event, paramName, value, key) { 685 // document.addEventListener('changeParameter.cards', function (event, paramName, value, key) { 686 if (paramName === 'bg') { 687 switch (key) { 688 case 'type': 689 if (value.type === 'video') { 690 videoParser(event.target); 691 } 692 break; 693 case 'value': 694 if (value.type === 'video') { 695 videoParser(event.target); 696 } 697 break; 698 } 699 } 700 }); 701 702 document.querySelector('html').classList.add('mbr-site-loaded'); 703 window.dispatchEvent(new CustomEvent('resize'));
704 window.dispatchEvent(new CustomEvent('scroll')); 705 706 // smooth scroll 707 708 if (!isBuilder) { 709 document.addEventListener('click', function (e) { 710 try { 711 var target = e.target; 712 713 if (target.parents().some(function(el) {el.classList.contains('carousel')})) { 714 return; 715 } 716 do { 717 if (target.hash) { 718 var useBody = /#bottom|#top/g.test(target.hash); 719 document.querySelectorAll(useBody ? 'body' : target.hash).forEach(function (el) { 720 e.preventDefault(); 721 722 var stickyMenuHeight = document.querySelector('.navbar-fixed-top'); 723 724 var stickyMenuHeightCalculate = function(){ 725 return stickyMenuHeight ? 60 : 0; 726 } 727 728 var goTo = target.hash == '#bottom' ? (getHe
728ight(el) - window.innerHeight) : (offset(el).top - stickyMenuHeightCalculate()); 729 // Disable Accordion's and Tab's scroll 730 function carouselCheck() { 731 return target.classList.contains('carousel-control') || !!target.parents('.carousel-controls').length 732 } 733 734 if (el.classList.contains('panel-collapse') || el.classList.contains('tab-pane') || carouselCheck()) { 735 return; 736 } 737 738 window.scrollTo({ 739 top: goTo, 740 left: 0, 741 behavior: 'smooth' 742 }); 743 }); 744 break; 745 } 746 } while (target = target.parentNode); 747 } catch (e) { 748 // throw e; 749 } 750 }); 751 } 752 753 754 // init the same height columns 755 756 document.querySelectorAll('.cols-same-height .mbr-figure').forEach(function (el) { 757 var img = el.querySelector('img'); 758 var cont = el.parentNode; 759 var imgW = img.width; 760 var imgH = img.height; 761 762 function setNewSize() { 763 img.style.width = ''; 764 img.style.maxWidth = ''; 765 img.style.marginLeft = ''; 766 767 if (imgH && imgW) { 768 var aspectRatio = imgH / imgW; 769 770 // needs check (in jQ version supposedly should be .css() instead of .addClass()) 771 el.style.position = 'absolute'; 772 el.style.top = '0'; 773 el.style.left = '0'; 774 el.style.right = '0'; 775 el.style.bottom = '0'; 776 777 // change image size 778 var contAspectRatio = getHeight(cont) / getWidth(cont); 779 if (contAspectRatio > aspectRatio) { 780 var percent = 100 * (contAspectRatio - aspectRatio) / aspectRatio; 781 img.style.width = percent + 100 + '%'; 782 img.style.maxWidth = percent + 100 + '%'; 783 img.style.marginLeft = (-percent / 2) + '%'; 784 } 785 } 786 } 787 788 img.addEventListener('load', function () { 789 imgW = img.width; 790 imgH = img.height; 791 setNewSize(); 792 }, { 793 once: true 794 }); 795 796 window.addEventListener('resize', setNewSize); 797 setNewSize(); 798 }); 799 }); 800 801 802 if (!isBuilder) { 803 // mbr-social-likes 804 if (isJQuery && $.fn.socialLikes) { 805 $(document).on('add.cards', function (event) { 806 // document.addEventListener('add.cards', function (event) { 807 outerFind(event.target, '.mbr-social-likes').forEach(function(el) { 808 el.addEventListener('counter.social-likes', function (event, service, counter) { 809 if (counter > 999) event.target.querySelectorAll('.social-likes__counter').forEach(function(el) { 810 el.innerHTML = Math.floor(counter / 1000) + 'k'; 811 }); 812 }) 813 el.socialLikes({ 814 initHtml: false 815 }); 816 }); 817 }); 818 } 819 Array.from(document.body.children).filter(function(el) { return !el.matches('style, script')}) 820 .forEach(function(el) { 821 if (el.classList.contains('mbr-reveal')) { 822 el.addEventListener('add.cards', function() { 823 el.footerReveal(); 824 }); 825 } 826 }); 827 828 ready(function () { 829 // disable animation on scroll on mobiles 830 if (isMobile()) { 831 return; 832 // enable animation on scroll 833 } else if (document.querySelectorAll('input[name=animation]').length) { 834 document.querySelectorAll('input[name=animation]').forEach(function(el){ el.remove() }); 835 836 var animatedElements = Array.from(document.querySelectorAll('p, h1, h2, h3, h4, h5, a, button, small, img, li, blockquote, .mbr-author-name, em, label, input, select, textarea, .input-group, .form-control, .iconbox, .btn-social, .mbr-figure, .mbr-map, .mbr-testimonial .card-block, .mbr-price-value, .mbr-price-figure, .dataTable, .dataTables_info, .item')); 837 animatedElements = animatedElements.filter(function(el) { 838 if (!el.parents().filter(function(parentElement) { 839 if (parentElement.matches('a, p, .navbar, .mbr-arrow, footer, .iconbox, .mbr-slider, .mbr-gallery, .mbr-testimonial .card-block, #cookiesdirective, .mbr-wowslider, .accordion, .tab-content, .engine, #scrollToTop, .modal, .item')) { 840 return true 841 } 842 }).length) { 843 return true 844 }; 845 }) 846 847 animatedElements = animatedElements.filter(function(el) { 848 if (!el.parents().filter(function(i) { 849 return i.matches('form') && !el.matches('li') 850 }).length) return true; 851 }) 852
853 animatedElements.forEach(function(el){ 854 el.classList.add('hidden') 855 el.classList.add('animate__animated') 856 el.classList.add('animate__delay-1s') 857 }); 858 859 function getElementOffset(element) { 860 var top = 0; 861 do { 862 top += element.offsetTop || 0; 863 element = element.offsetParent; 864 } while (element); 865 866 return top; 867 } 868 869 function elCarouselItem(element) { 870 if (element.parents('.carousel-item').some(function(x) { 871 return getComputedStyle(x, null).display !== 'none' 872 })) return false; 873 874 var parentEl = element.parents('.carousel-item').parentNode; 875 if (!parentEl) return false 876 if (parentEl.querySelectorAll('.carousel-item.active .hidden.animate__animated').length) { 877 return false; 878 } 879 else if (parentEl.getAttribute('data-visible') > 1) { 880 var visibleSlides = parentEl.getAttribute('data-visible'); 881 if (element.parents().some(function (el) {return el.matches('.cloneditem-' + (visibleSlides - 1))}) && element.parents('.cloneditem-' + (visibleSlides - 1)).some(function (el) {return el.getAttribute('data-cloned-index') >= visibleSlides})) { 882 return true; 883 } 884 else { 885 element.classList.remove('animate__animated animate__delay-1s hidden'); 886 return false; 887 } 888 } 889 else return true; 890 } 891 892 function checkIfInView() { 893 var window_height = window.innerHeight; 894 var window_top_position = document.documentElement.scrollTop || document.body.scrollTop; 895 var window_bottom_position = window_top_position + window_height - 100; 896 897 animatedElements.forEach(function (el) { 898 var element = el; 899 var element_height = element.offsetHeight; 900 var element_top_position = getElementOffset(element); 901 var element_bottom_position = (element_top_position + element_height); 902 903 // check to see if this current element is within viewport 904 if ((((element_bottom_position >= window_top_position) && 905 (element_top_position-50 <= window_bottom_position)) || elCarouselItem(el)) && 906 (el.classList.contains('hidden'))) { 907 el.classList.remove('hidden') 908 el.classList.add('animate__fadeIn') 909 el.classList.add('animate__delay-1s') 910 el.addEventListener('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function () { 911 el.classList.remove('animate__animated animate__delay-1s animate__fadeIn'); 912 }, { 913 once: true 914 }) 915 } 916 }); 917 } 918 919 window.addEventListener('scroll', checkIfInView); 920 window.addEventListener('resize', checkIfInView); 921 window.dispatchEvent(new CustomEvent('scroll')); 922 } 923 }); 924 } 925 926 // Scroll to Top Button 927 928 ready(function () { 929 if (document.querySelectorAll('.mbr-arrow-up').length) { 930 var scroller = document.querySelector('#scrollToTop'); 931 scroller.style.display = 'none'; 932 window.addEventListener('scroll', function () { 933 var scrollHeight = Math.max( 934 document.body.scrollHeight, document.documentElement.scrollHeight, 935 document.body.offsetHeight, document.documentElement.offsetHeight, 936 document.body.clientHeight, document.documentElement.clientHeight 937 ); 938 var scrollTop = document.documentElement.scrollTop || document.body.scrollTop; 939 940 if (scrollTop > scrollHeight / 2 - document.documentElement.clientHeight / 2 || window.scrollY > window.innerHeight) { 941 fadeIn(scroller); 942 } else { 943 fadeOut(scroller); 944 } 945 }); 946 947 scroller.addEventListener('click', function () { 948 window.scrollTo({ 949 top: 0, 950 left: 0, 951 behavior: 'smooth' 952 }); 953 return false; 954 }); 955 } 956 });
957 958 // arrow down 959 960 if (!isBuilder) { 961 var arrowDown = document.querySelector('.mbr-arrow'); 962 if (arrowDown) { 963 arrowDown.addEventListener('click', function (e) { 964 var next = e.target.closest('section').nextElementSibling; 965 if (next.classList.contains('engine')) { 966 next = next.closest('section').nextElementSibling; 967 } 968 969 // needs tests 970 window.scrollTo(0, offset(next).top); 971 /* 972 $('html, body').stop().animate({ 973 scrollTop: offset.top 974 }, 800, 'linear'); 975 */ 976 }); 977 } 978 } 979 980 // add padding to the first element, if it exists 981 if (document.querySelectorAll('nav.navbar').length) { 982 var navHeight = getHeight(document.querySelector('nav.navbar')); 983 if (document.querySelector('.mbr-after-navbar.mbr-fullscreen')) document.querySelector('.mbr-after-navbar.mbr-fullscreen').style.paddingTop = navHeight + 'px'; 984 } 985 986 function isIE() { 987 var ua = window.navigator.userAgent; 988 var msie = ua.indexOf('MSIE '); 989 990 if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)) { 991 return true; 992 } 993 994 return false; 995 } 996 997 // fixes for IE 998 999 if (!isBuilder && isIE()) { 1000 $(document).on('add.cards', function (event) { 1001 // document.addEventListener('add.cards', function (event) { 1002 var eventTarget = event.target; 1003 1004 if (eventTarget.classList.contains('mbr-fullscreen')) { 1005 var eventListener = function () { 1006 eventTarget.style.height = 'auto'; 1007 1008 if (eventTarget.offsetHeight <= window.innerHeight) { 1009 eventTarget.style.height = '1px'; 1010 } 1011 } 1012 window.addEventListener('load', eventListener); 1013 window.addEventListener('resize', eventListener); 1014 } 1015 1016 if (eventTarget.classList.contains('mbr-slider') || eventTarget.classList.contains('mbr-gallery')) { 1017 eventTarget.querySelectorAll('.carousel-indicators').forEach(function(el) { 1018 el.classList.add('ie-fix'); 1019 el.querySelectorAll('li').forEach(function (x) { 1020 x.style.display = 'inline-block'; 1021 x.style.width = '30px'; 1022 }) 1023 }) 1024 1025 if (eventTarget.classList.contains('mbr-slider')) { 1026 eventTarget.querySelectorAll('.full-screen .slider-fullscreen-image').forEach(function(x) {x.style.height = '1px'}); 1027 } 1028 } 1029 }); 1030 } 1031 1032 // Script for popUp video 1033 1034 ready(function () { 1035 if (!isBuilder) { 1036 var clickListener = function (event) { 1037 if (!event.target) return 1038 if (event.target.tagName == 'VIDEO') { 1039 event.preventDefault(); 1040 event.stopPropagation(); 1041 return 1042 }; 1043 modal(event.target); 1044 }; 1045 var modal = function (item) { 1046 var videoIframe = item.parents('section')[0].querySelector('iframe'), 1047 videoIframeSrc = videoIframe.getAttribute('src'); 1048 1049 item.parents('section').forEach(function(el) {el.style.zIndex = '5000'}); 1050 1051 if (videoIframeSrc) { 1052 if (videoIframeSrc.indexOf('youtu') !== -1) { 1053 videoIframe.contentWindow.postMessage('{"event":"command","func":"playVideo","args":""}', '*'); 1054 } 1055 1056 if (videoIframeSrc.indexOf('vimeo') !== -1) { 1057 var vimeoPlayer = new Vimeo.Player(videoIframe); 1058 vimeoPlayer.play(); 1059 } 1060 } else { 1061 let newVideo = videoIframe.parentNode.querySelector('video'); 1062 if (newVideo) { 1063 if (newVideo.play) newVideo.play(); 1064 } 1065 } 1066 1067 var section = item.parents('section')[0], 1068 modalWindow = section.querySelector(section.querySelector('[data-modal]').getAttribute('data-modal')); 1069 1070 modalWindow.style.display = 'table'; 1071 modalWindow.addEventListener('click', function(e) { 1072 if (e.target.tagName === 'VIDEO') return; 1073 if (videoIframeSrc) { 1074 if (videoIframeSrc.indexOf('youtu') !== -1) { 1075 videoIframe.contentWindow.postMessage('{"event":"command","func":"pauseVideo","args":""}', '*'); 1076 } 1077 1078 if (videoIframeSrc.indexOf('vimeo') !== -1) { 1079 vimeoPlayer.pause(); 1080 } 1081 } else { 1082 let newVideo = videoIframe.parentNode.querySelector('video'); 1083 if (newVideo) { 1084 if (newVideo.pause) newVideo.pause(); 1085 } 1086 } 1087 1088 modalWindow.style.display = 'none'; 1089 modalWindow.removeEventListener('click', clickListener); 1090 section.style.zIndex = '0'; 1091 }) 1092 }; 1093 1094 // Youtube & Vimeo 1095 document.querySelectorAll('.modalWindow-video > iframe').forEach(function (el) { 1096 // var videoURL = el.getAttribute('data-src') || el.getAttribute('src'); 1097 var videoURL = el.getAttribute('data-src'); 1098 if (!videoURL) return; 1099 el.removeAttribute('data-src'); 1100 1101 1102 // var videoURL = el.getAttribute('data-src') || el.getAttribute('src'); 1103 // el.removeAttribute('data-src'); 1104 // el.removeAttribute('src'); 1105 1106 var parsedUrl = videoURL.match(/(http:\/\/|https:\/\/|)?(player.|www.)?(vimeo\.com|youtu(be\.com|\.be|be\.googleapis\.com))\/(shorts\/|video\/|embed\/|watch\?v=|v\/)?([A-Za-z0-9._%-]*)(&\S+)?/); 1107 if (videoURL.indexOf('youtu') !== -1) { 1108 el.setAttribute('src', 'https://youtube.com/embed/' + parsedUrl[6] + '?rel=0&enablejsapi=1'); 1109 } else if (videoURL.indexOf('vimeo') !== -1) { 1110 el.setAttribute('src', 'https://player.vimeo.com/video/' + parsedUrl[6] + '?autoplay=0&loop=0'); 1111 } else if (/\.mp4|\.webm|\.ogg|\.ogv|\.m4a|\.m4v/.test(videoURL)) { 1112 let newVideo = document.createElement('video'); 1113 1114 newVideo.onloadeddata = function(e) { 1115 if (e.target.videoHeight > e.target.videoWidth) { 1116 e.target.style.height = window.innerHeight - (window.innerHeight * 0.2) + 'px'; 1117 } else { 1118 e.target.style.height = '100%'; 1119 } 1120 } 1121 1122 let posterEl = el.parents('section')[0].querySelector('img'); 1123 if (posterEl) {newVideo.setAttribute('poster', posterEl.src)}; 1124 newVideo.setAttribute('controls', '') 1125 newVideo.setAttribute('playsinline', '') 1126 newVideo.setAttribute('loop', ''); 1127 newVideo.setAttribute('src', videoURL); 1128 el.style.display = 'none'; 1129 newVideo.style.width = '100%'; 1130 el.after(newVideo); 1131 } 1132 }); 1133 1134 if (document.querySelector('[data-modal]')) 1135 document.querySelectorAll('[data-modal]').forEach(function(el){ 1136 el.addEventListener('click', clickListener); 1137 }) 1138 } 1139 });
1140 1141 1142 if (!isBuilder) { 1143 // removes the public class if it was open when published 1144 const dropdownTogglesArray = document.querySelectorAll('.dropdown-toggle.show'); 1145 const dropdownMenusArray = document.querySelectorAll('.dropdown-menu.show, .dropdown.open'); 1146 const dropdownArray = document.querySelectorAll('.dropdown.open'); 1147 1148 dropdownTogglesArray.forEach(dropdownTogglerItem => { 1149 dropdownTogglerItem.classList.remove('show'); 1150 dropdownTogglerItem.ariaExpanded = 'false'; 1151 }); 1152 1153 dropdownMenusArray.forEach(dropdownMenuItem => dropdownMenuItem.classList.remove('show')); 1154 1155 dropdownArray.forEach(dropdownItem => dropdownItem.classList.remove('open')); 1156 1157 // open dropdown menu on hover 1158 if (!isMobile()) { 1159 var menu = document.querySelector('section.menu'); 1160 if (menu) { 1161 var width = window.innerWidth, 1162 collapsed = menu.querySelector('.navbar').classList.contains('collapsed'); 1163 // check if collapsed on 1164 if (!collapsed) { 1165 // check width device 1166 if (width > 991) { 1167 menu.querySelectorAll('ul.navbar-nav li.dropdown').forEach(function(el) { 1168 el.addEventListener('mouseover', function() { 1169 if (!el.classList.contains('open')) { 1170 const dropdownItem = el.querySelector('a'); 1171 dropdownItem.parentNode.classList.toggle('open'); 1172 } 1173 }); 1174 el.addEventListener('mouseout', function() { 1175 if (el.classList.contains('open')) { 1176 const dropdownItem = el.querySelector('a'); 1177 dropdownItem.parentNode.classList.toggle('open'); 1178 } 1179 }); 1180 }) 1181 menu.querySelectorAll('ul.navbar-nav li.dropdown .dropdown-menu .dropdown').forEach(function(el) { 1182 el.addEventListener('mouseover', function() { 1183 if (!el.classList.contains('open')) { 1184 el.classList.toggle('open'); 1185 } 1186 }); 1187 el.addEventListener('mouseout', function() { 1188 if (el.classList.contains('open')) { 1189 el.classList.toggle('open'); 1190 } 1191 }); 1192 }) 1193 } 1194 } 1195 } 1196 } 1197 } 1198 1199 // Functions from plugins for 1200 // compatibility with old projects 1201 1202 1203 function setActiveCarouselItem(card){ 1204 var target = card.querySelector('.carousel-item'), 1205 firstIndicator = card.querySelector('.carousel-indicators > li') 1206 target.classList.add('active'); 1207 if (firstIndicator) firstIndicator.classList.add('active'); 1208 } 1209 1210 function initTestimonialsCarousel(card) { 1211 var target = card, 1212 carouselID = target.getAttribute('id') + '-carousel', 1213 bs5 = target.getAttribute('data-bs-version') && target.getAttribute('data-bs-version').startsWith('5'); 1214 1215 if (target.getAttribute('id') === null) { 1216 carouselID = target.classList.value.match(/cid-.*?(?=\s|$)/) + '-carousel'; 1217 } 1218 1219 target.querySelectorAll('.carousel').forEach(function(el) {el.setAttribute('id', carouselID)}); 1220 if (target.querySelector('.carousel-controls')) target.querySelectorAll('.carousel-controls').forEach(function(el) { 1221 el.querySelectorAll('a').forEach(function(el) { 1222 el.setAttribute('href', '#' + carouselID); 1223 bs5 ? el.setAttribute('data-bs-target', '#' + carouselID) 1224 : el.setAttribute('data-target', '#' + carouselID); 1225 }); 1226 }) 1227 target.querySelectorAll('.carousel-indicators > li').forEach(function(el) { 1228 bs5 ? el.setAttribute('data-bs-target', '#' + carouselID) 1229 : el.setAttribute('data-target', '#' + carouselID); 1230 });
1231 setActiveCarouselItem(target); 1232 } 1233 1234 1235 1236 function initClientCarousel(card) { 1237 var target = card, 1238 countElems = target.querySelectorAll('.carousel-item').length, 1239 visibleSlides = target.querySelector('.carousel-inner').getAttribute('data-visible'); 1240 if (countElems < visibleSlides) { 1241 visibleSlides = countElems; 1242 } 1243 target.querySelectorAll('.carousel-inner').forEach(function(el) {el.setAttribute('class', 'carousel-inner slides' + visibleSlides)}); 1244 target.querySelectorAll('.clonedCol').forEach(function(el) {el.remove()}); 1245 1246 target.querySelectorAll('.carousel-item .col-md-12').forEach(function (el) { 1247 if (visibleSlides < 2) { 1248 el.setAttribute('class', 'col-md-12'); 1249 } else if (visibleSlides == '5') { 1250 el.setAttribute('class', 'col-md-12 col-lg-15'); 1251 } else { 1252 el.setAttribute('class', 'col-md-12 col-lg-' + 12 / visibleSlides); 1253 } 1254 }); 1255 1256 // css fix for carousel mess in bs5 1257 target.querySelectorAll('.carousel-item .row').forEach(function(el) { 1258 el.setAttribute('style', '-webkit-flex-grow: 1; flex-grow: 1; margin: 0;') 1259 }); 1260 1261 target.querySelectorAll('.carousel-item').forEach(function (el) { 1262 var itemToClone = el; 1263 for (var i = 1; i < visibleSlides; i++) { 1264 itemToClone = itemToClone.nextElementSibling; 1265 if (!itemToClone) { 1266 itemToClone = el.parentNode.children[0] === el ? el.nextElementSibling : el.parentNode.children[0]; 1267 } 1268 var index = getIndex(itemToClone); 1269 var clonedItem = itemToClone.querySelector('.col-md-12').cloneNode(true); 1270 clonedItem.classList.add('cloneditem-' + i); 1271 clonedItem.classList.add('clonedCol'); 1272 clonedItem.setAttribute('data-cloned-index', index); 1273 el.children[0].appendChild(clonedItem); 1274 } 1275 }); 1276 } 1277 1278 function clickPrev(event) { 1279 event.stopPropagation(); 1280 event.preventDefault(); 1281 } 1282 1283 if (!isBuilder) { 1284 if (typeof window.initClientPlugin === 'undefined') { 1285 if (document.body.querySelectorAll('.clients').length != 0) { 1286 window.initClientPlugin = true; 1287 document.body.querySelectorAll('.clients').forEach(function (el) { 1288 if (!el.getAttribute('data-isinit')) { 1289 initTestimonialsCarousel(el); 1290 initClientCarousel(el); 1291 } 1292 }); 1293 } 1294 } 1295 if (typeof window.initPopupBtnPlugin === 'undefined') { 1296 if (document.body.querySelectorAll('section.popup-btn-cards').length != 0) { 1297 window.initPopupBtnPlugin = true; 1298 document.querySelectorAll('section.popup-btn-cards .card-wrapper').forEach(function (el) { 1299 el.classList.add('popup-btn'); 1300 }); 1301 } 1302 } 1303 if (typeof window.initTestimonialsPlugin === 'undefined') { 1304 if (document.body.querySelectorAll('.testimonials-slider').length != 0) { 1305 window.initTestimonialsPlugin = true; 1306 document.querySelectorAll('.testimonials-slider').forEach(function (el) { 1307 initTestimonialsCarousel(el); 1308 }); 1309 } 1310 } 1311 1312 1313 if (typeof window.initSwitchArrowPlugin === 'undefined'){ 1314 window.initSwitchArrowPlugin = true; 1315 ready(function () { 1316 if (document.querySelectorAll('.accordionStyles').length!=0) { 1317 document.querySelectorAll('.accordionStyles > .card > .card-header > a[role="button"]').forEach(function(el){ 1318 if(!el.classList.contains('collapsed')){ 1319 el.classList.add('collapsed'); 1320 } 1321 }); 1322 } 1323 }); 1324 document.querySelectorAll('.accordionStyles > .card > .card-header > a[role="button"]').forEach(function(el) { 1325 el.addEventListener('click', function() { 1326 var id = el.closest('.accordionStyles').getAttribute('id'), 1327 iscollapsing = el.closest('.card').querySelector('.panel-collapse'), 1328 sign = el.querySelector('span.sign') ? el.querySelector('span.sign') : el.querySelector('span.mbr-iconfont'); 1329 1330 if (iscollapsing.classList.contains('collapsing')) { 1331 if (id.indexOf('toggle')!= -1 || id.indexOf('accordion')!= -1) { 1332 if (el.classList.contains('collapsed')) { 1333 sign.classList.remove('mbri-arrow-up'); 1334 sign.classList.add('mbri-arrow-down'); 1335 } else { 1336 sign.classList.remove('mbri-arrow-down'); 1337 sign.classList.add('mbri-arrow-up'); 1338 } 1339 if (id.indexOf('accordion')!= -1) { 1340 var accordion = el.closest('.accordionStyles'); 1341 Array.from(accordion.children).filter(function(el) { return el.querySelector('span.sign') !== sign}) 1342 .forEach(function(el) { 1343 var icon = el.querySelector('span.sign') ? el.querySelector('span.sign') : el.querySelector('span.mbr-iconfont'); 1344 icon.classList.remove('mbri-arrow-up'); 1345 icon.classList.add('mbri-arrow-down'); 1346 }) 1347 } 1348 } 1349 } 1350 }) 1351 }) 1352 } 1353 1354 // Fix for slider bug 1355 if (document.querySelectorAll('.mbr-slider.carousel').length != 0) { 1356 document.querySelectorAll('.mbr-slider.carousel').forEach(function (el) { 1357 var slider = el, 1358 controls = slider.querySelectorAll('.carousel-control'), 1359 indicators = slider.querySelectorAll('.carousel-indicators li'), 1360 slideEventHandler = function (event) { clickPrev(event) } 1361 slider.addEventListener('slide.bs.carousel', function () {
1362 controls.forEach(function(el) {el.addEventListener('click', slideEventHandler)}); 1363 indicators.forEach(function(el) {el.addEventListener('click', slideEventHandler)}); 1364 // plugin needs replacement: bootstrapcarouselswipe 1365 if (isJQuery) $(slider).carousel({ 1366 keyboard: false 1367 }); 1368 }) 1369 slider.addEventListener('slid.bs.carousel', function () { 1370 controls.forEach(function(el) {el.removeEventListener('click', slideEventHandler)}); 1371 indicators.forEach(function(el) {el.removeEventListener('click', slideEventHandler)}); 1372 // plugin needs replacement: bootstrapcarouselswipe 1373 if (isJQuery) $(slider).carousel({ 1374 keyboard: true 1375 }); 1376 if (slider.querySelectorAll('.carousel-item.active').length > 1) { 1377 slider.querySelectorAll('.carousel-item.active')[1].classList.remove('active'); 1378 slider.querySelectorAll('.carousel-control li.active')[1].classList.remove('active'); 1379 } 1380 }); 1381 }); 1382 } 1383 } 1384 1385 // Form Styler 1386 1387 if (isBuilder) { 1388 if (!isJQuery) return; 1389 $(document).on('add.cards', function (event) { 1390 if ($(event.target).find('.form-with-styler').length) { 1391 var form = $(event.target).find('.form-with-styler'); 1392 $(form).find('select:not("[multiple]")').each(function () { 1393 if (!$(this).styler) return; 1394 $(this).styler(); 1395 }); 1396 $(form).find('input[type=number]').each(function () { 1397 if (!$(this).styler) return; 1398 $(this).styler(); 1399 $(this).parent().parent().removeClass('form-control') 1400 }); 1401 // documentation about plugin https://xdsoft.net/jqplugins/datetimepicker/ 1402 $(form).find('input[type=date]').each(function () { 1403 if ($(this).datetimepicker) 1404 $(this).datetimepicker({ 1405 format: 'Y-m-d', 1406 timepicker: false 1407 }); 1408 }); 1409 $(form).find('input[type=time]').each(function () { 1410 if ($(this).datetimepicker) 1411 $(this).datetimepicker({ 1412 format: 'H:i', 1413 datepicker: false 1414 }); 1415 }); 1416 1417 } 1418 }); 1419 } 1420 1421 document.querySelectorAll('input[type="range"]').forEach(function(el) { 1422 el.addEventListener('change', function(e) {e.target.parents('.form-group').forEach(function(x) { 1423 x.querySelector('.value').innerHTML = e.target.value 1424 })}); 1425 }); 1426 1427 1428 1429 // circular progress 1430 1431 function setGradient(section) { 1432 var linearGradient = '', 1433 gradientElement = section.querySelector('svg linearGradient'); 1434 if (gradientElement) { 1435 var colors = []; 1436 var stops = Array.from(gradientElement.children); 1437 for (var x = 0; x < stops.length; x++) { 1438 colors.push(`"${stops[x].getAttribute('stop-color')}"`); 1439 } 1440 linearGradient = `"lineargradient": [${colors}],`; 1441 if (!Array.from(section.querySelectorAll('svg')).some(function (el) { return el.classList.contains('svg-gradient') })) 1442 section.querySelectorAll('svg').forEach(function (el) {el.classList.add('svg-gradient')}); 1443 }; 1444 return linearGradient; 1445 } 1446 1447 function setProgressElement (el, cardID, percent) { 1448 // css fix for cards row 1449 var card = el.closest('.card'), 1450 rowClasses = card.parentElement.classList; 1451 if (!card.getAttribute('style')) 1452 card.setAttribute('style', '-webkit-flex-basis: auto; flex-basis: auto;');
1453 if (rowClasses.contains('row')) { 1454 rowClasses.remove('row'); 1455 rowClasses.add('media-container-row'); 1456 } 1457 1458 el.querySelectorAll('.svg-gradient > *').forEach(function(el) {el.setAttribute('id', cardID)}); 1459 var clonedEl = el.cloneNode(true); 1460 Array.from(el.children).forEach(function(el) { 1461 if (el.tagName !== 'SVG') return el.remove(); 1462 }) 1463 el.setAttribute('data-pie', `{ ${setGradient(el.closest('section'))} "percent": ${percent}, "size": 150, "colorCircle": "#f1f1f1", "stroke": 5, "colorSlice": "url(#${cardID})", "fontSize": "1.3rem", "number": false }`); 1464 Array.from(clonedEl.children).forEach(function(clonedChild) { 1465 switch (true) { 1466 case clonedChild.matches('p'): 1467 clonedChild.innerText = percent + '%'; 1468 el.appendChild(clonedChild); 1469 break; 1470 case clonedChild.matches('svg'): 1471 break; 1472 default: 1473 el.appendChild(clonedChild); 1474 } 1475 }) 1476 } 1477 1478 function initCircleProgress (card) { 1479 var section = card.closest('section'), 1480 cardID = section.getAttribute('id') + '-svg-gradient', 1481 percent = +card.getAttribute('data-goal'); 1482 setProgressElement(card, cardID, percent); 1483 } 1484 1485 function updateCircleProgress (section, paramName) { 1486 if (!section.classList.contains('circle-progress-section') || !paramName.includes('progress') || paramName == 'progressCount') return; 1487 if (paramName.includes('Color')) { 1488 section.querySelectorAll('.pie_progress').forEach(function(el) { 1489 var cardID = section.getAttribute('id') + '-svg-gradient', 1490 percent = +el.getAttribute('data-goal'); 1491 setProgressElement(el, cardID, percent); 1492 }) 1493 } else { 1494 var cardID = section.getAttribute('id') + '-svg-gradient', 1495 el = section.querySelector('.' + paramName), 1496 percent = +el.getAttribute('data-goal'); 1497 setProgressElement(el, cardID, percent); 1498 } 1499 } 1500 1501 if (isBuilder) { 1502 $(document).on('add.cards changeParameter.cards', function (event, paramName) { 1503 if (typeof CircularProgressBar !== 'undefined') new CircularProgressBar('pie_progress'); 1504 if (paramName) { 1505 updateCircleProgress(event.target, paramName) 1506 } else { 1507 if (event.target.querySelectorAll('.pie_progress').length) { 1508 event.target.querySelectorAll('.pie_progress').forEach(function(el) {initCircleProgress(el)}) 1509 } 1510 } 1511 }) 1512 } else { 1513 if (document.querySelectorAll('.pie_progress').length) { 1514 if (typeof CircularProgressBar !== 'undefined') new CircularProgressBar('pie_progress'); 1515 document.querySelectorAll('.pie_progress').forEach(function(el) {initCircleProgress(el)}) 1516 } 1517 } 1518 1519 if (isBuilder && isJQuery) { 1520 $(document).on('add.cards', function(event) { 1521 if($(event.target).hasClass('testimonials-slider')){ 1522 initTestimonialsCarousel(event.target); 1523 } 1524 1525 }).on('changeParameter.cards', function(event, paramName, value) { 1526 if (paramName === 'testimonialsSlides') { 1527 if ($(event.target).find('.carousel-item.active').length==0) {
1528 setActiveCarouselItem(event.target); 1529 } 1530 } 1531 }); 1532 } else { 1533 if (typeof window.initTestimonialsPlugin === 'undefined'){ 1534 window.initTestimonialsPlugin = true; 1535 document.querySelectorAll('.testimonials-slider').forEach(function(el){ 1536 initTestimonialsCarousel(el); 1537 }); 1538 } 1539 } 1540 1541 // init 1542 ready(function(){ 1543 if (!isBuilder) { 1544 Array.from(document.body.children).filter(function(el) { return !el.matches('style, script')}) 1545 .forEach(function(el) { 1546 if (window.Event && typeof window.Event === 'function') { 1547 var event = new Event('add.cards'); 1548 } else { 1549 var event = document.createEvent('CustomEvent'); 1550 event.initEvent('add.cards', true, true); 1551 } 1552 el.dispatchEvent(event); 1553 }) 1554 } 1555 }) 1556 1557 // background on scroll menu 1558 ready(() => { 1559 window.addEventListener('scroll', () => { 1560 const navbarDropdown = document.querySelector('.navbar-dropdown');
1561 const navbarCollapse = document.querySelector('.navbar-collapse'); 1562 1563 if (navbarDropdown && !navbarDropdown.classList.contains('opacityScrollOff')) { 1564 const scrollTop = document.documentElement.scrollTop; 1565 const isScrollingDown = scrollTop > 1; 1566 1567 navbarDropdown.classList.toggle("opacityScroll", !isScrollingDown); 1568 navbarCollapse.classList.toggle("opacityScroll", !isScrollingDown); 1569 } 1570 }); 1571 }); 1572 1573 // infinite marquee 1574 1575 function infinityMarquee() { 1576 const checkMarqueeOnPage = document.querySelector(".loop-container") 1577 1578 if (!checkMarqueeOnPage) { 1579 return 1580 } 1581 1582 const lerp = (current, target, factor) => current * (1 - factor) + target * factor; 1583 1584 const loopingText = (el) => { 1585 const lerpData = { current: 0, target: 0 }; 1586 const interpolationFactor = 0.2; // smoothness from 0.01 to 1 1587 const speed = +(el.children[0].dataset.speed) || 0.05; // speed from 0.01 to ~ 1588 const item = el.querySelector('.item'); 1589 const direction = item.dataset.direction // -1 left, 1 right 1590 1591 if (item) { 1592 // update the text content with line words 1593 const updateTextContent = () => { 1594 el.querySelectorAll('.item').forEach((item) => { 1595 const lineWords = item.dataset.linewords; 1596 item.textContent = lineWords + '\u00A0'; 1597 }); 1598 } 1599 1600 updateTextContent(); 1601 1602 1603 el.style.cssText = `position: relative; display: inline-flex; white-space: nowrap;`; 1604 el.children[1].style.cssText = `position: absolute; left: ${100 * -direction}%;`; 1605 1606 const animate = () => { 1607 lerpData.target += speed; 1608 lerpData.current = lerp(lerpData.current, lerpData.target, interpolationFactor); 1609 1610 if (lerpData.target > 100) { 1611 lerpData.current -= lerpData.target; 1612 lerpData.target = 0; 1613 } 1614 1615 const x = lerpData.current * direction; 1616 el.style.transform = `translateX(${x}%)`; 1617 1618 window.requestAnimationFrame(animate); 1619 }; 1620 1621 const events = () => { 1622 window.addEventListener("scroll", () => (lerpData.target += speed * 1.5)); 1623 }; 1624 1625 // tracking data-attribute changes to update the animation in the mbr 1626 const observer = new MutationObserver(() => { 1627 document.querySelectorAll(".loop-container").forEach(el => { 1628 el.style.transform = ""; // Reset the current animation 1629 }); 1630 observer.disconnect(); // Disconnect the observer to prevent cyclic observation 1631 loopingText(el); // Start the animation again after removal 1632 }); 1633 1634 observer.observe(item, { attributes: true, attributeFilter: ["data-direction", "data-speed", "data-linewords"] }); 1635 1636 1637 events(); 1638 animate(); 1639 } 1640 }; 1641 1642 document.querySelectorAll(".loop-container").forEach(el => loopingText(el)); 1643 } 1644 1645 if (isBuilder) { 1646 $(document).on("add.cards", infinityMarquee); 1647 } else { 1648 window.addEventListener("DOMContentLoaded", infinityMarquee); 1649 } 1650 1651 1652 // for animated text blocks 1653 1654 function tickerItemsUpdate() { 1655 const tickerItems = Array.from(document.querySelectorAll('.ticker__item')); 1656 1657 if (tickerItems.length === 0) { 1658 return; 1659 } 1660 1661 const textLines = tickerItems.map(item => item.textContent); 1662 const mutation = new MutationObserver(function () { 1663 tickerItems.forEach((item, index) => { 1664 const updatedWord = item.dataset['word']; 1665 item.textContent = updatedWord; 1666 }); 1667 }); 1668
1669 tickerItems.forEach((item, index) => { 1670 item.textContent = textLines[index]; 1671 mutation.observe(item, { attributes: true, attributeFilter: ['data-word'] }); 1672 }); 1673 1674 const updateTextContent = () => { 1675 document.querySelectorAll('.ticker__item').forEach((item) => { 1676 const lineWords = item.dataset.word; 1677 item.textContent = lineWords; 1678 }); 1679 } 1680 1681 updateTextContent(); 1682 } 1683 1684 if (isBuilder) { 1685 $(document).on("add.cards", tickerItemsUpdate); 1686 } else { 1687 window.addEventListener("DOMContentLoaded", tickerItemsUpdate); 1688 } 1689 1690 if (!document.getElementById('top-1')) { 1691 var e = document.createElement("section"); 1692 e.id = "top-1"; 1693 e.style = "display: none"; 1694 e.innerHTML = '<a href="https://ai.mobirise.com/">Mobirise AI Website Builder</a> Mobirise AI Alpha v0.01 <a href="https://mobirise.com/builder/ai-website-builder.html">AI Website Builder</a>'; 1695 document.body.insertBefore(e, document.body.childNodes[0]); 1696 } 1697}());
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.