$(function () { $(".tertiary-menu__item").on("click", function (e) { e.preventDefault(); var id = $(this).attr("href"); $('html, body').animate({ 'scrollTop': $(id).offset().top - 63 }, 2000); }); //copied from Main.js $(window).on("load", function () { var $allElements = $('*').find('[data-same-height]'); var groups = {}, group; $allElements.each(function (i, el) { group = $(el).data('same-height'); if (groups.hasOwnProperty(group)) { groups[group] += 1; } else { groups[group] = 1; } }); for (var key in groups) { // console.log(key); var $group = $('[data-same-height="' + key + '"]'); // Get an array of all element heights var elementHeights = $group.map(function () { return $(this).height(); }).get(); // Math.max takes a variable number of arguments // `apply` is equivalent to passing each height as an argument var maxHeight = Math.max.apply(null, elementHeights); // Set each height to the max height $group.height(maxHeight); } }); $(".remove-empty-paragraphs p:empty").remove(); //copied from Main.js $('.slider--features').royalSlider({ addActiveClass: true, arrowsNav: false, autoHeight: true, autoScaleSlider: false, //imageScaleMode: 'none', imageAlignCenter: false, imageScaleMode: 'fill', loop: true, fadeinLoadedSlide: false, globalCaption: true, keyboardNavEnabled: true, globalCaptionInside: false, }); var slider = $(".slider--features").data('royalSlider'); $('.slider--features + .slider .slider-nav__prev').on('click', function (e) { e.preventDefault(); slider.prev(); // prev slide }); $('.slider--features + .slider .slider-nav__next').on('click', function (e) { e.preventDefault(); slider.next(); // next slide }); $(".grouped-photo-switcher-link").click(function () { //Find first photo in group list and set container li element active $(this).parent(".photo-switcher__item").find(".photo-switcher__list--sub").find(".photo-switcher__link:first").parent().addClass("photo-switcher__item--active"); }); $("#more-reviews-section").on("click", "#more-reviews-button", function (e) { e.preventDefault(); var items = $(".testimonials__item"); currentReviewPage = currentReviewPage + 1; $(items).each(function (index, item) { var page = $(item).data('page'); if (page === currentReviewPage) { var main = $(item).find('.testimonials__item__main__text'); $(item).removeClass('hidden'); if ($(main).height() > 120) { $(main).addClass('testimonials__item__main__text--capitated'); $(main).closest('.testimonials__item').find('.testimonials__item__main__read-more').css('display', 'inline-flex'); $(main).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(); }); } } }); if (currentReviewPage === numberOfReviewPages) { $("#more-reviews-section").hide(); $("#all-reviews-section").addClass("testimonials__more"); //Keeping the bottom margin if button is hidden } }); $("#testimonials").on("click", "#load-more-testimonials", function (e) { e.preventDefault(); $(this).text($(this).data("waitMessage")); productsService.getMoreTestimonials(culture, nodeId, page, numberOfItems, function (html) { $(".grid__row.text--centered").remove(); $("#more-results-placeholder").replaceWith(html); $("#load-more-testimonials").text($("#load-more-testimonials").data("loadMessage")); page = page + 1; }); }); });