1(function ($) { 2 3 'use strict'; 4 5 $.exists = function(selector) { 6 return ($(selector).length > 0); 7 } 8 9 $('.text-component a > img').parent('a').addClass('has-img'); 10 $('.text-component__inner .twitter-tweet').parent('.media-wrapper').addClass('twitter-embed'); 11 12 ms_header_menu(); 13 ms_page_transition(); 14 ms_stickyheader(); 15 ms_not_found(); 16 ms_theme_mode(); 17 ms_menu_default_mobile(); 18 ms_excerpt_plyr(); 19 ms_excerpt_gallery(); 20 ms_search_widget(); 21 ms_woo_quantity(); 22 ms_woo_category_loop(); 23 ms_woo_product_image(); 24 ms_video_background(); 25 ms_footer_effect(); 26 27 // Elementor Controllers 28 $(window).on('elementor/frontend/init', function () { 29 elementorFrontend.hooks.addAction( 'frontend/element_ready/ms_posts.default', ms_isotope_card_grid ); 30 elementorFrontend.hooks.addAction( 'frontend/element_ready/ms_projects.default', ms_masonry_gallery ); 31 elementorFrontend.hooks.addAction( 'frontend/element_ready/ms_projects.default', ms_carousel_showcase ); 32 elementorFrontend.hooks.addAction( 'frontend/element_ready/ms_gallery.default', ms_masonry_gallery ); 33 elementorFrontend.hooks.addAction( 'frontend/element_ready/ms_slider_fs.default', ms_full_slider ); 34 elementorFrontend.hooks.addAction( 'frontend/element_ready/ms_gallery.default', ms_lightbox ); 35 if( elementorFrontend.isEditMode() ) { 36 } else { 37 elementorFrontend.hooks.addAction( 'frontend/element_ready/ms_projects.default', ms_load_more_btn ); 38 } 39 elementorFrontend.hooks.addAction( 'frontend/element_ready/ms_projects.default', ms_load_more_btn_list ); 40 elementorFrontend.hooks.addAction( 'frontend/element_ready/ms-hero.default', ms_parallax_hero ); 41 elementorFrontend.hooks.addAction( 'frontend/element_ready/ms-hero-parallax.default', ms_parallax_hero_text ); 42 elementorFrontend.hooks.addAction( 'frontend/element_ready/ms_google_map.default', ms_initMap ); 43 elementorFrontend.hooks.addAction( 'frontend/element_ready/ms_video_button.default', ms_video_button ); 44 }); 45 46 function ms_video_background() { 47 48 if ($.exists('[data-vbg]')) { 49 $('[data-vbg]').youtube_background(); 50 } 51 52 } 53 54 function ms_footer_effect() { 55 56 if ($('body').attr('data-footer-effect') == 'on') { 57 var m_body = $('.ms-footer').height(); 58 59 $(window).on("resize", function() { 60 m_body = $('.ms-footer').height(); 61 ms_fer(); 62 }); 63 64 ms_fer(); 65 66 //responsive 67 function ms_fer() { 68 if (window.matchMedia('(max-width: 768px)').matches) { 69 $('.ms-main').css('margin-bottom', $('.ms-footer').height() + 'px'); 70 $('.ms-footer').css('position', 'fixed'); 71 } else { 72 $('.ms-main').css('margin-bottom', 'auto'); 73 $('.ms-footer').css('position', 'inherit'); 74 } 75 } 76 77 gsap.registerPlugin(ScrollTrigger); 78 79 ScrollTrigger.matchMedia({ 80 "(min-width: 768px)": function () { 81 82 ScrollTrigger.saveStyles(".footer-container"); 83 const uncover = gsap.timeline({ paused:true }) 84 85 uncover.to('.footer-container', { yPercent: 0, ease: 'none' }); 86 gsap.set('.footer-container', { yPercent: -50 }) 87 88 ScrollTrigger.create({ 89 trigger: '.ms-main', 90 start: 'bottom bottom', 91 end: '+=' + $('.ms-footer').height() + 'px', 92 animation: uncover, 93 scrub: true, 94 markers: false, 95 invalidateOnRefresh: true, 96 }); 97 98 } 99 }); 100 101 102 103 } 104 105 } 106 107 $(function() { 108 $('.stars').find('a').on('click', function() { 109 $(this).nextAll().removeClass('action'); 110 }); 111 $('.stars').find('a').mouseover(function() { 112 113 $('.stars').find('a').each(function() { 114 if ( $('.stars').find('a').hasClass('active')) { 115 116 } else { 117 $(this).mouseover(function() { 118 $(this).addClass('action'); 119 $(this).nextAll().removeClass('action'); 120 $(this).prevAll().addClass('action'); 121 }); 122 } 123 }); 124 125 }); 126 127 $('.stars').find('a').mouseout(function() { 128 129 $('.stars').find('a').each(function() { 130 if ( $('.stars').find('a').hasClass('active')) { 131 $('.active').prevAll().addClass('action'); 132 $('.active').removeClass('action').nextAll().removeClass('action'); 133 } else { 134 $('.stars').find('a').removeClass('action'); 135 } 136 }); 137 }); 138 139 });
140 141 function ms_search_widget() { 142 143 $('.header__search-icon').on('click', function() { 144 $('.header__search-modal').toggleClass('modal--is-visible'); 145 }); 146 147 $(document).on('click', '.modal--is-visible', function(e) { 148 if (e.target == this) { 149 $('.header__search-modal').toggleClass('modal--is-visible'); 150 } 151 }); 152 153 $('.header__search--close-btn').on('click', function() { 154 $('.header__search-modal').toggleClass('modal--is-visible'); 155 }); 156 157 } 158 159 function ms_woo_product_image() { 160 161 $('[data-fancybox]').on('click', function(e) { 162 e.preventDefault(); 163 164 }); 165 $('[data-fancybox]').magnificPopup({ 166 mainClass: 'mfp-fade', 167 tClose: 'Fechar (Esc)', 168 tLoading: '', 169 type: 'image', 170 image: { 171 titleSrc: function(item) { 172 return item.el.attr("title");; 173 } 174 }, 175 gallery: { 176 enabled:true, 177 preload: [0,2], 178 }, 179 180 mainClass: 'mfp-zoom-in', 181 removalDelay: 300, //delay removal by X to allow out-animation 182 callbacks: { 183 beforeOpen: function() { 184 $('#portfolio a').each(function(){ 185 $(this).attr('alt', $(this).find('img').attr('alt')); 186 }); 187 }, 188 open: function() { 189 //overwrite default prev + next function. Add timeout for css3 crossfade animation 190 $.magnificPopup.instance.next = function() { 191 var self = this; 192 self.wrap.removeClass('mfp-image-loaded'); 193 setTimeout(function() { $.magnificPopup.proto.next.call(self); }, 120); 194 } 195 $.magnificPopup.instance.prev = function() { 196 var self = this; 197 self.wrap.removeClass('mfp-image-loaded'); 198 setTimeout(function() { $.magnificPopup.proto.prev.call(self); }, 120); 199 } 200 }, 201 imageLoadComplete: function() { 202 var self = this; 203 setTimeout(function() { self.wrap.addClass('mfp-image-loaded'); }, 16); 204 } 205 } 206 207 }); 208 } 209 210 function ms_excerpt_plyr() { 211 var player = new Plyr('.ms-player'), 212 v_player = new Plyr('.ms-video-player'); 213 214 $('.wp-block-video').each(function() { 215 216 var videoPlayer = new Plyr($(this).find('video'), { 217 tooltips: { 218 controls: true, 219 seek: true 220 } 221 }); 222 223 }); 224 $('.wp-block-audio').each(function() { 225 226 var audioPlayer = new Plyr($(this).find('audio'), { 227 tooltips: { 228 controls: true, 229 seek: true 230 } 231 }); 232 233 }); 234 } 235 236 function ms_excerpt_gallery() { 237 const swiper = new Swiper('.ms-post-media__gallery', { 238 loop: true, 239 speed: 600, 240 navigation: { 241 nextEl: '.ms-sp-btn__next', 242 prevEl: '.ms-sp-btn__prev', 243 }, 244 }); 245 } 246 247 // Header menu 248 function ms_header_menu() { 249 if ($.exists('.js-main-header__nav-trigger')) { 250 var mainHeader = document.getElementsByClassName('js-main-header')[0]; 251 if( mainHeader ) { 252 var trigger = mainHeader.getElementsByClassName('js-main-header__nav-trigger')[0], 253 nav = mainHeader.getElementsByClassName('js-main-header__nav')[0]; 254 //detect click on nav trigger 255 trigger.addEventListener("click", function(event) { 256 event.preventDefault(); 257 var ariaExpanded = !Util.hasClass(nav, 'main-header__nav--is-visible'); 258 //show nav and update button aria value 259 Util.toggleClass(nav, 'main-header__nav--is-visible', ariaExpanded); 260 trigger.setAttribute('aria-expanded', ariaExpanded); 261 if(ariaExpanded) { //opening menu -> move focus to first element inside nav
262 nav.querySelectorAll('[href], input:not([disabled]), button:not([disabled])')[0].focus(); 263 } 264 }); 265 } 266 } 267 if ( $(window).width() > 1023 ){ 268 269 // Default Menu Style 270 if ($.exists('.menu-default')) { 271 var m_item = $('.navbar-nav').find(' > li.menu-item > a'); 272 273 $(m_item).each(function() { 274 $(this).html('<span>' + this.textContent + '</span>'); 275 $(this).attr("title", this.textContent); 276 }); 277 278 var menu_type = $("body").attr('data-menu'); 279 if (menu_type == 'fixed') { 280 var header = $(".main-header__layout").addClass('top'); 281 $(window).scroll(function() { 282 var scroll = $(window).scrollTop(); 283 284 if (scroll > 300) { 285 header.removeClass('top').addClass("action"); 286 } else { 287 header.addClass('top').removeClass("action"); 288 } 289 }); 290 } 291 292 } 293 294 $(window).scroll(function(){ 295 if ($(this).scrollTop() > 50) { 296 $('.main-header').addClass('show-bg'); 297 } else { 298 $('.main-header').removeClass('show-bg'); 299 } 300 301 }); 302 303 } 304 305 } 306 307 // Mobile Menu 308 function ms_menu_default_mobile() { 309 310 if ($(window).width() < 1024) { 311 $('.main-header__nav ').addClass('is_mobile'); 312 } 313 314 var isAbove1024 = $(window).width() > 1024; 315 $(window).on('resize', function(event){ 316 if( $(window).width() < 1077 && isAbove1024){ 317 isAbove1024 = false; 318 $('.sub-menu').css('display', 'none'); 319 $('.main-header__nav ').addClass('is_mobile'); 320 }else if($(window).width() > 1077 && !isAbove1024){ 321 isAbove1024 = true; 322 $('.sub-menu').css('display', 'block'); 323 $('.main-header__nav ').removeClass('is_mobile'); 324 } 325 }); 326 327 $(document).on('click', '.is_mobile .navbar-nav > .menu-item-has-children > a', function(e) { 328 e.preventDefault(); 329 if ($(this).hasClass('active')) { 330 $(this).removeClass('active'); 331 $(this).siblings('.sub-menu').slideUp(300); 332 } else { 333 $('.menu-item-has-children > a').removeClass('active'); 334 $(this).addClass('active'); 335 $('.sub-menu').slideUp(200); 336 $(this).siblings('.sub-menu').slideDown(300); 337 } 338 }); 339 340 $(document).on('click', '.is_mobile .sub-menu > .menu-item-has-children > a', function(e) { 341 e.preventDefault(); 342 if ($(this).hasClass('active')) { 343 $(this).removeClass('active'); 344 $(this).siblings('.sub-menu').slideUp(300); 345 } else { 346 $('.sub-menu > .menu-item-has-children > a').removeClass("active"); 347 $(this).addClass('active'); 348 $(this).siblings('.sub-menu').slideUp(200); 349 $(this).siblings('.sub-menu').slideDown(300); 350 } 351 }); 352 } 353 354 // Sticky Header 355 function ms_stickyheader() { 356 357 if ($.exists('body[data-menu="sticky"]')) { 358 359 var mainHeader = $('.main-header__layout'), 360 belowNavHeroContent = $('.sub-nav-hero'), 361 scrolling = false, 362 previousTop = 0, 363 scrollDelta = 5, 364 scrollOffset = 100; 365 366 $(window).on('scroll', function(){ 367 if( !scrolling ) { 368 scrolling = true; 369 (!window.requestAnimationFrame) 370 ? setTimeout(autoHideHeader, 300) 371 : requestAnimationFrame(autoHideHeader); 372 } 373 }); 374 function autoHideHeader() { 375 var currentTop = $(window).scrollTop(); 376 ( belowNavHeroContent.length > 0 ) 377 ? checkStickyNavigation(currentTop) : checkSimpleNavigation(currentTop); 378 previousTop = currentTop; 379 scrolling = false; 380 } 381 function checkSimpleNavigation(currentTop) { 382 if (previousTop - currentTop > scrollDelta) { 383 mainHeader.removeClass('is-hide'); 384 } else if( currentTop - previousTop > scrollDelta && currentTop > scrollOffset) { 385 mainHeader.addClass('is-hide'); 386 } 387 } 388 389 $(window).scroll(function(){ 390 if ($(this).scrollTop() > 50) { 391 $('.main-header').addClass('show-bg'); 392 } else { 393 $('.main-header').removeClass('show-bg'); 394 } 395 396 }); 397 398 } 399 400 } 401 402 // Page Transition 403 function ms_page_transition() { 404 405 if ($.exists('#loaded')) { 406 407 window.onpageshow = function (event) { 408 if (event.persisted) { 409 window.location.reload(); 410 } 411 }; 412 413 window.onbeforeunload = function(){ 414 $('#loaded').css('display', 'block'); 415 gsap.to("#loaded",{ opacity:1, ease: "power4.inOut", duration:.3 });
416 }; 417 418 function ms_page_loaded() { 419 $('#loaded').css('display', 'none'); 420 $('body').attr('onunload',''); 421 } 422 gsap.fromTo("#loaded",{opacity: 1}, {opacity: 0, ease: Power1.easeOut, onComplete:ms_page_loaded, duration: 1 }); 423 424 } 425 426 } 427 428 // Portfolio Buttons 429 function ms_load_more_btn($scope) { 430 431 var pageNum = parseInt(infinity_load.startPage) + 1, 432 max = parseInt(infinity_load.maxPages), 433 el = $scope.find('.portfolio_wrap'), 434 id = el.attr('id'), 435 container = el.find('.ms-masonry-gallery'), 436 container_g = el.find('.portfolio-feed'), 437 contgrid = el.find('.grid-content'); 438 439 // Filter 440 el.on( 'click', '.filter-nav__item:not(.active)', function(e) { 441 pageNum = parseInt(infinity_load.startPage) + 1; 442 e.preventDefault(); 443 444 var $p_item = container.find('.grid-item-p'), 445 $pg_item = container_g.find('.grid-item-p'), 446 button = el.find('.ajax-area'), 447 filterValue = $(this).attr('data-filter'), 448 url = window.location.href, 449 url = url + '?category=' + filterValue, 450 preloader = el.find('.load_filter').addClass('show'); 451 452 button.hide(300).delay(300).queue(function(){$(this).remove();}); 453 el.find('.filter-nav__item').removeClass('active'); 454 $(this).addClass('active'); 455 el.find('.filtr-btn li .subnav__link').attr('aria-current', 'none'); 456 $(this).find('.subnav__link').attr('aria-current', 'page'); 457 el.find('.filtr-btn li').css({'pointer-events' : 'none'}); 458 $p_item.css({'pointer-events' : 'none'}); 459 460 if ($.exists(contgrid)) { 461 gsap.to( $p_item ,{opacity:.3, ease: "power2.inOut", duration:.5 }); 462 } else { 463 gsap.to( $pg_item ,{opacity:.3, ease: "power2.inOut", duration:.5 }); 464 } 465 466 $.ajax({
467 type: 'GET', 468 url: url, 469 dataType: 'html', 470 success: function(data) { 471 var max = parseInt(infinity_load.maxPages), 472 item = $(data), 473 items = item.find('#' + id +' .grid-item-p'), 474 button = item.find('#' + id +' .ajax-area'); 475 476 setTimeout(function(){ 477 container.imagesLoaded( function() { 478 $p_item.css({'pointer-events' : 'auto'}); 479 preloader.removeClass('show'); 480 // If Grid layout = masonry 481 if ($.exists(contgrid)) { 482 container.imagesLoaded( function() { 483 container.isotope({ 484 itemSelector: '.grid-item-p', 485 percentPosition: true, 486 masonry: { 487 columnWidth: '.grid-sizer' 488 } 489 }); 490 }); 491 if(items.length > 0) { 492 container.append(items).isotope( 'appended', items ); 493 } 494 container.isotope('reloadItems').isotope('remove', $p_item); 495 // If Grid layout = simple grid 496 } else { 497 container_g.imagesLoaded( function() { 498 container_g.find('.grid-item-p').remove(); 499 container_g.append(items); 500 }); 501 } 502 el.append(button); 503 el.find('.filtr-btn span').removeClass('loaded'); 504 el.find('.filtr-btn li').css({'pointer-events' : 'auto'}); 505 }); 506 ms_footer_effect(); 507 }, 2000); 508 } 509 }); 510 511 }); 512 513 // Load Button 514 el.on('click', '.btn-load-more', function(event){ 515 516 var nextLink = infinity_load.nextLink; 517 nextLink = nextLink.replace(/\/page\/[0-9]?/,'/page/'+ pageNum); 518 519 event.preventDefault(); 520 var posts_container = el.find('.ms-masonry-gallery'), 521 button = $(this), 522 filterValue = el.find('.filtr-btn li.active').attr('data-filter'); 523 if (filterValue === undefined || filterValue === '') { 524 filterValue = ''; 525 } 526 527 $(this).toggleClass('loading'); 528 $('.md-content-loader').addClass('active'); 529 var max = el.find('.ajax-area').attr('data-max'); 530 531 button.css({'pointer-events' : 'none'}); 532 533 pageNum++; 534 $.ajax({
535 type: 'POST', 536 url: nextLink + '?category=' + filterValue, 537 dataType: 'html', 538 success: function(data) { 539 540 var item = $(data), 541 val = item.find('#' + id +' .grid-item-p'); 542 543 if ($.exists(contgrid)) { 544 var $container = el.find('.ms-masonry-gallery').isotope(); 545 } else { 546 var $container = el.find('.portfolio-feed'); 547 } 548 549 nextLink = nextLink.replace(/\/page\/[0-9]?/,'/page/'+ pageNum); 550 551 if(val.length > 0) { 552 553 setTimeout(function(){ 554 $('.md-content-loader').removeClass('active'); 555 button.find('.ajax-area'); 556 button.toggleClass('loading'); 557 button.css({'pointer-events' : 'auto'}); 558 container.imagesLoaded( function() { 559 if ($.exists(contgrid)) { 560 $container.append(val).isotope( 'appended', val ); 561 } else { 562 $container.append(val); 563 } 564 }); 565 566 if(pageNum <= max) { 567 } else { 568 button.addClass('no-works'); 569 button.css({'pointer-events' : 'none'}); 570 } 571 ms_footer_effect(); 572 }, 1500); 573 } 574 575 } 576 }); 577 }); 578 579 } 580 581 // Portfolio Buttons ( List ) 582 function ms_load_more_btn_list($scope) { 583 584 if ($.exists('.portfolio-feed.ms-p--l')) { 585 var pageNum = parseInt(infinity_load.startPage) + 1, 586 el = $scope.find('.portfolio-feed.ms-p--l'), 587 parent_id = el.parent().attr('id'), 588 el = $scope.find('#' + parent_id); 589 590 // Filter 591 el.on( 'click', '.filter-nav__item:not(.active)', function(e) { 592 pageNum = parseInt(infinity_load.startPage) + 1; 593 e.preventDefault(); 594 595 var container = el.find('.grid-item-p__list'), 596 text_item = container.find('.ms-p-list__item'), 597 button = el.find('.ajax-area--list'), 598 filterValue = $(this).attr('data-filter'), 599 preloader = el.find('.load_filter').addClass('show'), 600 url = window.location.href; 601 if (url.indexOf("#") > 0) { 602 var clean_url = url.substring(0, url.indexOf("#")); 603 window.history.replaceState({}, document.title, clean_url); 604 } 605 var t_url = url + '?category=' + filterValue; 606 607 gsap.to( text_item ,{opacity:.3, ease: "power2.inOut", duration:.3 }); 608 609 button.hide(300).delay(300).queue(function(){$(this).remove();}); 610 el.find('.filter-nav__item').removeClass('active'); 611 $(this).addClass('active'); 612 el.find('.filtr-btn li .subnav__link').attr('aria-current', 'none'); 613 $(this).find('.subnav__link').attr('aria-current', 'page'); 614 el.find('.filtr-btn li').css({'pointer-events' : 'none'}); 615 $(text_item).css({'pointer-events' : 'none'}); 616 617 $.ajax({
618 type: 'GET', 619 url: t_url, 620 dataType: 'html', 621 success: function(data) { 622 623 var max = parseInt(infinity_load.maxPages), 624 item = $(data), 625 text_items = item.find('#' + parent_id +' .ms-p-list__item'), 626 button = item.find('#' + parent_id +' .ajax-area--list'); 627 setTimeout(function(){ 628 container.imagesLoaded( function() { 629 el.find('.ms-p-list__item').remove(); 630 $(text_item).css({'pointer-events' : 'auto'}); 631 preloader.removeClass('show'); 632 $(container).find('.ms-p-list').append(text_items); 633 el.append(button); 634 el.find('.filtr-btn span').removeClass('loaded'); 635 el.find('.filtr-btn li').css({'pointer-events' : 'auto'}); 636 }); 637 ms_footer_effect(); 638 }, 2000); 639 } 640 }); 641 642 }); 643 644 // Load Button 645 el.on('click', '.btn-load-more', function(event){ 646 event.preventDefault(); 647 648 var nextLink = infinity_load.nextLink, 649 nextLink = nextLink.replace(/\/page\/[0-9]?/,'/page/'+ pageNum), 650 id = el.attr('id'), 651 button = $(this), 652 filterValue = el.find('.filtr-btn li.active').attr('data-filter'); 653 if (filterValue === undefined || filterValue === '') { 654 filterValue = ''; 655 } 656 657 var max = el.find('.ajax-area--list').attr('data-max'); 658 659 button.css({'pointer-events' : 'none'}); 660 661 pageNum++; 662 $.ajax({
663 type: 'POST', 664 url: nextLink + '?category=' + filterValue, 665 dataType: 'html', 666 success: function(data) { 667 var item = $(data), 668 text_items = item.find('#' + id +' .ms-p-list__item'), 669 container = el.find('.ms-p-list'); 670 button.toggleClass('loading'); 671 672 if(text_items.length > 0) { 673 setTimeout(function(){ 674 $('.md-content-loader').removeClass('active'); 675 button.find('.ajax-area--list'); 676 button.css({'pointer-events' : 'auto'}); 677 container.append(text_items); 678 if(pageNum <= max) { 679 } else { 680 button.addClass('no-works'); 681 button.css({'pointer-events' : 'none'}); 682 } 683 ms_footer_effect(); 684 }, 1500); 685 } 686 687 } 688 }); 689 }); 690 } 691 692 } 693 694 // Google Map 695 function ms_initMap($scope) { 696 697 var googleMap = $scope.find('.ms-gmap--wrapper'), 698 map_lat = googleMap.data('map-lat'), 699 map_lng = googleMap.data('map-lng'), 700 map_zoom = googleMap.data('map-zoom'), 701 map_gesture_handling = googleMap.data('map-gesture-handling'), 702 map_zoom_control = googleMap.data('map-zoom-control') ? true : false, 703 map_zoom_control_position = googleMap.data('map-zoom-control-position'), 704 map_default_ui = googleMap.data('map-default-ui') ? false : true, 705 map_type = googleMap.data('map-type'), 706 map_type_control = googleMap.data('map-type-control') ? true : false, 707 map_type_control_style = googleMap.data('map-type-control-style'), 708 map_type_control_position = googleMap.data('map-type-control-position'), 709 map_streetview_control = googleMap.data('map-streetview-control') ? true : false, 710 map_streetview_position = googleMap.data('map-streetview-position'), 711 map_info_window_width = googleMap.data('map-info-window-width'), 712 map_locations = googleMap.data('map-locations'), 713 map_styles = googleMap.data('map-style') || '', 714 infowindow, 715 map; 716 717 function initMap() { 718 719 var myLatLng = { 720 lat: parseFloat(map_lat), 721 lng: parseFloat(map_lng) 722 }; 723 724 if (typeof google === 'undefined') { 725 return; 726 } 727 728 var map = new google.maps.Map(googleMap[0], { 729 center: myLatLng, 730 zoom: map_zoom, 731 disableDefaultUI: map_default_ui, 732 zoomControl: map_zoom_control, 733 zoomControlOptions: { 734 position: google.maps.ControlPosition[map_zoom_control_position] 735 }, 736 mapTypeId: map_type, 737 mapTypeControl: map_type_control, 738 mapTypeControlOptions: { 739 style: google.maps.MapTypeControlStyle[map_type_control_style], 740 position: google.maps.ControlPosition[map_type_control_position] 741 }, 742 streetViewControl: map_streetview_control, 743 streetViewControlOptions: { 744 position: google.maps.ControlPosition[map_streetview_position] 745 }, 746 styles: map_styles, 747 gestureHandling: map_gesture_handling, 748 }); 749 750 $.each(map_locations, function (index, googleMapement, content) { 751 752 var content = '\ 753 <div class="ms-gm--wrap">\ 754 <h6>' + googleMapement.title + '</h6>\ 755 <div>' + googleMapement.text + '</div>\ 756 </div>'; 757 758 var icon = ''; 759 760 if (googleMapement.pin_icon !== '') { 761 if (googleMapement.pin_icon_custom) { 762 icon = googleMapement.pin_icon_custom; 763 } else { 764 icon = ''; 765 } 766 } 767 768 var marker = new google.maps.Marker({ 769 map: map, 770 position: new google.maps.LatLng(parseFloat(googleMapement.lat), parseFloat(googleMapement.lng)), 771 animation: google.maps.Animation.DROP, 772 icon: icon, 773 }); 774 775 if (googleMapement.title !== '' && googleMapement.text !== '') { 776 addInfoWindow(marker, content); 777 } 778 779 google.maps.event.addListener(marker, 'click', toggleBounce); 780 781 function toggleBounce() { 782 if (marker.getAnimation() != null) { 783 marker.setAnimation(null); 784 } else { 785 marker.setAnimation(google.maps.Animation.BOUNCE); 786 } 787 } 788 789 }); 790 } 791 792 function addInfoWindow(marker, content) { 793 google.maps.event.addListener(marker, 'click', function () { 794 if (!infowindow) { 795 infowindow = new google.maps.InfoWindow({ 796 maxWidth: map_info_window_width 797 }); 798 } 799 infowindow.setContent(content); 800 infowindow.open(map, marker); 801 }); 802 } 803 804 initMap();
805 } 806 807 // Isotope 808 function ms_isotope_card_grid($scope) { 809 810 var grid = $scope.find('.grid-content'); 811 // init Isotope 812 grid.imagesLoaded(function () { grid.isotope(); }); 813 } 814 815 // Masonry Gallery 816 function ms_masonry_gallery($scope) { 817 818 var grid = $scope.find('.ms-masonry-gallery'); 819 820 grid.imagesLoaded(function () { grid.isotope(); }); 821 822 var el_2 = $scope.find('.blockgallery.h_s2').find('.mfp-img img'); 823 824 $(el_2).on('mouseenter', function () { 825 $(el_2).css('opacity', '0.5'); 826 }); 827 828 $(el_2).on('mouseleave', function () { 829 $(el_2).css('opacity', '1'); 830 }); 831 832 } 833 834 // Parallax Hero 835 function ms_parallax_hero($scope) { 836 var el = $scope.find('.ms-parallax'), 837 video = el.find('.jarallax-img').attr('data-jarallax-video'); 838 el.jarallax({ videoSrc: video }); 839 } 840 841 // Parallax Hero Text BG 842 function ms_parallax_hero_text($scope) { 843 var item = $scope.find('.ms-hero--parallax'); 844 $(item).on('mouseenter', function () { 845 var item_inner = $(this).children('.ms-hero--bg_text').find('h2'); 846 $(this).on('mousemove', function( e ) { 847 var offset = $(this).offset(); 848 const x = e.pageX - offset.left; 849 $(item_inner).css( '--x', x / 3 + 'px' ); 850 }); 851 }); 852 } 853 854 // Swiper Slider Options 855 function ms_full_slider($scope) { 856 857 var el = $scope.find('.ms-slider'), 858 effect = el.attr('data-effect'), 859 direction = el.attr('data-direction'), 860 slides = el.attr('data-spv'), 861 slides_t = el.attr('data-spv-t'), 862 slides_m = el.attr('data-spv-m'), 863 speed = el.attr('data-speed'), 864 space = el.attr('data-space'), 865 space_t = el.attr('data-space-t'), 866 space_m = el.attr('data-space-m'), 867 loop = ( 'on' === el.attr('data-loop') ) ? true : false, 868 autoplay = ( 'on' === el.attr('data-autoplay') ) ? true : false, 869 centered = ( 'on' === el.attr('data-centered') ) ? true : false, 870 wheel = ( 'on' === el.attr('data-mousewheel') ) ? true : false, 871 st = ( 'on' === el.attr('data-simulatetouch') ) ? true : false, 872 gc = ( 'on' === el.attr('data-grabcursor') ) ? true : false, 873 pbo = ( 'vertical' === el.attr('data-direction') ) ? true : false; 874 875 var swiper = new Swiper(el.get(0), { 876 slidesPerView: slides, 877 parallax: true, 878 spaceBetween: eval(space), 879 loop: loop, 880 loopFillGroupWithBlank: true, 881 autoplay: autoplay, 882 centeredSlides: centered, 883 effect: effect, 884 direction: direction, 885 speed: eval(speed), 886 mousewheel: wheel, 887 grabCursor: gc, 888 simulateTouch: st, 889 scrollbar: 'true', 890 navigation: { 891 nextEl: '.ms-nav--next', 892 prevEl: '.ms-nav--prev', 893 }, 894 pagination: { 895 el: '.swiper-pagination', 896 type: 'progressbar', 897 progressbarOpposite: pbo, 898 }, 899 breakpoints: { 900 320: { 901 slidesPerView: slides_m, 902 spaceBetween: eval(space_m) 903 }, 904 500: { 905 slidesPerView: slides_t, 906 spaceBetween: eval(space_t) 907 }, 908 1024: { 909 slidesPerView: slides, 910 spaceBetween: eval(space) 911 } 912 }, 913 }); 914 915 var counter = $('.ms-slider--count'), 916 total = $('.ms-slider--count__total'), 917 totalSlides = $('.swiper-slide:not(.swiper-slide-duplicate)').length, 918 currentCount = '01'; 919 counter.append( currentCount ); 920 921 if ( totalSlides < '10' ) { 922 totalSlides = '0' + totalSlides; 923 } 924 925 total.append(totalSlides ); 926 927 swiper.on('transitionStart', function () { 928 var index = this.realIndex + 1, 929 $current = $(".swiper-slide").eq(index); 930 if ( index < '10' ) { 931 index = '0' + index; 932 } 933 counter.html(index); 934 });
935 936 if ($.exists('.swiper-wrapper.ms-ticker')) { 937 swiper.params.autoplay.delay = '0'; 938 } else { 939 swiper.on('slideChangeTransitionEnd', function () { 940 swiper.slideToLoop(swiper.realIndex, 0, false); 941 }); 942 } 943 944 945 } 946 947 // Carousel Showcase 948 function ms_carousel_showcase($scope) { 949 950 function ms_carousel_bg() { 951 var active_bg = el.find('.swiper-slide-active .ms-p-img > img').attr('src'); 952 $('.ms-carousel--bg').css('background-image', 'url(' + active_bg + ')'); 953 } 954 955 var el = $scope.find('.ms-carousel-showcase'), 956 swiper_container = '.' + el.attr('class'), 957 swiper = new Swiper(swiper_container, { 958 slidesPerView: 'auto', 959 centeredSlides: true, 960 spaceBetween: '10%', 961 initialSlide: 0, 962 autoHeight: false, 963 centeredSlidesBounds: true, 964 loop: true, 965 speed: 1000, 966 mousewheel: true, 967 pagination: { 968 el: ".swiper-pagination", 969 clickable: true, 970 }, 971 breakpoints: { 972 320: { 973 slidesPerView: 1, 974 spaceBetween: '10%' 975 }, 976 1024: { 977 slidesPerView: 'auto', 978 spaceBetween: '10%' 979 } 980 }, 981 }); 982 983 } 984 985 // Video Button 986 function ms_video_button($scope) { 987 988 var el = $scope.find('.ms-vb').find('.ms-vb--src'), 989 autoplay = el.attr('data-autoplay'), 990 type = el.attr('data-video'), 991 loop = el.attr('data-loop'), 992 controls = el.attr('data-controls'), 993 muted = el.attr('data-muted'); 994 if ( type === 'youtube' ) { 995 var start = el.attr('data-start'), 996 end = el.attr('data-end'); 997 } 998 999 el.magnificPopup({ 1000 type: 'iframe', 1001 iframe: { 1002 patterns: { 1003 youtube: { 1004 index: 'youtube.com/', 1005 id: function(url) { 1006 var m = url.match(/[\\?\\&]v=([^\\?\\&]+)/); 1007 if ( !m || !m[1] ) return null; 1008 return m[1];
1009 }, 1010 src: '//www.youtube.com/embed/%id%?autoplay=' + autoplay + '&controls=' + controls + '&mute=' + muted + '&start=' + start + '&end=' + end 1011 }, 1012 vimeo: { 1013 index: 'vimeo.com/', 1014 id: function(url) { 1015 var m = url.match(/(https?:\/\/)?(www.)?(player.)?vimeo.com\/([a-z]*\/)*([0-9]{6,11})[?]?.*/); 1016 if ( !m || !m[5] ) return null; 1017 return m[5]; 1018 }, 1019 src: '//player.vimeo.com/video/%id%?autoplay=' + autoplay + '&loop=' + loop + '&controls=' + controls + '&muted=' + muted 1020 } 1021 }, 1022 markup: '<div class="mfp-iframe-scaler">'+ 1023 '<div class="mfp-close"></div>'+ 1024 '<iframe class="mfp-iframe" frameborder="0" allowfullscreen></iframe>'+ 1025 '<div class="mfp-title">Some caption</div>'+ 1026 '</div>' 1027 }, 1028 callbacks: { 1029 markupParse: function(template, values, item) { 1030 values.title = item.el.attr('data-caption'); 1031 } 1032 }, 1033 }); 1034 1035 } 1036 1037 // Justified Gallery 1038 function ms_lightbox($scope) { 1039 1040 var el = $scope.find('.blockgallery'), 1041 justified = $scope.find('.justified-gallery'), 1042 m = justified.data('margins'), 1043 h = justified.data('row-height'); 1044 1045 justified.justifiedGallery({ 1046 rowHeight : h, 1047 margins : m, 1048 captions : false, 1049 border: 0, 1050 lastRow : 'nojustify', 1051 }); 1052 1053 el.magnificPopup({ 1054 delegate: '.mfp-img', 1055 mainClass: 'mfp-fade', 1056 tClose: 'Fechar (Esc)', 1057 tLoading: '', 1058 type: 'image', 1059 image: { 1060 titleSrc: function(item) { 1061 return item.el.attr("title");; 1062 } 1063 }, 1064 gallery: { 1065 enabled:true, 1066 preload: [0,2], 1067 }, 1068 1069 mainClass: 'mfp-zoom-in', 1070 removalDelay: 300, //delay removal by X to allow out-animation 1071 callbacks: { 1072 beforeOpen: function() { 1073 $('#portfolio a').each(function(){ 1074 $(this).attr('alt', $(this).find('img').attr('alt')); 1075 }); 1076 }, 1077 open: function() { 1078 //overwrite default prev + next function. Add timeout for css3 crossfade animation 1079 $.magnificPopup.instance.next = function() { 1080 var self = this; 1081 self.wrap.removeClass('mfp-image-loaded'); 1082 setTimeout(function() { $.magnificPopup.proto.next.call(self); }, 120); 1083 } 1084 $.magnificPopup.instance.prev = function() { 1085 var self = this; 1086 self.wrap.removeClass('mfp-image-loaded'); 1087 setTimeout(function() { $.magnificPopup.proto.prev.call(self); }, 120); 1088 } 1089 }, 1090 imageLoadComplete: function() { 1091 var self = this; 1092 setTimeout(function() { self.wrap.addClass('mfp-image-loaded'); }, 16); 1093 } 1094 } 1095 1096 }); 1097 } 1098 1099 // Run on initial load. 1100 msResponsiveEmbeds(); 1101 1102 // Run on resize. 1103 window.onresize = msResponsiveEmbeds; 1104 1105 // Responsive Embeds 1106 function msResponsiveEmbeds() { 1107 var proportion, parentWidth; 1108 1109 // Loop iframe elements. 1110 document.querySelectorAll( 'iframe' ).forEach( function( iframe ) { 1111 // Only continue if the iframe has a width & height defined. 1112 if ( iframe.width && iframe.height ) { 1113 // Calculate the proportion/ratio based on the width & height. 1114 proportion = parseFloat( iframe.width ) / parseFloat( iframe.height ); 1115 // Get the parent element's width. 1116 parentWidth = parseFloat( window.getComputedStyle( iframe.parentElement, null ).width.replace( 'px', '' ) ); 1117 // Set the max-width & height. 1118 iframe.style.maxWidth = '100%'; 1119 iframe.style.maxHeight = Math.round( parentWidth / proportion ).toString() + 'px'; 1120 } 1121 } ); 1122 } 1123 1124 // Page 404 1125 function ms_not_found() { 1126 if ($.exists('.ms-404-page')) { 1127 gsap.to("#headStripe", { 1128 y: 0.5, 1129 rotation: 1, 1130 yoyo: true, 1131 repeat: -1, 1132 ease: "sine.inOut", 1133 duration: 1 1134 }); 1135 gsap.to("#spaceman", { 1136 y: 0.5, 1137 rotation: 1, 1138 yoyo: true, 1139 repeat: -1, 1140 ease: "sine.inOut", 1141 duration: 1 1142 }); 1143 gsap.to("#craterSmall", { 1144 x: -3, 1145 yoyo: true, 1146 repeat: -1, 1147 duration: 1, 1148 ease: "sine.inOut" 1149 }); 1150 gsap.to("#craterBig", { 1151 x: 3, 1152 yoyo: true, 1153 repeat: -1, 1154 duration: 1, 1155 ease: "sine.inOut" 1156 }); 1157 gsap.to("#planet", { 1158 rotation: -2, 1159 yoyo: true, 1160 repeat: -1, 1161 duration: 1, 1162 ease: "sine.inOut", 1163 transformOrigin: "50% 50%" 1164 }); 1165 1166 gsap.to("#starsBig g", { 1167 rotation: "random(-30,30)", 1168 transformOrigin: "50% 50%", 1169 yoyo: true, 1170 repeat: -1, 1171 ease: "sine.inOut" 1172 }); 1173 gsap.fromTo( 1174 "#starsSmall g", 1175 { scale: 0, transformOrigin: "50% 50%" }, 1176 { scale: 1, transformOrigin: "50% 50%", yoyo: true, repeat: -1, stagger: 0.1 } 1177 ); 1178 gsap.to("#circlesSmall circle", { 1179 y: -4, 1180 yoyo: true, 1181 duration: 1, 1182 ease: "sine.inOut", 1183 repeat: -1 1184 }); 1185 gsap.to("#circlesBig circle", { 1186 y: -2, 1187 yoyo: true, 1188 duration: 1, 1189 ease: "sine.inOut", 1190 repeat: -1 1191 }); 1192 1193 gsap.set("#glassShine", { x: -68 }); 1194 1195 gsap.to("#glassShine", { 1196 x: 80, 1197 duration: 2, 1198 rotation: -30, 1199 ease: "expo.inOut", 1200 transformOrigin: "50% 50%", 1201 repeat: -1, 1202 repeatDelay: 8, 1203 delay: .1 1204 }); 1205 } 1206 } 1207 1208 // Theme Mode 1209 function ms_theme_mode() { 1210 if ($.exists('.ms_theme_mode')) { 1211 var td = $("#theme-dark"), 1212 tl = $("#theme-light"), 1213 s = $("#switcher"); 1214 $(td).on("click", function(){ 1215 $(tl).removeClass("toggler--is-active"); 1216 $(s).prop('checked', false); 1217 $(this).addClass('toggler--is-active'); 1218 $('body').attr('data-theme', 'dark'); 1219 var theme = $('body').attr('data-theme');
1220 setCookie('theme-mode', theme, {expires : 30}); 1221 }); 1222 $(tl).on("click", function(){ 1223 $(td).removeClass("toggler--is-active"); 1224 $(s).prop('checked', true); 1225 $(this).addClass('toggler--is-active'); 1226 $('body').attr('data-theme', 'light'); 1227 var theme = $('body').attr('data-theme'); 1228 setCookie('theme-mode', theme, {expires : 30}); 1229 }); 1230 $(s).on("click", function(){ 1231 $(td).toggleClass("toggler--is-active"); 1232 $(tl).toggleClass("toggler--is-active"); 1233 $('body').attr('data-theme', $('body').attr('data-theme') == 'light' ? 'dark' : 'light'); 1234 var theme = $('body').attr('data-theme'); 1235 setCookie('theme-mode', theme, {expires : 30}); 1236 }); 1237 function setCookie(cname, cvalue, exdays) { 1238 var d = new Date(); 1239 d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000)); 1240 var expires = "expires=" + d.toUTCString(); 1241 document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"; 1242 } 1243 } 1244 } 1245 1246 function ms_woo_quantity() { 1247 1248 if ($.exists('.ms-quantity')) { 1249 $('body').on('click', '.button-plus, .button-minus', function(e) { 1250 const isNegative = $(e.target).closest('.button-minus').is('.button-minus'); 1251 const input = $(e.target).closest('.ms-quantity').find('input'); 1252 if (input.is('input')) { 1253 input[0][isNegative ? 'stepDown' : 'stepUp'](); 1254 $('button[name="update_cart"]').prop('disabled', false); 1255 } 1256 }); 1257 1258 } 1259 1260 } 1261 1262 function ms_woo_category_loop() { 1263 1264 if ($.exists('.product-category')) { 1265 $('.product-category').wrapAll('<div class="ms-woocommerce-product-category"></div>'); 1266 } 1267 1268 } 1269 1270})(jQuery); 1271 1272// Utill 1273( function( window, factory ) { 1274 // universal module definition 1275 /* jshint strict: false */ /*globals define, module, require */ 1276 if ( typeof define === 'function' && define.amd ) { 1277 // AMD 1278 define( [ 1279 'isotope-layout/js/layout-mode' 1280 ], 1281 factory ); 1282 } else if ( typeof exports === 'object' ) { 1283 // CommonJS 1284 module.exports = factory( 1285 require('isotope-layout/js/layout-mode') 1286 ); 1287 } else { 1288 // browser global 1289 factory( 1290 window.Isotope.LayoutMode 1291 ); 1292 } 1293 1294 }( window, function factory( LayoutMode ) { 1295 'use strict'; 1296 1297 var CellsByRow = LayoutMode.create( 'cellsByRow' ); 1298 var proto = CellsByRow.prototype; 1299 1300 proto._resetLayout = function() { 1301 // reset properties 1302 this.itemIndex = 0; 1303 // measurements 1304 this.getColumnWidth(); 1305 this.getRowHeight(); 1306 // set cols 1307 this.cols = Math.floor( this.isotope.size.innerWidth / this.columnWidth ); 1308 this.cols = Math.max( this.cols, 1 ); 1309 }; 1310 1311 proto._getItemLayoutPosition = function( item ) { 1312 item.getSize(); 1313 var col = this.itemIndex % this.cols; 1314 var row = Math.floor( this.itemIndex / this.cols ); 1315 // center item within cell 1316 var x = ( col + 0.5 ) * this.columnWidth - item.size.outerWidth / 2; 1317 var y = ( row + 0.5 ) * this.rowHeight - item.size.outerHeight / 2; 1318 this.itemIndex++; 1319 return { x: x, y: y }; 1320 }; 1321 1322 proto._getContainerSize = function() { 1323 return { 1324 height: Math.ceil( this.itemIndex / this.cols ) * this.rowHeight 1325 }; 1326 }; 1327 1328 return CellsByRow; 1329 1330 })); 1331 1332 // Utility function 1333 function Util () {}; 1334 1335// class manipulation functions 1336Util.hasClass = function(el, className) { 1337 if (el.classList) return el.classList.contains(className); 1338 else return !!el.className.match(new RegExp('(\\s|^)' + className + '(\\s|$)')); 1339}; 1340 1341Util.addClass = function(el, className) { 1342 var classList = className.split(' '); 1343 if (el.classList) el.classList.add(classList[0]); 1344 else if (!Util.hasClass(el, classList[0])) el.className += " " + classList[0]; 1345 if (classList.length > 1) Util.addClass(el, classList.slice(1).join(' '));
1346}; 1347 1348Util.removeClass = function(el, className) { 1349 var classList = className.split(' '); 1350 if (el.classList) el.classList.remove(classList[0]); 1351 else if(Util.hasClass(el, classList[0])) { 1352 var reg = new RegExp('(\\s|^)' + classList[0] + '(\\s|$)'); 1353 el.className=el.className.replace(reg, ' '); 1354 } 1355 if (classList.length > 1) Util.removeClass(el, classList.slice(1).join(' ')); 1356 }; 1357 1358Util.toggleClass = function(el, className, bool) { 1359 if(bool) Util.addClass(el, className); 1360 else Util.removeClass(el, className); 1361 }; 1362 1363Util.setAttributes = function(el, attrs) { 1364 for(var key in attrs) { 1365 el.setAttribute(key, attrs[key]); 1366 } 1367}; 1368 1369 /* 1370 DOM manipulation 1371 */ 1372Util.getChildrenByClassName = function(el, className) { 1373 var children = el.children, 1374 childrenByClass = []; 1375 for (var i = 0; i < el.children.length; i++) { 1376 if (Util.hasClass(el.children[i], className)) childrenByClass.push(el.children[i]); 1377 } 1378 return childrenByClass; 1379}; 1380 1381 Util.is = function(elem, selector) { 1382 if(selector.nodeType){ 1383 return elem === selector; 1384 } 1385 1386 var qa = (typeof(selector) === 'string' ? document.querySelectorAll(selector) : selector), 1387 length = qa.length, 1388 returnArr = []; 1389 1390 while(length--){ 1391 if(qa[length] === elem){ 1392 return true; 1393 } 1394 } 1395 1396 return false; 1397 }; 1398 1399 /* 1400 Animate height of an element 1401 */ 1402 Util.setHeight = function(start, to, element, duration, cb) { 1403 var change = to - start, 1404 currentTime = null; 1405 1406 var animateHeight = function(timestamp){ 1407 if (!currentTime) currentTime = timestamp; 1408 var progress = timestamp - currentTime; 1409 var val = parseInt((progress/duration)*change + start); 1410 element.style.height = val+"px"; 1411 if(progress < duration) { 1412 window.requestAnimationFrame(animateHeight); 1413 } else { 1414 cb(); 1415 } 1416 }; 1417 1418 //set the height of the element before starting animation -> fix bug on Safari 1419 element.style.height = start+"px"; 1420 window.requestAnimationFrame(animateHeight); 1421 }; 1422 1423// Portfolio filter-navigation 1424(function() { 1425 var FilterNav = function(element) { 1426 this.element = element; 1427 this.wrapper = this.element.getElementsByClassName('js-filter-nav__wrapper')[0]; 1428 this.nav = this.element.getElementsByClassName('js-filter-nav__nav')[0]; 1429 this.list = this.nav.getElementsByClassName('js-filter-nav__list')[0]; 1430 this.control = this.element.getElementsByClassName('js-filter-nav__control')[0]; 1431 this.modalClose = this.element.getElementsByClassName('js-filter-nav__close-btn')[0]; 1432 this.placeholder = this.element.getElementsByClassName('js-filter-nav__placeholder')[0]; 1433 this.marker = this.element.getElementsByClassName('js-filter-nav__marker'); 1434 this.layout = 'expanded'; 1435 initFilterNav(this); 1436 }; 1437 1438 function initFilterNav(element) { 1439 checkLayout(element); // init layout 1440 if(element.layout == 'expanded') placeMarker(element); 1441 element.element.addEventListener('update-layout', function(event){ // on resize - modify layout 1442 checkLayout(element); 1443 }); 1444 1445 // update selected item 1446 element.wrapper.addEventListener('click', function(event){ 1447 var newItem = event.target.closest('.js-filter-nav__btn'); 1448 if(newItem) { 1449 updateCurrentItem(element, newItem); 1450 return; 1451 } 1452 // close modal list - mobile version only 1453 if(Util.hasClass(event.target, 'js-filter-nav__wrapper') || event.target.closest('.js-filter-nav__close-btn')) toggleModalList(element, false); 1454 }); 1455 1456 // open modal list - mobile version only 1457 element.control.addEventListener('click', function(event){ 1458 toggleModalList(element, true); 1459 }); 1460 1461 // listen for key events 1462 window.addEventListener('keyup', function(event){ 1463 // listen for esc key 1464 if( (event.keyCode && event.keyCode == 27) || (event.key && event.key.toLowerCase() == 'escape' )) { 1465 // close navigation on mobile if open 1466 if(element.control.getAttribute('aria-expanded') == 'true' && isVisible(element.control)) { 1467 toggleModalList(element, false); 1468 } 1469 } 1470 // listen for tab key 1471 if( (event.keyCode && event.keyCode == 9) || (event.key && event.key.toLowerCase() == 'tab' )) { 1472 // close navigation on mobile if open when nav loses focus 1473 if(element.control.getAttribute('aria-expanded') == 'true' && isVisible(element.control) && !document.activeElement.closest('.js-filter-nav__wrapper')) toggleModalList(element, false); 1474 } 1475 }); 1476 }; 1477 1478 function updateCurrentItem(element, btn) { 1479 if(btn.getAttribute('aria-current') == 'true') { 1480 toggleModalList(element, false); 1481 return; 1482 } 1483 var activeBtn = element.wrapper.querySelector('[aria-current]'); 1484 if(activeBtn) activeBtn.removeAttribute('aria-current'); 1485 btn.setAttribute('aria-current', 'true'); 1486 // update trigger label on selection (visible on mobile only) 1487 element.placeholder.textContent = btn.textContent; 1488 toggleModalList(element, false); 1489 if(element.layout == 'expanded') placeMarker(element); 1490 }; 1491 1492 function toggleModalList(element, bool) { 1493 element.control.setAttribute('aria-expanded', bool); 1494 Util.toggleClass(element.wrapper, 'filter-nav__wrapper--is-visible', bool); 1495 if(bool) { 1496 element.nav.querySelectorAll('[href], button:not([disabled])')[0].focus(); 1497 } else if(isVisible(element.control)) { 1498 element.control.focus(); 1499 } 1500 }; 1501 1502 function isVisible(element) { 1503 return (element.offsetWidth || element.offsetHeight || element.getClientRects().length); 1504 }; 1505 1506 function checkLayout(element) { 1507 if(element.layout == 'expanded' && switchToCollapsed(element)) { // check if there's enough space 1508 element.layout = 'collapsed'; 1509 Util.removeClass(element.element, 'filter-nav--expanded'); 1510 Util.addClass(element.element, 'filter-nav--collapsed'); 1511 Util.removeClass(element.modalClose, 'is-hidden'); 1512 Util.removeClass(element.control, 'is-hidden'); 1513 } else if(element.layout == 'collapsed' && switchToExpanded(element)) { 1514 element.layout = 'expanded'; 1515 Util.addClass(element.element, 'filter-nav--expanded'); 1516 Util.removeClass(element.element, 'filter-nav--collapsed'); 1517 Util.addClass(element.modalClose, 'is-hidden'); 1518 Util.addClass(element.control, 'is-hidden'); 1519 } 1520 // place background element 1521 if(element.layout == 'expanded') placeMarker(element); 1522 }; 1523 1524 function switchToCollapsed(element) { 1525 return element.nav.scrollWidth > element.nav.offsetWidth; 1526 }; 1527 1528 function switchToExpanded(element) { 1529 element.element.style.visibility = 'hidden'; 1530 Util.addClass(element.element, 'filter-nav--expanded'); 1531 Util.removeClass(element.element, 'filter-nav--collapsed'); 1532 var switchLayout = element.nav.scrollWidth <= element.nav.offsetWidth; 1533 Util.removeClass(element.element, 'filter-nav--expanded'); 1534 Util.addClass(element.element, 'filter-nav--collapsed'); 1535 element.element.style.visibility = 'visible'; 1536 return switchLayout; 1537 }; 1538 1539 function placeMarker(element) { 1540 var activeElement = element.wrapper.querySelector('.js-filter-nav__btn[aria-current="true"]'); 1541 if(element.marker.length == 0 || !activeElement ) return; 1542 element.marker[0].style.width = activeElement.offsetWidth+'px'; 1543 element.marker[0].style.transform = 'translateX('+(activeElement.getBoundingClientRect().left - element.list.getBoundingClientRect().left)+'px)'; 1544 }; 1545 1546 var filterNav = document.getElementsByClassName('js-filter-nav'); 1547 if(filterNav.length > 0) { 1548 var filterNavArray = []; 1549 for(var i = 0; i < filterNav.length; i++) { 1550 filterNavArray.push(new FilterNav(filterNav[i])); 1551 } 1552 1553 var resizingId = false, 1554 customEvent = new CustomEvent('update-layout'); 1555 1556 window.addEventListener('resize', function() { 1557 clearTimeout(resizingId); 1558 resizingId = setTimeout(doneResizing, 100); 1559 }); 1560 1561 // wait for font to be loaded 1562 document.fonts.onloadingdone = function (fontFaceSetEvent) { 1563 doneResizing(); 1564 }; 1565 1566 function doneResizing() { 1567 for( var i = 0; i < filterNavArray.length; i++) { 1568 (function(i){filterNavArray[i].element.dispatchEvent(customEvent)})(i); 1569 }; 1570 }; 1571 } 1572 1573}()); 1574 1575/* 1576 Smooth Scroll 1577*/ 1578//Animation curves 1579Math.easeInOutQuad = function (t, b, c, d) { 1580 t /= d/2; 1581 if (t < 1) return c/2*t*t + b; 1582 t--; 1583 return -c/2 * (t*(t-2) - 1) + b; 1584}; 1585Util.scrollTo = function(final, duration, cb) { 1586 var start = window.scrollY || document.documentElement.scrollTop, 1587 currentTime = null; 1588 1589 var animateScroll = function(timestamp){ 1590 if (!currentTime) currentTime = timestamp; 1591 var progress = timestamp - currentTime; 1592 if(progress > duration) progress = duration; 1593 var val = Math.easeInOutQuad(progress, start, final-start, duration); 1594 window.scrollTo(0, val); 1595 if(progress < duration) { 1596 window.requestAnimationFrame(animateScroll); 1597 } else { 1598 cb && cb(); 1599 } 1600 }; 1601 1602 window.requestAnimationFrame(animateScroll); 1603}; 1604 1605// Back to Top 1606(function() { 1607 var backTop = document.getElementsByClassName('js-back-to-top')[0]; 1608 if( backTop ) { 1609 var scrollDuration = parseInt(backTop.getAttribute('data-duration')) || 0, //scroll to top duration 1610 scrollOffset = parseInt(backTop.getAttribute('data-offset')) || 10, //show back-to-top if scrolling > scrollOffset 1611 scrolling = false; 1612 1613 //detect click on back-to-top link 1614 backTop.addEventListener('click', function(event) { 1615 event.preventDefault(); 1616 (!window.requestAnimationFrame) ? window.scrollTo(0, 0) : Util.scrollTo(0, scrollDuration); 1617 });
1618 1619 } 1620 1621}());
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.