From fe7a10f64507a7b8f2fa1136b7b0f3875db15845 Mon Sep 17 00:00:00 2001 From: Eugene K Date: Wed, 7 Jun 2023 11:51:44 -0400 Subject: [PATCH] Attempt to fix consultingjs script This PR attempts to fix issue loading the consulting.js script in production due to odd MIME types being reported for the file. We don't quite understand what's going on or why the MIME types appear odd. We've tried re-creating and re-formatting the file in this PR in the hopes of correcting the issue. --- assets/js/consulting.js | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/assets/js/consulting.js b/assets/js/consulting.js index 076a46f09..1b830476e 100644 --- a/assets/js/consulting.js +++ b/assets/js/consulting.js @@ -1,43 +1,41 @@ - (function ($) { $(window).scroll(function () { // get the scroll position of the document + half the window height - - var scrollTop = $(document).scrollTop() + ($(window).height() / 2); - + var scrollTop = $(document).scrollTop() + $(window).height() / 2; var positions = []; // push each of the items we want to check against to an array with their position and selector - $('.box').each(function () { + $(".box").each(function () { $(this).removeClass("active"); positions.push({ position: $(this).offset().top, - element: $(this) + element: $(this), }); }); - var getClosest = closest(positions, scrollTop); getClosest.addClass("active"); // the element closest to the middle of the screen - var classList = $(".active").attr("class") + var classList = $(".active").attr("class"); var classArr = classList.split(/\s+/); - $('.box').each(function () { - if ($(this).hasClass(classArr[1]) && !$(this).hasClass('active')) { - $(this).addClass('active'); + $(".box").each(function () { + if ($(this).hasClass(classArr[1]) && !$(this).hasClass("active")) { + $(this).addClass("active"); } - check() + check(); }); - }); // finds the nearest position (from an array of objects) to the specified number function closest(array, number) { var num = 0; for (var i = array.length - 1; i >= 0; i--) { - if (Math.abs(number - array[i].position) < Math.abs(number - array[num].position)) { + if ( + Math.abs(number - array[i].position) < + Math.abs(number - array[num].position) + ) { num = i; } } @@ -45,9 +43,9 @@ } function check() { - var activeBox = $('.active'); + var activeBox = $(".active"); - $('.square').removeClass('active'); - $('.square-' + activeBox.data('box')).addClass('active'); + $(".square").removeClass("active"); + $(".square-" + activeBox.data("box")).addClass("active"); } })(window.jQuery);