$(document).ready(function () { // Slider video var slideWrapper = $("#heroSlider"); function playPauseVideo(slick, control) { var currentSlide = slick.find(".slick-current"); var video = currentSlide.find("video").get(0); if (video) { if (control === "play") { video.play(); } else { video.pause(); } } } slideWrapper.on("init", function (slick) { slick = $(slick.currentTarget); setTimeout(function () { playPauseVideo(slick, "play"); }, 1000); }); slideWrapper.on("beforeChange", function (event, slick) { slick = $(slick.$slider); playPauseVideo(slick, "pause"); }); slideWrapper.on("afterChange", function (event, slick) { slick = $(slick.$slider); playPauseVideo(slick, "play"); }); flexibility(document.documentElement); $("a[href^=mailto]").css("border-bottom", "2px solid #c7cf1a").css("text-decoration", "none"); $('.subbar .navitem').on('click mouseenter', function () { $('.subbar .navitem').removeClass('active'); $(this).addClass('active'); $('.optionBar').hide(); $(`#${$(this)[0].dataset.target}`).show(); $('.jumbotron--blocks__fixed').css('top', $('.navbar').height() + 'px'); }); $('.subbar .navitem, .optionBar').on('mouseleave', function () { if ($(".subbar:hover, .optionBar:hover").length === 0) { $('.subbar .navitem').removeClass('active'); $('.optionBar').hide(); } }); $('.optionsHeader').click(function () { $('.optionsHeader').removeClass('active'); $(this).addClass('active'); $('.optionsContent').hide(); $(`#${$(this)[0].dataset.target}`).show(); }) $('.mainbar .hamburger').click(function () { $('body, html').toggleClass('no-scroll'); $('.mainbar .hamburger').toggleClass('active'); $('.subbar-mobile').toggleClass('active'); }) //if (document.querySelector('.spacer')) { // document.querySelector('.spacer').style.height = document.querySelector('.navbar').clientHeight + 'px'; //} $('[data-playvideo]').click(function (e) { e.preventDefault(); var videoFile = $(this).data('playvideo'); $('body').append('
'); }); $('body').on('click', '.slider__video', function (e) { if (e.srcElement.className === 'slider__video') { $(this).fadeOut(); } }); $('.slider--no-arrows').slick({ accessibility: false, dots: true, arrows: false }); $('.slider--technical').not('.slider--technical--owl-carousel').slick({ dots: false, arrows: true, adaptiveHeight: true }); /* ######################################################### */ var $navExtraItems = $('.nav-top__item--extra'), $navTopMain = $('.nav-top__main'), $navTopMainHeight = $navTopMain.height(); $navExtraItems.on('hover', function () { $navTopMainHeight = ($navTopMain.outerHeight() - $(this).outerHeight()) / 2; $(this).find('.hover-arrow').css('top', -$navTopMainHeight); }); /* ######################################################### */ $('.slider--engines').slick({ infinite: false, slidesToShow: 5, slidesToScroll: 1, responsive: [ { breakpoint: 1600, settings: { infinite: false, slidesToShow: 4, slidesToScroll: 1 } }, { breakpoint: 768, settings: { infinite: false, slidesToShow: 3, slidesToScroll: 1 } }, { breakpoint: 480, settings: { infinite: false, slidesToShow: 2, slidesToScroll: 1 } }, { breakpoint: 400, settings: { infinite: false, slidesToShow: 1, slidesToScroll: 1 } }] }); /* ######################################################### */ /* Open close nav-container var $navContainer = $('.nav-container'); var $navMain = $('.nav-main'); var $navLanguage = $('.nav-language'); var $navTrigger = $('[data-trigger="nav"]'); $navTrigger.on('click', function (e) { e.preventDefault(); $navTrigger.toggleClass('nav-trigger--active'); $navContainer.toggleClass('nav-container--active'); $navMain.toggleClass('nav-main--active'); $navLanguage.toggleClass('nav-language--active'); $sm_secondaryMenu.toggleClass('secondary-menu--pushed-down'); });*/ var $nav = $('.nav-top'); var $body = $('body'); var $navFixedClone = $('.nav-top').clone().addClass('nav-top--fixed').appendTo('body'); var $navMainBar = $('.nav-top__main'); var $navMoreBar = $('.nav-top__more'); var $navMoreBarState = false; var $navMoreBarHeight = $navMoreBar.height(); var $navMoreTrigger = $('.nav-top__more-trigger'); var $navMobileTrigger = $('.nav-trigger--top-nav'); var $filter2container = $('.filter--2--desktop__container'); var $filter2 = $('.filter--2--desktop__container .filter--2--desktop'); $(window).scroll(function () { if ($(window).scrollTop() > ($nav.height() + 50)) { $navFixedClone.addClass('nav-top--fixed-down'); if ($filter2container.hasClass('filter--2--desktop__fill-space')) { $filter2container.css('height', '58px'); $filter2container.css('top', $('.navbar').height()); } if ($navFixedClone.find('.filter--2--desktop').length < 1) { $navFixedClone.prepend($filter2); } } else { $navFixedClone.removeClass('nav-top--fixed-down'); $filter2container.removeClass('filter--2--desktop__container--no-content'); if ($filter2container.hasClass('filter--2--desktop__fill-space')) { $filter2container.css('height', 'initial'); $filter2container.css('top', '0px'); } if ($filter2container.find('.filter--2--desktop').length < 1) { $filter2container.prepend($navFixedClone.find('.filter--2--desktop')); } } }); $navMoreTrigger.on('click',function(e) { e.preventDefault(); if(!$navMoreBarState) { $navMoreBarHeight = $navMoreBar.height(); $navMoreBarState = true; } else { $navMoreBarHeight = 0; $navMoreBarState = false; } $navMainBar.animate({ marginTop: $navMoreBarHeight },300, function() { $navMoreTrigger.toggleClass('is-active'); }); }); $navMobileTrigger.on('click', function(e) { e.preventDefault(); $nav.toggleClass('is-active'); $body.toggleClass('nav-active'); }); /* ######################################################### */ /* Select language */ var $navLanguageSelect = $('.nav-language__select select'); var $navLanguageLabel = $('.nav-language__label'); // First Init $navLanguageLabel.html($navLanguageSelect.val()); $navLanguageSelect.change(function () { //console.log($navLanguageSelect.val()); $navLanguageLabel.html($navLanguageSelect.val()); }); /* ######################################################### */ // Lazy load helper function lazyLoadImage(el) { var $el = el.jquery ? el : $(el); var attr = $el.attr("data-src"); if (typeof attr !== "undefined" && attr !== false) { $el.attr("src", $el.data("src")).removeAttr("data-src"); } } /* ######################################################### */ /* Accordion */ $('.accordion__title').on('click', function (e) { e.preventDefault(); var section = $(this).data('linked-section'); var $parent = $(this).parents('.accordion'); var $allTitles = $parent.find('.accordion__title'); var $activeTitles = $parent.find('[data-linked-section=' + section + ']'); var $siblings = $parent.find('.accordion__section'); var $sibling = $parent.find('[data-section=' + section + ']'); $allTitles.removeClass('accordion__title--active'); $activeTitles.each(function () { $(this).addClass('accordion__title--active'); }); $siblings.removeClass('accordion__section--active'); $sibling.toggleClass('accordion__section--active'); }); /* ######################################################### */ /* Photo-switcher */ $('.photo-switcher__item a').on('click', function (e) { e.preventDefault(); //var isActive = $(this).parent().hasClass("photo-switcher__item--active"); var $ps_parent = $(this).parents('.photo-switcher'); var $ps_current = $(this).parent('.photo-switcher__item'); var $ps_currentImg = $(this).parent('.photo-switcher__item').find('.photo-switcher__image-container').first(); var $ps_items = $ps_parent.find('.photo-switcher__item'); var $ps_images = $ps_parent.find('.photo-switcher__image-container'); var $ps_caption = $(this).parent('.photo-switcher__item').find('.photo-switcher__caption').html(); // load image lazyLoadImage($('img[data-src]', $ps_currentImg)); // remove active on all items $ps_items.each(function () { $(this).removeClass('photo-switcher__item--active'); }); // remove active on all images $ps_images.each(function () { $(this).removeClass('photo-switcher__image-container--active'); $(this).removeClass('photo-switcher__image-container--non-visible'); }); //if (isActive) { // var $ps_imageSource = $(this).parent() // .find('img') // .first() // .attr('src'); // $ps_parent.find('.photo-switcher__gallery-container .photo-switcher__image img').attr('src', $ps_imageSource); // // // return; //} // set actives $ps_current.addClass('photo-switcher__item--active'); $ps_currentImg.addClass('photo-switcher__image-container--active'); if ($ps_current.parents('.photo-switcher__item')) { $ps_current.parents('.photo-switcher__item').addClass('photo-switcher__item--active'); } if ($ps_current.parent().hasClass('photo-switcher__list--sub')) { $ps_current .parent() .parent() .find('.photo-switcher__image-container:first') .addClass('photo-switcher__image-container--non-visible'); } var $ps_imageSource = $(this).parent() .find('img') .first() .attr('src'); $ps_parent.find('.photo-switcher__gallery-container .photo-switcher__image img').attr('src', $ps_imageSource); if ($ps_caption !== undefined) { $ps_parent.find('.photo-switcher__gallery-container .photo-switcher__caption').text("" + $ps_caption + ""); } }); $('.photo-switcher').each(function () { var $ps_activeImage = $(this).find('.photo-switcher__item--active').find('img').first(); //var $ps_imageSource = $ps_activeImage.attr('src'); //var $ps_caption = $(this).find('.photo-switcher__item--active').find('.photo-switcher__caption').first().html(); //if (typeof $ps_imageSource === "undefined") { // $ps_imageSource = "/assets/shared/images/pixel.png"; //} var $ps_img = $('', { src: $ps_activeImage, alt: '' }); $(this).find('.photo-switcher__gallery-container .photo-switcher__image').append($ps_img); //$(this).find('.photo-switcher__gallery-container .photo-switcher__caption').html($ps_caption); }); // LEVEL PHOTO OF PHOTOSWITCHER WITH THE SCREEN TOP $(window).on('load', function () { $('.photo-switcher').each(function () { var $ps_gallery = $(this).find('.photo-switcher__gallery-container'); var $ps_gallery_image = $(this).find('.photo-switcher__image-container--gallery .photo-switcher__image'); $(window).on('scroll', function () { var ps_gallery_posTop = $ps_gallery.offset().top /*- 70*/; //get the offset top of the element var ps_gallery_posBottom; ps_gallery_posBottom = ps_gallery_posTop + $ps_gallery_image.outerHeight() + 300; // console.log( ps_gallery_posTop - $(window).scrollTop() ); if (ps_gallery_posTop - $(window).scrollTop() < 0 && ps_gallery_posBottom - $(window).scrollTop() > 0) { $ps_gallery_image.css({ 'top': -(ps_gallery_posTop - $(window).scrollTop()) + 'px', 'margin-top': '70px' }); } else { $ps_gallery_image.css({ 'top': 0, 'margin-top': 0 }); } }); }); }); /* ######################################################### */ /* Sticky Secondary-menu */ var screenSize = window.getComputedStyle(document.querySelector('body'), ':after').getPropertyValue('content').replace(/\"/g, ''); var $stickTo = $('.nav-top'); var $sm_secondaryMenu = $('.secondary-menu.helper--hide-medium'); var $sm_secondaryMenu_clone = $sm_secondaryMenu.clone().addClass('secondary-menu--clone'); if ($sm_secondaryMenu.length > 0 && screenSize !== 'small' && screenSize !== 'medium') { $stickTo.after($sm_secondaryMenu_clone); var windowTop = window.top; var $menu_bottom = $sm_secondaryMenu.offset().top - $stickTo.outerHeight(); $(window).scroll(function () { var $menu_bottom = $sm_secondaryMenu.offset().top - $stickTo.outerHeight(); var sm_pos = getTopPos($sm_secondaryMenu); $(window).resize(function () { sm_pos = getTopPos($sm_secondaryMenu); }); if ($menu_bottom > 0 && $(window).scrollTop() > ($menu_bottom + $sm_secondaryMenu.outerHeight())) { $sm_secondaryMenu_clone.addClass('is-active').css('top', $stickTo.height()); } else { $sm_secondaryMenu_clone.removeClass('is-active').css('top', 0); } }); } /*var $sm_secondaryMenu = $('.secondary-menu.helper--hide-medium'); var $sm_secondaryMenu_clone = $sm_secondaryMenu.clone().addClass('secondary-menu--clone').appendTo('.masthead'); if ( $sm_secondaryMenu.length > 0 ) { var windowTop = window.top; var $masthead = $('.masthead__top'); var $menu_bottom = $sm_secondaryMenu.offset().top - $masthead.outerHeight(); var sm_pos = getTopPos($sm_secondaryMenu); $(window).scroll(function(){ $(window).resize(function() { sm_pos = getTopPos($sm_secondaryMenu); }); if($menu_bottom > 0 && $(window).scrollTop() > ($menu_bottom + $sm_secondaryMenu.outerHeight())) { $sm_secondaryMenu_clone .css('top',$masthead.outerHeight()) .addClass('secondary-menu--fixed'); $navTrigger.removeClass('nav-trigger--active'); $navContainer.removeClass('nav-container--active'); $navMain.removeClass('nav-main--active'); $navLanguage.removeClass('nav-language--active'); $sm_secondaryMenu.removeClass('secondary-menu--pushed-down'); $masthead.addClass('masthead__top--pulled-up'); } else { $sm_secondaryMenu_clone.removeClass('secondary-menu--fixed').css('top',0); $masthead.removeClass('masthead__top--pulled-up'); } }); }*/ function getTopPos(t) { if ($(t).length > 0) { return t.position().top; } } //function getBottomPos(t) { // if ($(t).length > 0) { // return t.position().top + t.outerHeight(true); // } //} /* ######################################################### */ /* Open/Close filter */ var $filterTrigger = $('[data-trigger="filter"]'); var $filter = $('.filter'); var $filterResults = $('.filter-results'); $filterTrigger.on('click', function (e) { e.preventDefault(); $filter.toggleClass('filter--active'); $filterResults.toggleClass('filter-results--active'); }); /* ######################################################### */ /* Update slider ranges */ var $rangeInputs = $('.filter__field--range'); $rangeInputs.each(function () { $(this).on('change', function () { var $rangeLabel = $(this).closest("fieldset").find('.range-value'); $rangeLabel.html($(this).val()); }); }); //function getRange(host, val) { // var $host = host; // var min = $host.attr('min'); // var max = $host.attr('max'); // var range = max - min; // var value = range - (max - val); // var step = 100 / range; // return (value * step); //} /* ######################################################### */ /* Custom Select */ $('.select').each(function (i) { var $select__label = $(this).find('.select__label'); var $select__input = $(this).find('.select__input'); var selectedValue = $(this).find('.select__input option:selected').text(); $select__label.html(selectedValue); $select__input.on('change', function (e) { selectedValue = $(this).find('option:selected').text(); $select__label.html(selectedValue); }); }); /* ######################################################### */ /* Open/Close popup */ var $imagePopupTrigger = $('[data-trigger="popup"]'); var $imagePopup = $('.popup.popup-images'); $imagePopupTrigger.on('click', function (e) { e.preventDefault(); $imagePopup.toggleClass('popup--active'); if ($imagePopup.data('trigger') === 'slider') { // Initialize only once to prevent javascipt error if (!$('.slider--images').hasClass('slick-initialized')) { $('.slider--images').slick({ lazyLoad: 'progressive', dots: false, arrows: true, adaptiveHeight: true, mobileFirst: true, slide: '.slider__item' }); } } }); var $videopPopupTrigger = $('[data-trigger="popup-video"]'); var $videoPopup = $('.popup.popup-video'); $videopPopupTrigger.on('click', function (e) { e.preventDefault(); if ($(e.target).hasClass('popup__close')) { $videoPopup.removeClass('popup--active'); return; } //$videoPopup.toggleClass('popup--active'); $videoPopup.addClass('popup--active'); if ($videoPopup.data('trigger') === 'popup-video') { // Initialize only once to prevent javascipt error if (!$('.slider--tabbed-video').hasClass('slick-initialized')) { $('.slider--tabbed-video').slick({ //lazyLoad: 'progressive', dots: false, arrows: false, slidesToShow: 1 }); } // Required to auto start/pause playback when popup is toggled $videoPopup.trigger('toggleChange', [$(this).is(':visible')]); $('.popup--tabbed .popup__tab-menu__item').each(function (index) { $(this).on('click', function (e) { e.preventDefault(); var screenSize = window.getComputedStyle(document.querySelector('body'), ':after').getPropertyValue('content').replace(/\"/g, ''); $('.slider--tabbed-video').slick('slickGoTo', index); $(this).siblings().removeClass('popup__tab-menu__item--active'); $(this).addClass('popup__tab-menu__item--active'); }); }); } }); var $tourPopupTrigger = $('[data-trigger="popup-tour"]'); var $tourPopup = $('.popup.popup-tour'); $tourPopupTrigger.on('click', function (e) { e.preventDefault(); $tourPopup.toggleClass('popup--active'); if ($tourPopup.data('trigger') === 'tour') { if (!$('.slider--tabbed-tour').hasClass('slick-initialized')) $('.slider--tabbed-tour').slick({ //lazyLoad: 'progressive', dots: false, arrows: false, slidesToShow: 1 }); } }); //var $packsPopupTrigger = $('[data-trigger=".popup-packs"]'); //var $packsPopup = $('.popup.popup-packs'); //$packsPopupTrigger.on('click', function (e) { // console.info("I'm here"); // e.preventDefault(); // if ($(e.target).hasClass('popup__close')) { // $packsPopup.removeClass('popup--active'); // return; // } // $packsPopup.addClass('popup--active'); //}); /* ######################################################### */ /* JUI Range slider */ $('#slider-range').slider({ range: true, min: 0, max: 500, values: [75, 300], slide: function (event, ui) { $('#amount').val("$" + ui.values[0] + " - $" + ui.values[1]); } }); $('#amount').val('$' + $('#slider-range').slider('values', 0) + ' - $' + $('#slider-range').slider('values', 1)); /* ######################################################### */ /* Route form */ var $routeFormTrigger = $('.route-form-trigger'); $routeFormTrigger.on('click', function (e) { e.preventDefault(); $(this).next('.form--route').toggleClass('form--hidden'); }); /* ######################################################### */ /* Compare button */ //moved to product-selector.js /* ######################################################### */ /* Set Same Height on Elements */ //moved to product-selector.js /* Smooth scroll */ $("a[href^='#']").click(function (e) { if (!$(this).attr('noInnerLink') === "" || $(this).attr('smoothscroll') === 'true') { let offset = 0; if ($(window).width() > 375) { offset = $('.navbar').offset().top || $('.navbar').height() + 66; } else { offset = 80; } e.preventDefault(); id = $(this).attr('href'); $('html, body').stop().animate({ scrollTop: $(id).offset().top - offset }, 2000); } }); $(document).ready(function () { $(document).on('input', '[data-keep-value]', function (e) { var value = $(this).val(); var keepValueId = $(this).attr('data-keep-value'); if ($(this).attr('data-keep-value-fixed') !== undefined) { value = parseFloat(value).toFixed($(this).attr('data-keep-value-fixed')); } $('[data-keep-value="' + keepValueId + '"]').val(value); }); /* | --------------------------- | Image counters | --------------------------- | Loop over all data-toggle items and add | an image count for all images in the toggle */ //$('[data-toggle^=".slider-"]').each(function (index) { // let slider = $(this).attr('data-toggle'); // $(this) // .find('.c_tabs-box__tab__content__item__image__container') // .append('
'); //}) //setTimeout(function () { // $('.image-count.lg').each(function (index) { // var c = $(this).attr('data-item'); // var count = $(c + ' .c_img-slider__footer__images .owl-item').length; // $(this).text(count); // }); //}, 500); }); $(document).ready(function () { $('.owl-carousel').not('.new-slider').owlCarousel({ items: 1, slideBy: 1, loop: true, touchDrag: false, mouseDrag: false, singleItem: true, autoplayHoverPause: false, autoplayTimeout: 8000, autoplay: true, animateOut: 'fadeOut' }); }); $('.owlCarousel.c_tabs-box__tabs-container').owlCarousel({ responsive: { // breakpoint from 480 up 480: { items: 3, slideBy: 2 }, // breakpoint from 768 up 1200: { items: 6, slideBy: 3 } }, loop: false, dots: false, nav: false, navContainer: $('.c_tabs-box__navigation-container') }); /* Tab Box */ for (var i = 0; i < $('[data-component="Application/Components/TabBox"]').length; i++) { el = $('[data-component="Application/Components/TabBox"]')[i]; // console.log(el); // console.log("Initialized tab"); $(el).on('click', function (e) { e.preventDefault(); var config = JSON.parse($(this).find('span[data-component-config]').html()); if (config) { // console.log(config); $(this).closest('.c_tabs-box').find('.c_tabs-box__tab-item').removeClass('active'); $(this).addClass('active'); $(this).closest('.c_tabs-box').find('.c_tabs-box__tab__content__container .c_tabs-box__tab__content').removeClass('active'); $(this).closest('.c_tabs-box').find('.c_tabs-box__tab__content__container .c_tabs-box__tab__content#' + config.contentTab).addClass('active'); } }); } /* Dropdown */ $('[data-component="Application/Components/Dropdown"]').find('.c_dropdown__trigger').on('click', function (e) { e.preventDefault(); $(this).closest('[data-component="Application/Components/Dropdown"]').toggleClass('c_dropdown--open'); }); $('[data-component="Application/Components/Dropdown"]').find('.c_dropdown__span').on('click', function (e) { e.preventDefault(); $(this).closest('[data-component="Application/Components/Dropdown"]').toggleClass('c_dropdown--open'); }); if ($('.filter__option__container').length > 0) { $('input[name="filter_type"]').on('change', function () { let checked = $('input[name="filter_type"]:checked'); // if the length of the checked items is 0 if (checked.length === 0) { // Clear the checked logic $('.filter_type_title').text('Type'); } // if the length of the checked items is 1 if (checked.length === 1) { // Show the selected item in the tab $('.filter_type_title').text( $(checked[0]) .siblings('label:first') .text() ); $('.filter_type_title') .parent() .addClass('active'); } // if the length of the checked items is > 1 if (checked.length >= 2) { // Show the count of the selected items in the tab $('.filter_type_title').text('Type - ' + checked.length); $('.filter_type_title') .parent() .addClass('active'); } }); $('[data-slider-input-field]').on('input', function () { let amount = $(this)[0].value; let type = this.dataset.sliderInputField; $('.filter_' + type + '_title').text(amount + ' - ' + type); $('.filter_' + type + '_title') .parent() .addClass('active'); $('[data-slider-input-slider="' + type + '"]').val(amount); }); $('[data-slider-input-slider]').on('change', function () { let amount = $(this)[0].value; let type = this.dataset.sliderInputSlider; $('.filter_' + type + '_title').text(amount + ' - ' + type); $('.filter_' + type + '_title') .parent() .addClass('active'); $('[data-slider-input-field="' + type + '"]').val(amount); }); } /* Card slider */ for (var j = 0; j < $('[data-component="Application/Components/CardSlider"]').length; j++) { el = $('[data-component="Application/Components/CardSlider"]')[j]; var i_length = $(el).find('.card-slider__card.limit-loop').length; var loop = i_length === 0 || i_length > 2 ? true : false; var shouldCenter = i_length === 2 ? false : true; var navContainer = $(el).find('.card-slider__arrow'); var navText = ["", ""]; if (el.dataset.slidertype === 'otherModelsInRange') { loop = false; shouldCenter = false; if (i_length <= 3 && $(window).width() > 375) { navContainer = []; navText = []; } } // 1. If the slider is for the events if (el.dataset.slidertype === 'events') { // 2. If we are not on mobile if ($(window).width() > 375) { // 3. If we have 2 or less items if (i_length < 3) { navContainer = []; navText = []; } } } $(el) .find('.card-slider__content') .owlCarousel({ items: 1, slideBy: 1, loop: true, autoWidth: true, margin: 0, center: true, navContainer: navContainer, navText: navText, responsive: { 480: { margin: 40 }, 1220: { center: shouldCenter, items: !shouldCenter ? 2 : 1, loop: loop, margin: 40, onInitialized: function () { if (!shouldCenter) { $(el) .find('.owl-stage-outer') .css('padding-left', '40px') $(el) .find('.owl-item.active') .addClass('center') } } } } }); } // window.dispatchEvent(new Event('resize')); if (navigator.userAgent.indexOf('MSIE') !== -1 || navigator.appVersion.indexOf('Trident/') > 0) { var evt = document.createEvent('UIEvents'); evt.initUIEvent('resize', true, false, window, 0); window.dispatchEvent(evt); } else { window.dispatchEvent(new Event('resize')); } /* Testimonials review capitation */ for (var k = 0; k < $('.testimonials__item__main__text').length; k++) { if ($('.testimonials__item__main__text:eq(' + k + ')').height() > 120) { $('.testimonials__item__main__text:eq(' + k + ')').addClass('testimonials__item__main__text--capitated'); $('.testimonials__item__main__text:eq(' + k + ')').closest('.testimonials__item').find('.testimonials__item__main__read-more').css('display', 'inline-flex'); $('.testimonials__item__main__text:eq(' + k + ')').closest('.testimonials__item').find('.testimonials__item__main__read-more').click(function () { $(this).closest('.testimonials__item').find('.testimonials__item__main__text').removeClass('testimonials__item__main__text--capitated'); $(this).remove(); }); } } function checkJumbotronVisibility() { var elOffset = $('.jumbotron--blocks').offset().top; var elHeight = $('.jumbotron--blocks').height(); var scrollPos = $(window)[0].pageYOffset; if (elOffset + elHeight - scrollPos < 0) { $('.jumbotron--blocks').addClass('jumbotron--blocks--invisible'); $('.jumbotron--blocks__fixed').css('top', $('.navbar').height() + 'px'); } else { $('.jumbotron--blocks').removeClass('jumbotron--blocks--invisible'); $('.jumbotron--blocks__fixed').css('top', '0px'); } } $(document).ready(function () { // $('.key--features:has(+ .call-to-action--product)').css('padding-bottom', '80px'); // $('.helper--lp:has(+ .call-to-action--product)').css('padding-bottom', '0'); // $('.helper--lp + .call-to-action--product').css('background-color', '#8bbce8'); // $('.helper--lp + .call-to-action--product .button').css('background-color', '#ea582e'); if ($('.jumbotron--blocks').length > 0) { $(window).scroll(function () { checkJumbotronVisibility(); }); checkJumbotronVisibility(); } // Init the new slider $('[data-toggle^=".slider-"]').each(function () { initslider(this.dataset.toggle, {}); }); }); if ($('.slider--technical--owl-carousel .slider__item').length > 1) { $('.slider--technical--owl-carousel').owlCarousel({ items: 1, slideBy: 1, // stagePadding: 20, // margin: 10, touchDrag: true, mouseDrag: true, loop: true, // autoWidth: true, center: true, navContainer: $('.slider--technical--owl-carousel .slider__item__image-container .slider--technical__arrow'), navText: ["", ""] }); } $(document).ready(function () { $('[data-toggle]').click(function (e) { var slideIdx, owl; slideIdx = $(this).find('.c_tabs-box__tab__content__item__image:first-of-type').data('slide'); if (slideIdx !== undefined) { owl = $('.owl-carousel'); owl.trigger('to.owl.carousel', slideIdx); } else { slideIdx = $(this).find('.c_dropdown__option__content__item:first-of-type').data('slide'); if (slideIdx !== undefined) { owl = $('.owl-carousel'); owl.trigger('to.owl.carousel', slideIdx); } } toggle(this, e); $(this).prop('checked', true); eval($(this).attr('data-toggle-js')); }); }); function toggle(el, e) { if ($(el).attr('data-toggle-prevent-default') !== 'false') { try { e.preventDefault(); } catch (err) { ; } } var id = $(el).attr('data-toggle'); if ($(el).hasClass('toggle-active')) { $(el).removeClass('toggle-active').addClass('toggle-inactive'); $(id).removeClass('toggle-active').addClass('toggle-inactive'); $('a.toggle-active').removeClass('toggle-active').addClass('toggle-inactive'); $('.c_tabs-box__tab__content__item').removeClass('toggle-active').addClass('toggle-inactive'); $('.c_dropdown__option__content__item').removeClass('toggle-active').addClass('toggle-inactive'); $('.product-detail-menu__col1').removeClass('toggle-active').addClass('toggle-inactive'); $('.product-detail-menu__preview-small').removeClass('toggle-active').addClass('toggle-inactive'); } else { if (['.filterType', '.filterPassenger', '.filterHull', '.filterBerth', '.filterMore', '.filterCountry', '.filterDealer', '.filterRegion'].includes(id)) { $('.filterType, .filterPassenger, .filterHull, .filterBerth, .filterMore, .filterCountry, .filterDealer, .filterRegion') .removeClass('toggle-active') .addClass('toggle-inactive'); } $(el).removeClass('toggle-inactive').addClass('toggle-active'); $(id).removeClass('toggle-inactive').addClass('toggle-active'); } } function initslider(el, config) { var owlCarousel = $(el) .find('.c_img-slider__body__carousel') .owlCarousel({ items: 1, slideBy: 1, loop: false, dots: false, nav: true, navContainer: $(el).find('.c_img-slider__body__arrow-container'), lazyLoad: true, navText: ["", ""] }) .on('changed.owl.carousel', function (event) { slideChanged(this, event); }); var owlCarouselFooter = $(el) .find('.c_img-slider__footer__images.owl-carousel') .owlCarousel({ slideBy: 1, items: 100, loop: false, dots: false, autoWidth: true, nav: false, margin: 20, lazyLoad: true, onChanged: onChanged, onRefreshed: onRefreshed }); function onChanged(event) { var width = $(el) .find('.c_img-slider__footer .owl-stage') .width(); $(el) .find('.c_img-slider__footer .owl-stage') .attr('data-initial-width', width); } function onRefreshed(event) { var width = $(el) .find('.c_img-slider__footer .owl-stage') .attr('data-initial-width') + 100; $(el) .find('.c_img-slider__footer .owl-stage') .width(width); } $(document).ready(function () { var images = $(el).find('.c_img-slider__footer__images__image'); for (var i = 0; i < images.length; i++) { $(images[i]).attr('data-slide', i); } $(el) .find('.c_img-slider__footer__slide-counter__total-slides') .html(images.length); $(el) .find('.c_img-slider__footer__images .c_img-slider__footer__images__image') .click(function () { owlCarousel.trigger('to.owl.carousel', $(this).attr('data-slide')); owlCarouselFooter.trigger('to.owl.carousel', $(this).attr('data-slide')); }); $(el) .find('.c_img-slider__body__arrow') .click(function () { if ( $(this) .find('.icon--arrow-left') .is(':visible') ) { // Left //console.log('Left'); } else { // Right //console.log('Right'); } }); }); function slideChanged(element, event) { $(el) .find('.c_img-slider__footer__images__image') .removeClass('active'); $(el) .find('.c_img-slider__footer__images__image:eq(' + event.item.index + ')') .addClass('active'); $(el) .find('.c_img-slider__footer__slide-counter__current-slide') .html(event.item.index + 1); owlCarouselFooter.trigger('to.owl.carousel', event.item.index); var description = $(el).find('.c_img-slider__footer__images__image:eq(' + event.item.index + ')').data('description'); $('.c_img-slider__header__title').html(description); } } });