PageSourceSearch

https://lcctorch.com/wp-content/themes/newsnation/assets/lib/custom/js/custom.js?ver=7.1.2

js lcctorch.com collected 2026-10-02 12:34:46 UTC 19,489 bytes, 549 lines download raw bytes

1window.addEventListener("load", function(){
2
3    jQuery(document).ready(function($){
4        "use strict";
5
6        $("body").addClass("page-loaded");
7
8    });
9
10});
11// Keep globals intact
12let timerInterval;
13let timeClock = document.getElementById("wpi-time-clock");
14
15function myTimer() {
16    const date = new Date();
17    if (timeClock) timeClock.innerHTML = date.toLocaleTimeString();
18}
19
20// Simple micro-throttle for scroll-intensive handlers
21function throttle(fn, wait) {
22    let inProgress = false;
23    return function (...args) {
24        if (inProgress) return;
25        inProgress = true;
26        setTimeout(() => {
27            fn.apply(this, args);
28            inProgress = false;
29        }, wait);
30    };
31}
32
33jQuery(function ($) {
34    "use strict";
35
36    // Cache commonly used selectors
37    const $doc = $(document);
38    const $win = $(window);
39    const $body = $("body");
40    const $primaryMenu = $(".primary-menu");
41    const $siteNavigation = $(".site-navigation");
42    const $headerSearchbar = $(".header-searchbar");
43    const $offcanvasMenu = $("#offcanvas-menu");
44    const $navbarOffcanvasBtn = $(".navbar-control-offcanvas");
45    const $hamburgerOne = $("#hamburger-one");
46    const $sidrWrapper = $("#sidr-nav");
47    const $themeNavigation = $("#theme-navigation");
48
49    // Tab-to-menu syncing
50    $doc.on("click", ".tab-button", function () {
51        const target = $(this).data("target");
52        $primaryMenu.find("li").removeClass("active");
53        $primaryMenu.find(".sub-menu").hide();
54        const $menuItem = $primaryMenu.find('a[href="' + target + '"]');
55        if ($menuItem.length) {
56            $menuItem.closest("li").addClass("active");
57            const $parentLi = $menuItem.closest(".menu-item-has-children");
58            $parentLi.addClass("active");
59            $parentLi.children(".sub-menu").css("display", "block");
60        }
61    }); // [3][14]
62
63    // Accessible primary menu focus/touch management
64    const menuHandler = {
65        init() {
66            if ($siteNavigation.length) this.traverse($siteNavigation);
67        },
68        traverse($navigation) {
69            const $menu = $navigation.find("ul").first();
70            if (!$menu.length) return;
71            if (!$menu.hasClass("theme-menu")) $menu.addClass("theme-menu");
72
73            const $links = $menu.find("a");
74            const $linksWithChildren = $menu.find(
75                ".menu-item-has-children > a, .page_item_has_children > a"
76            );
77
78            $links.on("focus blur", this.toggleFocus);
79            $linksWithChildren.on("touchstart", this.toggleFocus);
80        },
81        toggleFocus(event) {
82            const $self = $(this);
83            if (event.type === "focus" || event.type === "blur") {
84                $self.parentsUntil(".theme-menu", "li").toggleClass("focus");
85            }
86            if (event.type === "touchstart") {
87                event.preventDefault();
88                const $menuItem = $self.parent("li");
89                $menuItem.siblings().removeClass("focus");
90                $menuItem.toggleClass("focus");
91            }
92        },
93    };
94    menuHandler.init(); // [3][14]
95
96    // Start time clock if present
97    if (timeClock) {
98        timerInterval = setInterval(myTimer, 1000);
99    } // [1]
100
101    // Tooltips
102    $(".tooltips").append("<span></span>");
103    $doc.on("mouseenter", ".tooltips", function () {
104        $(this).find("span").empty().append($(this).attr("data-tooltip"));
105    }); // [1]
106
107    // Dark/Light mode via localStorage
108    let switchMode = localStorage.getItem("switchMode");
109    const $switchModeToggle = $(".theme-colormode-switcher");
110    const enableDarkMode = function () {
111        $body.addClass("theme-darkmode-enabled");
112        localStorage.setItem("switchMode", "enabled");
113    };
114    const disableDarkMode = function () {
115        $body.removeClass("theme-darkmode-enabled");
116        localStorage.setItem("switchMode", null);
117    };
118    if (switchMode === "enabled") {
119        enableDarkMode();
120        $(".mode-icon-change").addClass("mode-icon-night").removeClass("mode-icon-light");
121    } else {
122        $(".mode-icon-change").addClass("mode-icon-light").removeClass("mode-icon-night");
123    }
124    $doc.on("click", ".theme-colormode-switcher", function () {
125        $(".mode-icon-change").toggleClass("mode-icon-light mode-icon-night");
126        switchMode = localStorage.getItem("switchMode");
127        if (switchMode !== "enabled") {
128            enableDarkMode();
129        } else {
130            disableDarkMode();
131        }
132    }); // [1]
133
134
135
136    // Mark articles as loaded
137    $(".theme-article-area").addClass("theme-article-loaded"); // [1]
138
139    // Submenu Toggle
140    $doc.on("click", ".submenu-toggle", function () {
141        $(this).toggleClass("button-toggle-active");
142        const currentClass = $(this).attr("data-toggle-target");
143        $(currentClass).toggleClass("submenu-toggle-active");
144    }); // [3][14]
145
146    // Header Search open/close and focus trap
147    $doc.on("click", ".header-searchbar", function () {
148        $headerSearchbar.removeClass("header-searchbar-active");
149        $body.removeClass("body-scroll-locked");
150    });
151    $doc.on("click", ".header-searchbar-inner", function (e) {
152        e.stopPropagation();
153    });
154    $doc.on("click", "#search-closer", function () {
155        $headerSearchbar.removeClass("header-searchbar-active");
156        setTimeout(function () {
157            $(".navbar-control-search").focus();
158        }, 300);
159        $body.removeClass("body-scroll-locked");
160    });
161    $doc.on("click", ".navbar-control-search", function () {
162        $headerSearchbar.toggleClass("header-searchbar-active");
163        setTimeout(function () {
164            $(".header-searchbar .search-field").focus();
165        }, 300);
166        $body.addClass("body-scroll-locked");
167    });
168    $doc.on("focus", "input, a, button", function () {
169        if ($headerSearchbar.hasClass("header-searchbar-active")) {
170            if ($(this).hasClass("skip-link-search-top")) {
171                $(".header-searchbar #search-closer").focus();
172            }
173            if (!$(this).parents(".header-searchbar").length) {
174                $(".header-searchbar .search-field").focus();
175            }
176        }
177    }); // [1]
178
179    // Global Escape handler
180    $doc.on("keyup", function (j) {
181        if (j.key !== "Escape") return;
182        if ($headerSearchbar.hasClass("header-searchbar-active")) {
183            $headerSearchbar.removeClass("header-searchbar-active");
184            $body.removeClass("body-scroll-locked");
185            setTimeout(function () {
186                $(".navbar-control-search").focus();
187            }, 300);
188        }
189        if ($offcanvasMenu.hasClass("offcanvas-menu-active")) {
190            $headerSearchbar.removeClass("header-searchbar-active");
191            $offcanvasMenu.removeClass("offcanvas-menu-active");
192            $navbarOffcanvasBtn.removeClass("active");
193            $body.removeClass("body-scroll-locked");
194            setTimeout(function () {
195                $navbarOffcanvasBtn.focus();
196            }, 300);
197        }
198        if ($body.hasClass("sidr-nav-open")) {
199            $.sidr("close", "sidr-nav");
200            $hamburgerOne.removeClass("active");
201            $body.removeClass("body-scroll-locked");
202            setTimeout(function () {
203                $hamburgerOne.focus();
204            }, 300);
205        }
206    }); // [1]
207
208    // Offcanvas toggles
209    $doc.on("click", ".navbar-control-offcanvas", function () {
210        $(this).addClass("active");
211        $body.addClass("body-scroll-locked");
212        $offcanvasMenu.toggleClass("offcanvas-menu-active");
213        $(".button-offcanvas-close").focus();
214    });
215    $doc.on("click", ".button-offcanvas-close", function () {
216        $offcanvasMenu.removeClass("offcanvas-menu-active");
217        $navbarOffcanvasBtn.removeClass("active");
218        $body.removeClass("body-scroll-locked");
219        setTimeout(function () {
220            $navbarOffcanvasBtn.focus();
221        }, 300);
222    });
223    $doc.on("click", "#offcanvas-menu", function () {
224        $offcanvasMenu.removeClass("offcanvas-menu-active");
225        $navbarOffcanvasBtn.removeClass("active");
226        $body.removeClass("body-scroll-locked");
227    });
228    $doc.on("click", ".offcanvas-wraper", function (e) {
229        e.stopPropagation();
230    });
231    $doc.on("focus", "input, a, button", function () {
232        if ($offcanvasMenu.hasClass("offcanvas-menu-active")) {
233            if ($(this).hasClass("skip-link-off-canvas")) {
234                if (!$("#offcanvas-menu #social-nav-offcanvas").length == 0) {
235                    $("#offcanvas-menu #social-nav-offcanvas ul li:last-child a").focus();
236                } else if (!$("#offcanvas-menu #primary-nav-offcanvas").length == 0) {
237                    $("#offcanvas-menu #primary-nav-offcanvas ul li:last-child a").focus();
238                }
239            }
240        }
241    });
242    $doc.on("focus", ".skip-link-offcanvas", function () {
243        $(".button-offcanvas-close").focus();
244    }); // [3][14]
245
246    // Sidr Widget Area
247    if ($body.hasClass("rtl")) {
248        $("#widgets-nav").sidr({ name: "sidr-nav", side: "right" });
249    } else {
250        $("#widgets-nav").sidr({ name: "sidr-nav", side: "left" });
251    }
252    $doc.on("click", "#hamburger-one", function () {
253        $(this).toggleClass("active");
254        if ($(this).hasClass("active")) {
255            $body.addClass("body-scroll-locked");
256        } else {
257            $body.removeClass("body-scroll-locked");
258        }
259        setTimeout(function () {
260            $(".sidr-offcanvas-close").focus();
261        }, 300);
262    });
263    $doc.on("click", ".sidr-offcanvas-close", function () {
264        $.sidr("close", "sidr-nav");
265        $hamburgerOne.removeClass("active");
266        $body.removeClass("body-scroll-locked");
267        setTimeout(function () {
268            $hamburgerOne.focus();
269        }, 300);
270    });
271    $doc.on("focus", "input, a, button", function () {
272        if ($body.hasClass("sidr-nav-open")) {
273            if ($(this).hasClass("skip-link-offcanvas-first")) {
274                $(".skip-link-offcanvas-last").focus();
275            }
276            if (!$(this).parents("#sidr-nav").length) {
277                $(".sidr-offcanvas-close").focus();
278            }
279        }
280    }); // [1]
281
282    // RTL flag for sliders
283    let rtled = $body.hasClass("rtl"); // [16]
284
285    // Gutenberg gallery/slick (safe per-instance init)
286    $('figure.wp-block-gallery.has-nested-images.columns-1, .wp-block-gallery.columns-1 ul.blocks-gallery-grid, .gallery-columns-1').each(function () {
287        $(this).slick({
288            slidesToShow: 1,
289            slidesToScroll: 1,
290            fade: true,
291            autoplay: false,
292            autoplaySpeed: 8000,
293            infinite: true,
294            nextArrow: '<button type="button" class="slide-btn slide-btn-bg slide-next-icon">' + newsnation_custom.next_svg + "</button>",
295            prevArrow: '<button type="button" class="slide-btn slide-btn-bg slide-prev-icon">' + newsnation_custom.prev_svg + "</button>",
296            dots: false,
297            rtl: rtled
298        });
299    }); // [16][7]
300
301    // Banner tabs
302    $doc.on("click", "#theme-banner-navs a", function () {
303        $("#theme-banner-navs li").removeClass("active");
304        $(this).parent().addClass("active");
305        const currentTab = $(this).attr("href");
306        $(".video-slider-right .wpi-banner-tab").hide();
307        $(currentTab).show();
308        return false;
309    }); // [1]
310
311    // Slick groups
312    $(".theme-slider-block").each(function () {
313        $(this).slick({
314            slidesToShow: 1,
315            slidesToScroll: 1,
316            fade: true,
317            autoplay: false,
318            autoplaySpeed: 8000,
319            infinite: true,
320            prevArrow: $(this).closest(".theme-block-navtabs").find(".slide-prev-lead"),
321            nextArrow: $(this).closest(".theme-block-navtabs").find(".slide-next-lead"),
322            dots: false
323        });
324    }); // [16]
325
326    $(".theme-tiles-slide").each(function () {
327        $(this).slick({
328            slidesToShow: 1,
329            slidesToScroll: 1,
330            fade: true,
331            autoplay: false,
332            autoplaySpeed: 8000,
333            infinite: true,
334            prevArrow: $(this).closest(".theme-block-tiles").find(".slide-prev-tiles"),
335            nextArrow: $(this).closest(".theme-block-tiles").find(".slide-next-tiles"),
336            dots: false
337        });
338    }); // [16]
339
340    $(".theme-widget-slider").each(function () {
341        $(this).slick({
342            slidesToShow: 1,
343            slidesToScroll: 1,
344            fade: true,
345            autoplay: false,
346            autoplaySpeed: 8000,
347            infinite: true,
348            prevArrow: $(this).closest(".theme-jumbo-banner").find(".slide-prev-banner"),
349            nextArrow: $(this).closest(".theme-jumbo-banner").find(".slide-next-banner"),
350            dots: false
351        });
352    }); // [16]
353
354    $(".main-carousel-content").slick({
355        slidesToShow: 1,
356        slidesToScroll: 1,
357        fade: true,
358        asNavFor: ".main-carousel-pagination",
359        autoplay: true,
360        speed: 900,
361        autoplaySpeed: 6000,
362        arrows: false
363    }); // [16]
364
365    $(".main-carousel-pagination").slick({
366        slidesToShow: 4,
367        slidesToScroll: 1,
368        asNavFor: ".main-carousel-content",
369        focusOnSelect: true,
370        vertical: true,
371        arrows: false,
372        responsive: [
373            { breakpoint: 991, settings: { slidesToShow: 2 } },
374            { breakpoint: 575, settings: { slidesToShow: 1 } }
375        ]
376    }); // [16]
377
378    $(".theme-widget-carousel").each(function () {
379        $(this).slick({
380            slidesToShow: 4,
381            slidesToScroll: 1,
382            dots: true,
383            infinite: true,
384            prevArrow: $(".slide-widget-prev"),
385            nextArrow: $(".slide-widget-next"),
386            responsive: [
387                { breakpoint: 991, settings: { slidesToShow: 3, slidesToScroll: 3 } },
388                { breakpoint: 768, settings: { slidesToShow: 2, slidesToScroll: 2, dots: false } },
389                { breakpoint: 575, settings: { slidesToShow: 1 } }
390            ]
391        });
392    }); // [16][10]
393
394    $(".slider-content-container").slick({
395        slidesToShow: 1,
396        slidesToScroll: 1,
397        arrows: false,
398        fade: true,
399        asNavFor: ".pagination-content-container"
400    }); // [16]
401
402    $(".pagination-content-container").slick({
403        slidesToShow: 1,
404        slidesToScroll: 1,
405        asNavFor: ".slider-content-container",
406        focusOnSelect: true,
407        prevArrow: $(".slider-content-pagination .slide-prev"),
408        nextArrow: $(".slider-content-pagination .slide-next")
409    }); // [16]
410
411    // Background images
412    $(".data-bg").each(function () {
413        const bg = $(this).attr("data-background");
414        if (bg) $(this).css("background-image", "url(" + bg + ")");
415    }); // [1]
416
417    // Scroll up button show/hide (throttled)
418    const toggleScrollUp = throttle(function () {
419        if ($win.scrollTop() > $win.height() / 2) {
420            $(".scroll-up").fadeIn(300);
421        } else {
422            $(".scroll-up").fadeOut(300);
423        }
424    }, 100); // [9][17][19]
425
426    $win.on("scroll", toggleScrollUp);
427    $doc.on("click", ".scroll-up", function () {
428        $("html, body").animate({ scrollTop: 0 }, 700);
429        return false;
430    }); // [9][17]
431
432    // Header affix on scroll
433    (function () {
434        const header = document.getElementById("theme-navigation");
435        if (!header) return;
436        const sticky = header.offsetTop;
437        const onScroll = throttle(function () {
438            if (window.pageYOffset > sticky) {
439                header.classList.add("theme-navbar-affix");
440            } else {
441                header.classList.remove("theme-navbar-affix");
442            }
443        }, 50);
444        // Use passive listener for scroll
445        window.addEventListener("scroll", onScroll, { passive: true });
446        onScroll();
447    })(); // [9][12][15]
448
449    // Navbar hide/show on scroll delta
450    (function () {
451        let didScroll = false;
452        let lastScrollTop = 0;
453        const delta = 5;
454        const navbarHeight = $themeNavigation.outerHeight() || 0;
455
456        $win.on("scroll", function () {
457            didScroll = true;
458        });
459
460        setInterval(function () {
461            if (!didScroll) return;
462            const st = $win.scrollTop();
463            if (Math.abs(lastScrollTop - st) <= delta) {
464                didScroll = false;
465                return;
466            }
467            if (st > lastScrollTop && st > navbarHeight) {
468                $("#theme-navigation").removeClass("navbar-affix-down").addClass("navbar-affix-up");
469            } else {
470                if (st + $win.height() < $(document).height()) {
471                    $("#theme-navigation").removeClass("navbar-affix-up").addClass("navbar-affix-down");
472                }
473            }
474            lastScrollTop = st;
475            didScroll = false;
476        }, 250);
477    })(); // [9][12][15]
478
479    // Ticker
480    $(".ticker-slides").marquee({
481        delayBeforeStart: 0,
482        duration: 25000,
483        pauseOnHover: true,
484        duplicated: true,
485        direction: "left",
486        startVisible: true
487    }); // [1]
488
489    // Masonry after images loaded
490    if ($(".archive-layout-masonry").length > 0) {
491        let grid;
492        const hidden = "scale(0.5)";
493        const visible = "scale(1)";
494        grid = $(".archive-layout-masonry").imagesLoaded(function () {
495            grid.masonry({
496                itemSelector: ".theme-article-area",
497                hiddenStyle: { transform: hidden, opacity: 0 },
498                visibleStyle: { transform: visible, opacity: 1 }
499            });
500        });
501    } // [1]
502
503    // Header ad countdown & scroll
504    const adCountDown = document.querySelector(".ad-countdown-timer");
505    const headerAds = document.querySelector(".theme-header-ads");
506    const adBtn = document.querySelector(".top-header-add");
507
508    if (headerAds && adCountDown && adBtn) {
509        const headerAdsHeight = headerAds.getBoundingClientRect().height;
510        let counter = 6;
511
512        const startScroll = () => {
513            window.scrollTo({ top: headerAdsHeight, behavior: "smooth" });
514            const onScroll = () => {
515                if (window.scrollY >= headerAdsHeight) {
516                    headerAds.classList.add("header-add-top");
517                    clearInterval(startCount);
518                    window.removeEventListener("scroll", onScroll, { passive: true });
519                }
520            };
521            window.addEventListener("scroll", onScroll, { passive: true });
522        };
523
524        adBtn.addEventListener("click", startScroll);
525
526        const startCount = setInterval(() => {
527            counter--;
528            if (counter <= 0) {
529                clearInterval(startCount);
530                startScroll();
531            }
532            adCountDown.textContent = `${counter}s`;
533        }, 1000);
534    } // [1]
535
536    // Subscribe modal
537    const subBtn = document.querySelector(".navbar-control-subscription");
538    const modal = document.querySelector(".theme-modal");
539    const closeBtn = document.querySelector(".theme-modal-close");
540    if (modal && subBtn && closeBtn) {
541        subBtn.addEventListener("click", () => {
542            modal.classList.add("active");
543        });
544        closeBtn.addEventListener("click", (e) => {
545            e.preventDefault();
546            modal.classList.remove("active");
547        });
548    } // [1]
549});

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.