PageSourceSearch

https://www.castitreach.com/wp-content/themes/custom_theme/script.js?ver=1.0.0-1790275855

js castitreach.com collected 2026-09-24 19:02:24 UTC 20,422 bytes, 555 lines download raw bytes

1
2
3// scroll to top of page on all page refreshes
4if (history.scrollRestoration) {
5    history.scrollRestoration = 'manual';
6} else {
7    window.onbeforeunload = function () {
8        window.scrollTo(0, 0);
9    }
10}
11
12// Home Page - Case Studies: set height of section
13function setCaseStudyCarouselHeight(addedHeight = 0) {
14    $(".case-studies-carousel").height(
15        $(".case-studies .case-study.active").height() + addedHeight
16    );
17}
18
19// Home Page: set heights of "Reach More Talent", "Premium Platform", and "Benefits" sections
20function setHomePageSectionContainerHeights() {
21    const windowHeight = $(window).height();
22    const reachMoreTalent = $(".home-page .reach-more-talent");
23    const reachMoreTalentPadding = (windowHeight - reachMoreTalent.outerHeight()) / 2;
24    const premiumPlatform = $(".home-page .premium-platform");
25    const premiumPlatformPadding = (windowHeight - premiumPlatform.height()) / 2;
26    const benefits = $(".home-page .benefits");
27    const benefitsPadding = (windowHeight - benefits.height()) / 2;
28
29    if ($(window).width() > 992) {
30        reachMoreTalent.parent().css({
31            paddingTop: reachMoreTalentPadding,
32            paddingBottom: (reachMoreTalentPadding >= premiumPlatformPadding) ? reachMoreTalentPadding : 0,
33        });
34
35        premiumPlatform.parent().css({
36            paddingTop: (premiumPlatformPadding > reachMoreTalentPadding) ? premiumPlatformPadding : 0,
37            paddingBottom: premiumPlatformPadding,
38        });
39
40        benefits.css({
41            paddingTop: benefitsPadding,
42            paddingBottom: benefitsPadding,
43        });
44    }
45}
46
47// Home Page - Benefits: set initial hidden position for phone mockup image and all text
48function hideBenefitsContentAnimation() {
49    $(".home-page .benefits .phone-mockup-image > *").css({transform: "scale(0)"});
50    $(".home-page .benefits .column-title, .home-page .benefits .column-description").each(function() {
51        const textElement = $(this).find("p");
52        textElement.css({transform: `translateY(${textElement.height()}px)`});
53    });
54}
55
56function setNavbarBgColor(setTransitionsAfter = false) {
57    if (
58        window.location.pathname.startsWith("/terms") ||
59        window.location.pathname.startsWith("/privacy") ||
60        window.location.pathname.startsWith("/cookies")
61    ) {
62        $(".site-header").addClass("scrolled");
63    } else if ($(document).scrollTop() === 0 && $(".site-header").hasClass("scrolled")) {
64        $(".site-header").removeClass("scrolled");
65    } else if ($(document).scrollTop() !== 0 && !$(".site-header").hasClass("scrolled")) {
66        $(".site-header").addClass("scrolled");
67    }
68
69    if (setTransitionsAfter) {
70        $(".site-header.scrolled .left-col #navbar-logo .logo-white").css({
71        	transition: "0.3s fill",
72        });
73        $(".site-header .right-col, .site-header .right-col a, .site-header .hamburger-menu-icon i").css({
74        	transition: "0.3s color",
75        });
76    }
77}
78
79function loadingScreenAnimation() {
80    // freeze scroll
81    $("html, body").css({overflow: "hidden"});
82
83    // hide title and subtitle in jumbotron (will be animated to appear later)
84    const jumbotronTitle = $(".home-page .jumbotron .title");
85    jumbotronTitle.css({transform: `translateY(${jumbotronTitle.height()}px)`});
86    const jumbotronSubtitle = $(".home-page .jumbotron .subtitle p");
87    jumbotronSubtitle.css({transform: `translateY(${jumbotronSubtitle.height()}px)`});
88
89    // animation to show logo
90    $(".loading-screen .logo-wrapper").addClass("show");
91
92    // make all content visible, so that it will be revealed after the swipe animation
93    $(".home-page .lifestyle-carousel, .home-page .black-bg").css({opacity: 1});
94
95    // swipe away loading screen
96    $(".loading-screen")
97        .queue(function(next) {
98            $(this).addClass("hide");
99            next();
100        })
101        .delay(500)
102        .queue(function(next) {
103            $(this).css({display: "none"});
104            next();
105        });
106
107    // swipe in jumbotron section
108    $(".home-page .black-bg")
109        .delay(500)
110        .animate(
111            {now: "+=200"},
112            {
113                duration: 1200, // Gary Polygon Speed 
114                step: function(now, fx) {
115                    $(this).css(
116                        "clip-path",
117                        `polygon(
118                            ${200 - (now + 50)}% 0vh,
119                            100% 0vh,
120                            100% 100vh,
121                            100% 100vh,
122                            ${200 - now}% 100vh
123                        )`
124                    );
125                },
126                complete: function() {
127                    this.now = 0;
128                },
129            },
130        );
131
132    // slide/fade in jumbotron content TEXT
133    $(".home-page .jumbotron")
134        .delay(1000)
135        .queue(function(next) {
136            $(this).addClass("show-content");
137            jumbotronTitle.css({transform: `translateY(0)`});
138            jumbotronSubtitle.css({transform: `translateY(0)`});
139            next();
140        });
141
142    // partial swipe in to reveal corner of lifestyle carousel
143    $(".home-page .black-bg")
144        .animate(
145            {now: "+=100"},
146            {
147                duration: 500,
148                step: function(now, fx) {
149                    $(this).css(
150                        "clip-path",
151                        `polygon(
152                            0% 0%,
153                            ${now > 45 ? 55 : (100 - now)}% 0%,
154                            ${now > 45 ? 100 : 145 - now}% 100vh,
155                            100% 100%,
156                            0% 100%
157                        )`
158                    );
159                },
160                complete: function() {
161                    this.now = 0;
162                },
163            },
164        );
165
166    // unfreeze scroll
167    $('html, body')
168        .delay(2000)
169        .queue(function(next) {
170            $(this).css({overflow: 'auto'});
171            next();
172        });
173}
174
175// Home Page - Benefits: animate sprite sheet
176const totalFrames = 80;
177const spriteSheetAnimationSpeed = totalFrames / 2;
178let currentFrame = 0;
179let spriteImageHeight = 500;
180let spriteSheetAnimation;
181function animateSpriteSheet() {
182    $(".home-page .phone-mockup-image-sprite-sheet img").css({
183        transform: `translateX(-${currentFrame * spriteImageHeight}px)`,
184    });
185
186    // currentFrame = currentFrame >= totalFrames ? 0 : (currentFrame + 1);
187    if (currentFrame >= totalFrames - 1) {
188        clearInterval(spriteSheetAnimation);
189    } else {
190        currentFrame += 1;
191    }
192}
193function resetSpriteSheet() {
194    currentFrame = 0;
195    $(".home-page .phone-mockup-image-sprite-sheet img").css({
196        transform: `translateX(0)`,
197    });
198}
199
200// Home Page - Testimonials: auto-rotate testimonials carousel
201const testimonialsCarouselSpeed = 5000;
202let testimonialsRotationAnimation;
203function animateTestimonialsCarousel() {
204    const currentActiveIndex = $(".case-studies .indicator-dot").index(
205        $(".case-studies .indicator-dot.active")
206    );
207    const newActiveIndex = (currentActiveIndex + 1) ===  $(".case-studies .indicator-dot").length
208        ? 0
209        : (currentActiveIndex + 1);
210
211    $(".case-study.active").removeClass("active");
212    $(".case-study").eq(newActiveIndex).addClass("active");
213    setCaseStudyCarouselHeight();
214
215    $(".indicator-dot.active").removeClass("active");
216    $(".indicator-dot").eq(newActiveIndex).addClass("active");
217}
218
219// on page load
220// $(document).ready(function() {
221$(window).on("load", function() {
222    $(window).scrollLeft(0);
223
224    setNavbarBgColor(true);
225
226    if (window.location.pathname === "/" && $(window).width() > 992) {
227        loadingScreenAnimation();
228    }
229
230    if (localStorage.getItem("acknowledgedCookies") !== "true") {
231        $(".cookie-banner").css({display: "block"});
232    }
233
234    // Navbar - Collapsed: change link and logo colors if current page is Contact page
235    if (window.location.pathname.startsWith("/contact-us")) {
236        $("#navbar-logo .logo-white").css({fill: "#161616"});
237        $(".site-header .right-col").css({color: "#161616"});
238    }
239
240    // Home Page - Case Studies: generate indicator dots based on number of case studies
241    let indicatorsHtml = "";
242    $(".case-studies .case-study").each(function(index, caseStudy) {
243        indicatorsHtml += `<div class="indicator-dot ${index === 0 ? "active" : ""}"></div>`;
244    });
245    $(".indicator-dots").html(indicatorsHtml);
246
247    setCaseStudyCarouselHeight();
248
249    setHomePageSectionContainerHeights();
250
251    // Home Page - Companies: set width of slide track based on number of slides and trigger scroll animation
252    const slideWidth = $(window).width() <= 600 ? 150 : 250;
253    const numSlides = $(".home-page .customer-slide").length;
254    $(".home-page .customers-carousel-track").width(slideWidth * numSlides);
255    $.keyframe.define([
256        {
257            name: 'customers-carousel-scroll',
258            '0%':   {transform: "translateX(0)"},
259            '100%': {transform: `translateX(${slideWidth * numSlides * -1}px)`},
260        },
261        {
262            name: 'customers-carousel-scroll-reverse',
263            '0%':   {transform: `translateX(${slideWidth * numSlides * -1}px)`},
264            '100%': {transform: "translateX(0)"},
265        },
266    ]);
267    $(".home-page .customer-slide").clone().appendTo(".home-page .customers-carousel-track");
268    $(".home-page .customers-carousel.carousel-1 .customers-carousel-track").playKeyframe({
269        name: 'customers-carousel-scroll',
270        duration: '150s',
271        timingFunction: 'linear',
272        iterationCount: 'infinite',
273    });
274    $(".home-page .customers-carousel.carousel-2 .customers-carousel-track").playKeyframe({
275        name: 'customers-carousel-scroll-reverse',
276        duration: '150s',
277        timingFunction: 'linear',
278        iterationCount: 'infinite',
279    });
280
281    // Home Page - Companies: initialize animate-on-scroll animation library
282    AOS.init({
283        easing: 'ease-out-back',
284        duration: 1000,
285    });
286
287    // Home Page - Reach More Talent / Premium Platform: initialize parallax for images in both sections
288    const parallaxImages = document.querySelectorAll(
289        ".home-page .reach-more-talent img, .home-page .premium-platform img"
290    );
291    new simpleParallax(parallaxImages, {overflow: true, scale: 1.3});
292
293    // set initial hidden position for phone mockup image and all text in "Benefits" section
294    // (will be used for Benefits section entrance animation)
295    hideBenefitsContentAnimation();
296
297    $(".preload-phone-mockup-image").attr("src", $(".home-page .phone-mockup-image-sprite-sheet img").attr("src"));
298
299    if ($(window).width() <= 992) {
300        testimonialsRotationAnimation = setInterval(animateTestimonialsCarou
300sel, testimonialsCarouselSpeed);
301    }
302});
303
304// on window resize
305$(window).resize(function() {
306    // Navbar - Expanded: fix sizing when reizing screen
307    $(".mainMenu").css({transition: "0s left"});
308    if ($(".mainMenu").hasClass("open")) {
309        $(".mainMenu").css({
310            left: $(window).width() <= 500
311                ? "0px"
312                : `calc(100vw - ${$(".mainMenu").outerWidth()}px)`,
313        });
314    }
315
316    // Home Page - Case Studies: reset heights for grid descriptions that were
317    // hidden from when mobile accordion was visible
318    if ($(window).width() > 600) {
319        $(".case-study .grid-item-description").height("auto");
320    } else {
321        $(".case-study .grid-item:not(.open) .grid-item-description").height(0);
322    }
323
324    setCaseStudyCarouselHeight();
325
326    setHomePageSectionContainerHeights();
327});
328
329// Cookie Banner: close banner on button click
330$(".cookie-button").click(function() {
331    $(".cookie-banner").css({display: "none"});
332    localStorage.setItem("acknowledgedCookies", "true");
333});
334
335// Subpages: open/close "Summary of Changes" accordion
336$(".summary-of-changes .head").click(function() {
337    if ($(".summary-of-changes").hasClass("collapsed")) {
338        $(".summary-of-changes").removeClass("collapsed");
339    } else {
340        $(".summary-of-changes").addClass("collapsed");
341    }
342});
343
344// Navbar: open expanded menu
345$(".site-header .hamburger-menu-icon").click(function() {
346    $(".mainMenu").addClass("open");
347    $(".mainMenu").css({transition: "0.5s left"});
348    $(".mainMenu").css({left: `calc(100vw - ${$(".mainMenu").outerWidth()}px)`});
349
350    // freeze scrolling
351    $("html, body").css({overflow: "hidden"});
352});
353
354// Navbar: close expanded menu
355$(".mainMenu .close-icon").click(function() {
356    $(".mainMenu").removeClass("open");
357    $(".mainMenu").css({transition: "0.5s left"});
358    $(".mainMenu").css({left: "100vw"});
359
360    // unfreeze scrolling
361    $("html, body").css({overflow: "auto"});
362});
363
364// Scroll Down Button: scroll down to "Reach More Talent" section of Home page
365$(".scroll-down-button").click(function() {
366    $("html, body").animate({scrollTop: $(window).height()}, 1000);
367});
368
369// Home Page - Case Studies: on indicator dot click, hide current case study and show new case study
370$(".indicator-dots").on("click", ".indicator-dot:not(.active)", function() {
371    const clickedDotIndex = $(".case-studies .indicator-dot").index(this);
372
373    $(".case-study.active").removeClass("active");
374    $(".case-study").eq(clickedDotIndex).addClass("active");
375    setCaseStudyCarouselHeight();
376
377    $(".indicator-dot.active").removeClass("active");
378    $(".indicator-dot").eq(clickedDotIndex).addClass("active");
379});
380
381// Home Page - Case Studies: on title click, expand/collapse accordion row
382$(".case-study .grid-item-title").click(function() {
383    if ($(window).width() <= 600) {
384        const parent = $(this).parent();
385        const description = parent.find(".grid-item-description");
386        const newDescriptionHeight = description.find("div").height();
387
388        if (parent.hasClass("open")) {
389            parent.removeClass("open");
390            description.height(0);
391            setCaseStudyCarouselHeight(newDescriptionHeight * -1);
392        } else {
393            parent.addClass("open");
394            description.height(newDescriptionHeight);
395            setCaseStudyCarouselHeight(newDescriptionHeight);
396        }
397    }
398});
399
400let entranceAnimStarted = false;
401let exitAnimStarted = false;
402$(window).scroll(function() {
403    setNavbarBgColor();
404
405    if (window.location.pathname !== "/") {
406        return;
407    }
408
409    // once end of black background section is reached scrolling down, begin entrance animation
410    if (
411        !DISABLE_ORANGE_BG_TRANSITION &&
412        !entranceAnimStarted &&
413        $(window).width() > 992 &&
414        $('.home-page .orange-bg')[0].getBoundingClientRect().top <= -50
415    ) {
416        entranceAnimStarted = true;
417        exitAnimStarted = false;
418
419        // freeze scrolling to prevent user from moving during the animation
420        const sectionTopPos = $('.home-page .orange-bg').offset().top + 50;
421        $(window).scrollTop(sectionTopPos + 2);
422        $('html, body').css({overflow: 'hidden'});
423
424        // exit animation (staggered slide left off screen) for all elements in "Premium Platform" section
425        $(".home-page .premium-platform").addClass("anim-started");
426
427        // swipe animation (black bg -> orange bg)
428        let transformAnimsStarted = false;
429        $(".home-page .orange-bg").delay(600).animate(
430            {now: "+=150"},
431            {
432                duration: 800,
433                step: function(now, fx) {
434                    $(this).css(
435                        "clip-path",
436                        `polygon(
437                            ${now < 100 ? (100 - now) : 0}% 0,
438                            100% 0,
439                            100% 100%,
440                            ${now < 50 ? 100 : (100 - (now - 50))}% 100%
441                        )`
442                    );
443
444                    // entrance animation for image and text columns in "Benefits section" once swipe animation is 66% done
445                    if (now > 100 && !transformAnimsStarted) {
446                        transformAnimsStarted = true;
447                        $(".home-page .benefits .phone-mockup-image img").css({transform: "scale(1)"});
448                        $(".home-page .benefits .column-title, .home-page .benefits .column-description").each(function() {
449                            $(this).find("p").css({transform: "translateY(0)"});
450                        });
451
452                        // animation for opaque circles behind phone image
453                        $(".home-page .benefits .phone-mockup-image")
454                            .queue(function(next) {
455                                $(this).find(".large-bg-circle").css({transform: "scale(1)"});
456                                next();
457                            })
458                            .delay(500)
459                            .queue(function(next) {
460                                $(this).find(".small-bg-circle").css({transform: "scale(1)"});
461                                next();
462                            })
463                            .delay(1000)
464                            .queue(function(next) {
465                                $(this).find(".small-bg-circle").css({transform: "scale(0)"});
466                                $(this).find(".large-bg-circle").css({transform: "scale(0)"});
467                                next();
468                            });
469                    }
470                },
471                complete: function() {
472                    this.now = 0;
473                },
474            },
475        );
476
477        // unfreeze scroll once animation is complete
478        $(".home-page .orange-bg").promise().done(function() {
479            $('html, body').css({overflow: 'auto'});
480            spriteSheetAnimation = setInterval(animateSpriteSheet, spriteSheetAnimationSpeed);
481            testimonialsRotationAnimation = setInterval(animateTestimonialsCarousel, testimonialsCarouselSpeed);
482        });
483    }
484
485    // once top of orange background section is reached scrolling up, begin exit animation
486    else if (
487        !DISABLE_ORANGE_BG_TRANSITION &&
488        entranceAnimStarted &&
489        !exitAnimStarted &&
490        $(window).width() > 992 &&
491        $('.home-page .orange-bg')[0].getBoundingClientRect().top > 0
492    ) {
493        exitAnimStarted = true;
494        entranceAnimStarted = false;
495
496        // freeze scrolling to prevent user from moving during the animation
497        const sectionTopPos = $('.home-page .orange-bg').offset().top;
498        $(window).scrollTop(sectionTopPos - 2);
499        $('html, body').css({overflow: 'hidden'});
500
501        // swipe animation (black bg <- orange bg)
502        hideBenefitsContentAnimation();
503        $(".home-page .orange-bg").animate(
504            {now: "+=150"},
505            {
506                duration: 800,
507                step: function(now, fx) {
508                    $(this).css(
509                        "clip-path",
510                        `polygon(
511                            ${now < 100 ? now : 100}% 0,
512                            100% 0,
513                            100% 100%,
514                            ${now < 50 ? 0 : (now - 50)}% 100%
515                        )`
516                    );
517                },
518                complete: function() {
519                    this.now = 0;
520                },
521            },
522        );
523
524        // entrance animation (staggered slide right onto screen) for all elements in "Premium Platform" section
525        $(".home-page .premium-platform")
526            .queue(function(next) {
527                $(this).addClass("anim-ended");
528                next();
529            })
530            .delay(1750)
531            .queue(function(next) {
532                $(this).removeClass("anim-started");
533                $(this).removeClass("anim-ended");
534                next();
535            });
536
537        // unfreeze scroll once animation is complete
538        $(".home-page .orange-bg").promise().done(function() {
539            $('html, body').css({overflow: 'auto'});
540            resetSpriteSheet();
541            clearInterval(spriteSheetAnimation);
542            clearInterval(testimonialsRotationAnimation);
543        });
544    }
545
546    else if (
547        !entranceAnimStarted &&
548        $(window).width() <= 992 &&
549        $('.home-page .orange-bg')[0].getBoundingClientRect().top < 300
550    ) {
551        entranceAnimStarted = true;
552        exitAnimStarted = false;
553        spriteSheetAnimation = setInterval(animateSpriteSheet, spriteSheetAnimationSpeed);
554    }
555});

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.