PageSourceSearch

https://jalbath.com/wp-content/themes/blacklisted/assets/js/custom.js?ver=1788431761

js jalbath.com collected 2026-10-04 04:09:24 UTC 39,149 bytes, 1,252 lines download raw bytes

1document.addEventListener('DOMContentLoaded', function () {
2
3    // Guard: bail early with a clear message if localized data is missing
4    if (typeof headerSearchAjax === 'undefined') {
5        console.error('Header search: headerSearchAjax is not defined. Check wp_localize_script() output and page caching.');
6        return;
7    }
8
9    // Each entry represents one independent search panel (desktop dropdown, mobile offcanvas)
10    const panels = [
11        {
12            name:    'desktop',
13            input:   document.getElementById('headerSearchInputDesktop'),
14            results: document.getElementById('headerSearchResultsDesktop'),
15            viewAll: document.getElementById('headerViewAllDesktop'),
16            toggle:  document.getElementById('headerSearchToggle')
17        },
18        {
19            name:    'mobile',
20            input:   document.getElementById('headerSearchInputMobile'),
21            results: document.getElementById('headerSearchResultsMobile'),
22            viewAll: document.getElementById('headerViewAllMobile'),
23            toggle:  document.getElementById('offcanvasMenu')
24        }
25    ];
26
27    panels.forEach(function (panel) {
28        if (!panel.input || !panel.results) {
29            console.warn('Header search: input or results container not found for panel:', panel.name);
30            return;
31        }
32
33        let debounceTimer;
34        let hasLoadedDefault = false;
35
36        function runSearch(term) {
37            jQuery.post(headerSearchAjax.ajaxurl, {
38                action: 'header_live_search',
39                nonce: headerSearchAjax.nonce,
40                term: term
41            }, function (res) {
42                if (res && res.success) {
43                    panel.results.innerHTML = res.data.html;
44                    if (panel.viewAll) {
45                        panel.viewAll.href = res.data.view_all_url;
46                    }
47                } else {
48                    console.error('Header search (' + panel.name + '): unexpected/failed response (possible nonce expiry or cached page)', res);
49                }
50            }).fail(function (xhr) {
51                console.error('header_live_search AJAX request failed (' + panel.name + ')', xhr.status, xhr.responseText);
52            });
53        }
54
55        function loadDefaultOnce() {
56            if (hasLoadedDefault) return;
57            hasLoadedDefault = true;
58            runSearch('');
59        }
60
61        // Load latest 4 products immediately for this panel
62        loadDefaultOnce();
63
64        // Also reload if the panel is opened via hover/click/touch/focus
65        if (panel.toggle) {
66            panel.toggle.addEventListener('mouseenter', loadDefaultOnce);
67            panel.toggle.addEventListener('click', loadDefaultOnce);
68            panel.toggle.addEventListener('touchstart', loadDefaultOnce, { passive: true });
69            panel.toggle.addEventListener('focusin', loadDefaultOnce);
70        }
71
72        // Debounced live search while typing
73        panel.input.addEventListener('input', function () {
74            const val = this.value.trim();
75            clearTimeout(debounceTimer);
76            debounceTimer = setTimeout(function () {
77                runSearch(val);
78            }, 300);
79        });
80
81        // Also trigger on focus, in case mobile users tap the field directly
82        panel.input.addEventListener('focus', loadDefaultOnce);
83
84        // Enter key -> go to results page
85        panel.input.addEventListener('keydown', function (e) {
86            if (e.key === 'Enter') {
87                e.preventDefault();
88                window.location.href = '<?php echo esc_js(site_url('/product-search/')); ?>?s=' + encodeURIComponent(this.value.trim());
89            }
90        });
91    });
92});
93    
94jQuery(function ($) {
95
96    if (!$('#product-search-term').length) return;
97
98    let filterTimer;
99    let searchTypingTimer;
100
101    // Helper: update the "(N) Search Results" count in the DOM.
102    // Falls back to 0 if the value isn't a valid number.
103    function updateSearchResultsCount(total) {
104        const $count = $('#search-results-count');
105        if (!$count.length) return;
106
107        const n = parseInt(total, 10);
108        $count.text('(' + (isNaN(n) ? 0 : n) + ') Search Results');
109    }
110
111    function applySearchFilters(page = 1) {
112
113        let searchVal = $('#product-search-term').val();
114
115        let typeVal = $('input[name="type[]"]:checked').map(function () {
116            return this.value;
117        }).get();
118
119        let colorVal = $('input[name="color[]"]:checked').map(function () {
120            return this.value;
121        }).get();
122
123        let sortVal = $('select[name="sort"]').val();
124
125        let data = {
126            action: 'filter_search_products',
127            page: page,
128            s: searchVal,
129            type: typeVal,
130            color: colorVal
131        };
132
133        if (sortVal) data.sort = sortVal;
134
135        const params = new URLSearchParams(window.location.search);
136        params.set('s', searchVal);
137        if (sortVal) { params.set('sort', sortVal); } else { params.delete('sort'); }
138        params.delete('type[]');
139        params.delete('color[]');
140        typeVal.forEach(v => params.append('type[]', v));
141        colorVal.forEach(v => params.append('color[]', v));
142
143        history.replaceState({}, '', window.location.pathname + '?' + params.toString());
144
145        $('#loader-overlay').css('display', 'flex');
146
147        $.post(blogAjax.ajaxurl, data, function (response) {
148            if (response.success) {
149                $('.products-grid').html('<div class="row g-4">' + response.data.html + '</div>');
150
151                // Update the visible result count using the total
152                // returned by filter_search_products_ajax().
153                updateSearchResultsCount(response.data.total);
154
155                (response.data.total > 0 && response.data.max > 1)
156                    ? $('.filter-clear').show()
157                    : $('.filter-clear').hide();
158                $('#loader-overlay').hide();
159                $('html, body').animate({ scrollTop: $('#get_results').offset().top - 100 }, 400);
160            }
161        });
162    }
163
164    function triggerSearchFilters(page = 1) {
165        clearTimeout(filterTimer);
166        filterTimer = setTimeout(() => applySearchFilters(page), 300);
167    }
168
169    $(document).on('change', 'select[name="sort"]', function () {
170        triggerSearchFilters(1);
171    });
172
173    $(document).on('change', 'input[name="type[]"], input[name="color[]"]', function () {
174        triggerSearchFilters(1);
175    });
176
177    $('#applySearchFilters').on('click', function () {
178        applySearchFilters(1);
179    });
180
181    // NEW: live search as user types in the visible search box
182    $(document).on('input', '#productSearchPageInput', function (e) {
183        e.preventDefault();
184
185        let typedVal = $(this).val();
186
187        // keep the hidden term input in sync so applySearchFilters reads the latest value
188        $('#product-search-term').val(typedVal);
189
190        clearTimeout(searchTypingTimer);
191        searchTypingTimer = setTimeout(function () {
192            applySearchFilters(1);
193        }, 400);
194    });
195
196    // Prevent full page reload if Enter is pressed inside the search form
197    $(document).on('keydown', '#productSearchPageInput', function (e) {
198        if (e.key === 'Enter') {
199            e.preventDefault();
200            clearTimeout(searchTypingTimer);
201            $('#product-search-term').val($(this).val());
202            applySearchFilters(1);
203        }
204    });
205
206    $(document).on('click', '.products-grid .pagination-wrapper a', function (e) {
207        e.preventDefault();
208
209        let href = $(this).attr('href');
210        if (!href) return;
211
212        let page = 1;
213        let pagedMatch = href.match(/paged=([0-9]+)/);
214        let pageMatch  = href.match(/\/page\/([0-9]+)/);
215
216        if (pagedMatch) page = parseInt(pagedMatch[1], 10);
217        else if (pageMatch) page = parseInt(pageMatch[1], 10);
218
219        applySearchFilters(page);
220    });
221
222    $('.filter-clear').on('click', function (e) {
223        e.preventDefault();
224        $('select[name="sort"]').val('');
225        $('input[name="type[]"], input[name="color[]"]').prop('checked', false);
226        applySearchFilters(1);
227        $(this).hide();
228    });
229
230});
231
232jQuery('.page-template-social-media .download_icon').on('click', function () {
233
234    var DownloadPDFfile = jQuery(this).data("download");
235
236    jQuery.ajax({
237        url: fluentFormVars.ajaxUrl,
238        type: 'POST',
239        data: {
240            action: 'downloadPDF_file',
241            DownloadPDFfile: DownloadPDFfile,
242        },
243        success: function (response) {
244            if (response) {
245                var fileUrl = response;
246
247                if (typeof response === 'object') {
248                    if (response.data && response.data.file_url) {
249                        fileUrl = response.data.file_url;
250                    } else if (response.data) {
251                        fileUrl = response.data;
252                    } else if (response.file_url) {
253                        fileUrl = response.file_url;
254                    }
255                }
256
257                jQuery('#ff_14_download_link').val(fileUrl);
258                jQuery('#final-download-link').attr('href', fileUrl);
259
260                jQuery('#downloadModal').modal('show');
261            }
262        },
263        error: function (xhr, status, error) {
264            console.error('Download AJAX failed:', status, error);
265        }
266    });
267});
268
269jQuery(document).on('click', '#final-download-link', function () {
270    setTimeout(function () {
271        jQuery('#downloadModal').modal('hide');
272        location.reload();
273    }, 800);
274});
275
276jQuery(document).on('click', 'a.toc-list-item', function(e) {
277    e.preventDefault();
278
279    let target = jQuery(this).attr('href');
280
281    if (jQuery(target).length) {
282        jQuery('html, body').animate({
283            scrollTop: jQuery(target).offset().top - 100
284        }, 400);
285    }
286});
287
288document.addEventListener("DOMContentLoaded", function () {
289
290    document.querySelectorAll(".colors_elements .color-box").forEach(function (box) {
291
292        box.addEventListener("click", function () {
293
294            const imageUrl = this.getAttribute("data-image");
295            const imageCate = this.getAttribute("data-imagecate");
296
297            document.querySelectorAll(".swiper-slide img").forEach(function (swiperImg) {
298                swiperImg.setAttribute("src", imageUrl);
299                swiperImg.setAttribute("data-zoom", imageUrl);
300                if (imageCate) {
301                    swiperImg.setAttribute("alt", imageCate);
302                }
303            });
304
305            document.querySelectorAll(".magnifier-glass").forEach(function (glass) {
306                glass.style.backgroundImage = `url("${imageUrl}")`;
307            });
308
309            const catalogueEl = document.getElementById("catalogue-no");
310            if (catalogueEl) {
311                catalogueEl.textContent = imageCate;
312            }
313
314        });
315
316    });
317
318});
319
320// about slider Sh
321document.addEventListener("DOMContentLoaded", function () {
322
323    const timelineWrapper = document.querySelector(".timeline-wrapper");
324    const timelineItems = document.querySelectorAll(".timeline-item");
325
326    const swiper = new Swiper(".timelineSwiper", {
327        slidesPerView: 1,
328        speed: 700,
329        allowTouchMove: true,
330        navigation: {
331            nextEl: ".swiper-next",
332            prevEl: ".swiper-prev",
333        },
334        on: {
335            slideChange: function () {
336                updateTimeline(this.activeIndex);
337            }
338        }
339    });
340
341    function updateTimeline(index) {
342        timelineItems.forEach(el => el.classList.remove("active"));
343
344        const active = timelineItems[index];
345        if (!active) return;
346
347        active.classList.add("active");
348
349        const wrapperRect = timelineWrapper.getBoundingClientRect();
350        const itemRect = active.getBoundingClientRect();
351
352        const LEFT_PADDING = 120;
353
354        const scrollLeft =
355            timelineWrapper.scrollLeft +
356            (itemRect.left - wrapperRect.left) -
357            LEFT_PADDING;
358
359        timelineWrapper.scrollTo({
360            left: scrollLeft,
361            behavior: "smooth"
362        });
363    }
364});
365
366// Catalogue page JS
367document.addEventListener("DOMContentLoaded", function () {
368    let pdfLink = "";
369    jQuery(document).on('click', '#catalogModalPDF', function () {
370        pdfLink = jQuery(this).data('cat');
371        console.log(pdfLink);
372    });
373
374    const swiper = new Swiper(".productSwiper", {
375        slidesPerView: "auto",
376        centeredSlides: true,
377        loop: true,
378        roundLengths: true,
379        spaceBetween: 20,
380        speed: 600,
381        loopedSlides: 10,
382        loopAdditionalSlides: 10,
383        grabCursor: true,
384        breakpoints: {
385            0: { slidesPerView: 1.5 },
386            768: { slidesPerView: 2.5 },
387            1024: { slidesPerView: 5 }
388        },
389        on: {
390            init: function () {
391                const activeSlide = this.slides[this.activeIndex];
392                if (!activeSlide) return;
393                document.getElementById("catalogTitle").textContent = activeSlide.dataset.title || "";
394                document.getElementById("catalogDesc").textContent = activeSlide.dataset.desc || "";
395                document.getElementById("catalogBtn").textContent = activeSlide.dataset.label || "Download Now";
396                pdfLink = activeSlide.dataset.link || "";
397            },
398            slideChangeTransitionEnd: function () {
399                const activeSlide = this.slides[this.activeIndex];
400                if (!activeSlide) return;
401                document.getElementById("catalogTitle").textContent = activeSlide.dataset.title || "";
402                document.getElementById("catalogDesc").textContent = activeSlide.dataset.desc || "";
403                document.getElementById("catalogBtn").textContent = activeSlide.dataset.label || "Download Now";
404                pdfLink = activeSlide.dataset.link || "";
405            }
406        }
407    });
408
409    const modal = document.getElementById("catalogModal");
410    const formWrapper = document.getElementById("formWrapper");
411    const downloadWrapper = document.getElementById("downloadWrapper");
412    const downloadPDF = document.getElementById("downloadPDF");
413
414    function resetFormUI() {
415        downloadWrapper.style.display = "none";
416        const form = formWrapper.querySelector("form");
417        if (form) {
418            form.reset();
419        }
420        const successMsgs = formWrapper.querySelectorAll(".ff-message-success");
421        successMsgs.forEach(el => el.remove());
422    }
423
424    document.addEventListener("fluentform_submission_success", function () {
425        downloadPDF.setAttribute("href", pdfLink);
426        downloadWrapper.style.display = "block";
427    });
428
429    downloadPDF.addEventListener("click", function () {
430        resetFormUI();
431    });
432    modal.addEventListener("hidden.bs.modal", function () {
433        resetFormUI();
434    });
435});
436
437// Fluent Form Validation
438jQuery(document).ready(function ($) {
439
440    jQuery('input[name="phone"]').on('input', function () {
441        var maxDigits = 12;
442        var valuedigiti = jQuery(this).val();
443        valuedigiti = valuedigiti.replace(/\D/g, '');
444        if (valuedigiti.length > maxDigits) {
445            valuedigiti = valuedigiti.slice(0, maxDigits);
446        }
447        jQuery(this).val(valuedigiti);
448    });
449
450    jQuery('input[name="names[first_name]"], input[name="names[last_name]"] ').on('input', function () {
451        var maxDigits = 50;
452        var valuelast = jQuery(this).val();
453        valuelast = valuelast.replace(/[^a-zA-Z ]/g, '');
454        if (valuelast.length > maxDigits) {
455            valuelast = valuelast.slice(0, maxDigits);
456        }
457        jQuery(this).val(valuelast);
458    });
459
460});
461
462jQuery(document).on('click', 'a[data-bs-toggle="modal"]', function () {
463
464    let title = jQuery(this).closest('.job-card').find('h3').text().trim();
465    let degree = jQuery(this).closest('.job-card').find('.degree').text().trim();
466    let current_job_location = jQuery(this).closest('.job-card').find('.current_job_location').text().trim();
467
468    console.log(degree);
469    console.log(title);
470
471    jQuery('#ff_8_Post_Applied_For').prop("disabled",true);
472    jQuery('#ff_8_Post_Applied_For').val(title+ ', '+ current_job_location);
473    jQuery('#ff_8_Qualification').val(degree);
474});
475
476// Dealer Filters Ajax
477jQuery(function ($) {
478
479    function loadDealers(page = 1) {
480        let data = {
481            action: 'filter_dealers',
482            pincode: $('#pindcode').val(),
483            state: $('#selectState').val(),
484            city: $('#selectCity').val(),
485            page: page
486        };
487
488        $.post(blogAjax.ajaxurl, data, function (response) {
489            $('#loader-overlay').removeClass('d-flex');
490            $('.results').html(response);
491        });
492    }
493
494    $('#pindcode').on('keyup change', function () {
495        $('#loader-overlay').addClass('d-flex');
496        loadDealers(1);
497    });
498
499    $('#selectState').on('change', function () {
500        $('#loader-overlay').addClass('d-flex');
501        let state = $(this).val();
502        $.post(blogAjax.ajaxurl, { action: 'load_cities', state: state }, function (cities) {
503            $('#selectCity').html(cities);
504        });
505        loadDealers(1);
506    });
507
508    $('#selectCity').on('change', function () {
509        $('#loader-overlay').addClass('d-flex');
510        loadDealers(1);
511    });
512
513    $(document).on('click', '.ajax-page', function(e){
514        e.preventDefault();
515        let page = $(this).data('page');
516        if (!page) return;
517        $('#loader-overlay').addClass('d-flex');
518        loadDealers(page);
519        $('html, body').animate({ scrollTop: $('#cst-find-dealers').offset().top - 100 }, 300);
520    });
521
522});
523
524// Products Filters Ajax
525jQuery(function ($) {
526
527// Only run on category listing pages, never on the search page
528    if (!$('#product-category-id').length || $('#product-search-term').length) return;
529    let filterTimer;
530
531    function applyFilters(page = 1) {
532
533        let categoryId = $('#product-category-id').val();
534
535        let typeVal = $('input[name="type[]"]:checked').map(function () {
536            return this.value;
537        }).get();
538
539        let colorVal = $('input[name="color[]"]:checked').map(function () {
540            return this.value;
541        }).get();
542
543        let subCatVal = $('input[name="sub_cat[]"]:checked').map(function () {
544            return this.value;
545        }).get();
546
547        let rangesVal = $('select[name="ranges"]').val();
548
549        let data = {
550            action: 'filter_products',
551            page: page,
552            category_id: categoryId,
553            type: typeVal,
554            color: colorVal
555        };
556
557        if (rangesVal) {
558            data.ranges = rangesVal;
559        } else {
560            if (subCatVal.length) {
561                data.sub_cat = subCatVal;
562            }
563        }
564
565        let sortVal = $('select[name="sort"]').val();
566        if (sortVal) {
567            data.sort = sortVal;
568        }
569
570        let colorElementVal = $('input[name="colors_elements"]:checked').val();
571        if (colorElementVal) {
572            data.colors_elements = colorElementVal;
573        }
574
575        const params = new URLSearchParams();
576
577        if (data.sort) {
578            params.set('sort', data.sort);
579        }
580
581        if (data.colors_elements) {
582            params.set('colors_elements', data.colors_elements);
583        }
584
585        if (rangesVal) {
586            params.set('ranges', rangesVal);
587        }
588
589        ['type', 'color', 'sub_cat'].forEach(key => {
590            if (Array.isArray(data[key])) {
591                data[key].forEach(v => params.append(key + '[]', v));
592            }
593        });
594
595        history.replaceState(
596            {},
597            '',
598            window.location.pathname + (params.toString() ? '?' + params.toString() : '')
599        );
600
601        $('#loader-overlay').show();
602
603        $.post(blogAjax.ajaxurl, data, function (response) {
604
605            if (response.success) {
606
607                $('.products-grid').html(response.data.html);
608                $('.products-grid .pagination-wrapper').html(response.data.pagination);
609
610                // Keep the result count in sync here too, in case this
611                // page also renders a #search-results-count element.
612                if (typeof response.data.total !== 'undefined') {
613                    const $count = $('#search-results-count');
614                    if ($count.length) {
615                        const n = parseInt(response.data.total, 10);
616                        $count.text('(' + (isNaN(n) ? 0 : n) + ') Search Results');
617                    }
618                }
619
620                response.data.get_filter
621                    ? $('.filter-clear').show()
622                    : $('.filter-clear').hide();
623
624                $('#loader-overlay').hide();
625
626                $('html, body').animate({
627                    scrollTop: $('#get_results').offset().top - 100
628                }, 400);
629            }
630        });
631    }
632
633    function triggerFilters(page = 1) {
634        clearTimeout(filterTimer);
635        filterTimer = setTimeout(() => applyFilters(page), 300);
636    }
637
638    $(document).on('change', 'select[name="sort"]', function () {
639        $('#loader-overlay').css('display', 'flex');
640        triggerFilters(1);
641    });
642
643    $(document).on('change', 'select[name="ranges"]', function () {
644        $('#loader-overlay').css('display', 'flex');
645        triggerFilters(1);
646    });
647
648    $(document).on(
649        'change',
650        'input[name="type[]"], input[name="color[]"], input[name="sub_cat[]"]',
651        function () {
652            $('#loader-overlay').css('display', 'flex');
653            triggerFilters(1);
654        }
655    );
656
657    $(document).on('change', 'input[name="colors_elements"]', function () {
658        $('input[name="colors_elements"]').not(this).prop('checked', false);
659        $('#loader-overlay').css('display', 'flex');
660        triggerFilters(1);
661    });
662
663    $(document).on('click', '.products-grid .pagination-wrapper a', function (e) {
664        e.preventDefault();
665
666        $('#loader-overlay').css('display', 'flex');
667
668        let href = $(this).attr('href');
669        if (!href) return;
670
671        let page = 1;
672
673        let pagedMatch = href.match(/paged=([0-9]+)/);
674        let pageMatch  = href.match(/\/page\/([0-9]+)/);
675
676        if (pagedMatch) {
677            page = parseInt(pagedMatch[1], 10);
678        } else if (pageMatch) {
679            page = parseInt(pageMatch[1], 10);
680        }
681
682        applyFilters(page);
683    });
684
685    $('.filter-clear').on('click', function (e) {
686        e.preventDefault();
687
688        history.replaceState({}, '', window.location.pathname);
689
690        $('select[name="sort"]').val('');
691        $('input[name="type[]"], input[name="color[]"], input[name="sub_cat[]"], input[name="colors_elements"]')
692            .prop('checked', false);
693
694        $('#loader-overlay').css('display', 'flex');
695        applyFilters(1);
696        $(this).hide();
697    });
698
699    if (window.location.search.length) {
700        syncFiltersFromURL();
701        applyFilters(1);
702    }
703
704    function syncFiltersFromURL() {
705
706        const params = new URLSearchParams(window.location.search);
707
708        $('select[name="sort"]').val('');
709        $('input[name="type[]"], input[name="color[]"], input[name="sub_cat[]"], input[name="colors_elements"]')
710            .prop('checked', false);
711
712        if (params.has('sort')) {
713            $('select[name="sort"]').val(params.get('sort'));
714        }
715
716        if (params.has('colors_elements')) {
717            $('input[name="colors_elements"][value="' + params.get('colors_elements') + '"]')
718                .prop('checked', true);
719        }
720
721        params.getAll('type[]').forEach(val => {
722            $('input[name="type[]"][value="' + val + '"]').prop('checked', true);
723        });
724
725        params.getAll('color[]').forEach(val => {
726            $('input[name="color[]"][value="' + val + '"]').prop('checked', true);
727        });
728
729        params.getAll('sub_cat[]').forEach(val => {
730            $('input[name="sub_cat[]"][value="' + val + '"]').prop('checked', true);
731        });
732    }
733
734});
735
736// Ajax call of Events
737jQuery(function ($) {
738
739    let currentPage = 1;
740    let currentSlug = 'all';
741    let currentCatId = 0;
742    let currentSort = 'date_desc';
743    let ajaxUsed = false;
744
745    function loadTabContent(page = 1) {
746
747        ajaxUsed = true;
748
749        jQuery.ajax({
750            url: blogAjax.ajaxurl,
751            type: 'POST',
752            data: {
753                action: 'load_events',
754                category_id: currentCatId,
755                category_slug: currentSlug,
756                page: page,
757                sort: currentSort
758            },
759            beforeSend() {
760                jQuery('#' + currentSlug).html('<p>Loading...</p>');
761            },
762            success(response) {
763                jQuery('#' + currentSlug).html(response);
764            }
765        });
766    }
767
768    jQuery('.page-template-events .blog-tabs button').on('click', function () {
769        currentSlug = jQuery(this).data('category-id');
770        currentCatId = jQuery(this).data('categoryid');
771        currentPage = 1;
772        loadTabContent();
773    });
774
775    jQuery('.page-template-events #event-sort').on('change', function () {
776        currentSort = jQuery(this).val();
777        currentPage = 1;
778        loadTabContent();
779    });
780
781    jQuery(document).on(
782        'click',
783        '.page-template-events .event-section .pagination-wrapper a',
784        function (e) {
785
786            e.preventDefault();
787
788            let href = jQuery(this).attr('href');
789            if (!href) return;
790
791            let page = 1;
792
793            let match = href.match(/\/page\/(\d+)/) || href.match(/paged=(\d+)/);
794            if (match) {
795                page = parseInt(match[1]);
796            }
797
798            currentPage = page;
799            loadTabContent(currentPage);
800            jQuery('html, body').animate({
801                scrollTop: jQuery('#' + currentSlug).offset().top - 100
802            }, 500);
803        }
804    );
805
806});
807
808// Ajax call of blogs
809jQuery(function ($) {
810
811    let currentPage = 1;
812    let currentSlug = 'all';
813    let currentCatId = 0;
814    let currentSort = 'date_desc';
815    let ajaxUsed = false;
816
817    function loadTabContentBlogs(page = 1) {
818
819        ajaxUsed = true;
820
821        jQuery.ajax({
822            url: blogAjax.ajaxurl,
823            type: 'POST',
824            data: {
825                action: 'load_blogs',
826                category_id: currentCatId,
827                category_slug: currentSlug,
828                page: page,
829                sort: currentSort
830            },
831            beforeSend() {
832                jQuery('#' + currentSlug).html('<p>Loading...</p>');
833            },
834            success(response) {
835                jQuery('#' + currentSlug).html(response);
836            }
837        });
838    }
839
840    jQuery('.page-template-blogs .blog-tabs button').on('click', function () {
841        currentSlug = jQuery(this).data('category-id');
842        currentCatId = jQuery(this).data('categoryid');
843        currentPage = 1;
844        loadTabContentBlogs();
845    });
846
847    jQuery('.page-template-blogs #blog-sort').on('change', function () {
848        currentSort = jQuery(this).val();
849        currentPage = 1;
850        loadTabContentBlogs();
851    });
852
853    jQuery(document).on(
854        'click',
855        '.page-template-blogs .blog-section .pagination-wrapper a',
856        function (e) {
857
858            e.preventDefault();
859
860            let href = jQuery(this).attr('href');
861            if (!href) return;
862
863            let page = 1;
864
865            let match = href.match(/\/page\/(\d+)/) || href.match(/paged=(\d+)/);
866            if (match) {
867                page = parseInt(match[1]);
868            }
869
870            currentPage = page;
871            loadTabContentBlogs(currentPage);
872
873            jQuery('html, body').animate({
874                scrollTop: jQuery('#' + currentSlug).offset().top - 100
875            }, 500);
876
877        }
878
879    );
880
881});
882
883// Projects call of blogs
884jQuery(function ($) {
885
886    let currentPage = 1;
887    let currentSlug = 'all';
888    let currentCatId = 0;
889    let currentSort = 'date_desc';
890    let ajaxUsed = false;
891
892    function loadprjectTabContentProjects(page = 1) {
893
894        ajaxUsed = true;
895
896        jQuery.ajax({
897            url: blogAjax.ajaxurl,
898            type: 'POST',
899            data: {
900                action: 'load_projects',
901                category_id: currentCatId,
902                category_slug: currentSlug,
903                page: page,
904                sort: currentSort
905            },
906            beforeSend() {
907                jQuery('#' + currentSlug).html('<p>Loading...</p>');
908            },
909            success(response) {
910                jQuery('#' + currentSlug).html(response);
911            }
912        });
913    }
914
915    jQuery('#projects-sort').on('change', function () {
916        currentSort = jQuery(this).val();
917        currentPage = 1;
918        loadprjectTabContentProjects();
919    });
920
921    jQuery(document).on(
922        'click',
923        '.our-projects-section .pagination-wrapper a',
924        function (e) {
925
926            e.preventDefault();
927
928            let href = jQuery(this).attr('href');
929            if (!href) return;
930
931            let page = 1;
932
933            let match = href.match(/\/page\/(\d+)/) || href.match(/paged=(\d+)/);
934            if (match) {
935                page = parseInt(match[1]);
936            }
937
938            currentPage = page;
939            loadprjectTabContentProjects(currentPage);
940
941            jQuery('html, body').animate({
942                scrollTop: jQuery('#' + currentSlug).offset().top - 100
943            }, 500);
944        }
945
946    );
947
948});
949
950document.addEventListener('DOMContentLoaded', function () {
951    const thumbSwiper = new Swiper(".thumb-swiper", {
952        spaceBetween: 12,
953        slidesPerView: 4,
954        watchSlidesProgress: true,
955    });
956
957    const mainSwiper = new Swiper(".main-swiper", {
958        spaceBetween: 0,
959        thumbs: {
960            swiper: thumbSwiper,
961        },
962    });
963
964    var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
965    var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
966        return new bootstrap.Tooltip(tooltipTriggerEl)
967    });
968
969    // anchor tag scroll smooth (FIXED: safe against non-fragment hrefs)
970    document.querySelectorAll('a[href^="#"]').forEach(anchor => {
971        anchor.addEventListener('click', function (e) {
972            const hash = this.getAttribute('href');
973
974            if (!hash || hash === '#' || hash.length < 2) return;
975
976            let target;
977            try {
978                target = document.querySelector(hash);
979            } catch (err) {
980                return;
981            }
982
983            if (target) {
984                e.preventDefault();
985                target.scrollIntoView({
986                    behavior: 'smooth',
987                    block: 'start'
988                });
989            }
990        });
991    });
992
993});
994
995document.addEventListener("DOMContentLoaded", function () {
996  const menuWrapper = document.querySelector('#menu-off-canvas');
997
998  if (!menuWrapper) return;
999
1000  const menuItems = menuWrapper.querySelectorAll('.menu-item-has-children');
1001
1002  menuItems.forEach(item => {
1003    const link = item.querySelector('.nav-link');
1004    const submenu = item.querySelector('.sub-menu');
1005
1006    if (!link || !submenu) return;
1007
1008    link.addEventListener('click', function (e) {
1009      e.preventDefault();
1010      e.stopPropagation();
1011
1012      submenu.classList.toggle('open');
1013      link.classList.toggle('open');
1014    });
1015  });
1016
1017  document.addEventListener('click', function (e) {
1018    if (menuWrapper.contains(e.target)) return;
1019
1020    menuWrapper.querySelectorAll('.sub-menu.open').forEach(submenu => {
1021      submenu.classList.remove('open');
1022    });
1023
1024    menuWrapper.querySelectorAll('.nav-link.open').forEach(link => {
1025      link.classList.remove('open');
1026    });
1027  });
1028});
1029
1030// video section js
1031document.addEventListener('DOMContentLoaded', () => {
1032    const videoWrapper = document.querySelector('.video-wrapper');
1033    const poster = videoWrapper.querySelector('.video-poster');
1034    const playBtn = videoWrapper.querySelector('.play-button');
1035    const videoContainer = videoWrapper.querySelector('.video-container');
1036    const iframe = videoContainer.querySelector('iframe');
1037
1038    const playVideo = () => {
1039        poster.style.display = 'none';
1040        playBtn.style.display = 'none';
1041
1042        videoContainer.classList.remove('d-none');
1043
1044        if (!iframe.src) {
1045            const src = iframe.dataset.src;
1046            iframe.src = src.includes('?') ? `${src}&autoplay=1` : `${src}?autoplay=1`;
1047        }
1048    };
1049
1050    poster.addEventListener('click', playVideo);
1051    playBtn.addEventListener('click', playVideo);
1052});
1053
1054// home hero section
1055const video = document.getElementById('heroVideo');
1056
1057function setupToggle(id) {
1058    const toggle = document.getElementById(id);
1059    if (toggle) {
1060        toggle.addEventListener('click', () => {
1061            video.muted = !video.muted;
1062
1063            document.querySelectorAll('.sound-icon--mute')
1064                .forEach(el => el.style.display = video.muted ? 'block' : 'none');
1065
1066            document.querySelectorAll('.sound-text--mute')
1067                .forEach(el => el.style.display = video.muted ? 'inline' : 'none');
1068
1069            document.querySelectorAll('.sound-icon--sound')
1070                .forEach(el => el.style.display = video.muted ? 'none' : 'block');
1071
1072            document.querySelectorAll('.sound-text--sound')
1073                .forEach(el => el.style.display = video.muted ? 'none' : 'inline');
1074        });
1075    }
1076}
1077
1078setupToggle('soundToggle');
1079setupToggle('soundToggleDesktop');
1080
1081// projects-slider
1082document.addEventListener('DOMContentLoaded', function () {
1083
1084    const projectsSwiper = new Swiper('.projects-slider', {
1085        loop: false,
1086        spaceBetween: 24,
1087        grabCursor: true,
1088        slidesPerView: 1.1,
1089        breakpoints: {
1090            576: { slidesPerView: 2 },
1091            768: { slidesPerView: 2.5 },
1092            992: { slidesPerView: 1.5 },
1093            1200: { slidesPerView: 1.8 }
1094        }
1095    });
1096
1097});
1098
1099// homepage shortsSwiper js
1100document.addEventListener('DOMContentLoaded', () => {
1101    const section = document.getElementById('shortsBg');
1102
1103    const swiper = new Swiper('.shortsSwiper', {
1104        centeredSlides: true,
1105        loop: true,
1106        slidesPerView: 1.6,
1107        spaceBetween: 40,
1108
1109        mousewheel: {
1110            enabled: true,
1111            forceToAxis: true,
1112            sensitivity: 1,
1113            releaseOnEdges: false
1114        },
1115
1116        breakpoints: {
1117            768: { slidesPerView: 2.8, spaceBetween: 60 },
1118            1024: { slidesPerView: 3.5, spaceBetween: 70 },
1119            1500: { slidesPerView: 4.8, spaceBetween: 80 }
1120        },
1121
1122        on: {
1123            init(swiper) {
1124                updateBg(swiper);
1125            },
1126            slideChange(swiper) {
1127                updateBg(swiper);
1128            }
1129        }
1130    });
1131
1132    function updateBg(swiper) {
1133        const realSlide = swiper.slides.filter(
1134            slide => !slide.classList.contains('swiper-slide-duplicate')
1135        )[swiper.realIndex];
1136
1137        const bg = realSlide?.dataset.bg;
1138
1139        if (bg) {
1140            section.style.backgroundImage = `url(${bg})`;
1141        }
1142    }
1143});
1144
1145// home stack slider
1146const wrapper = document.getElementById('sliderWrapper');
1147if (wrapper) {
1148    let slides = Array.from(wrapper.children);
1149    let rotationSeq = [0, 8, -8];
1150    let rotIndex = 0;
1151
1152    function updateStackedSlides() {
1153        slides.forEach(slide => {
1154            slide.className = 'slide';
1155            slide.style.opacity = '';
1156            slide.style.zIndex = '';
1157            slide.style.transform = '';
1158        });
1159
1160        slides[0].style.opacity = 1;
1161        slides[0].style.zIndex = 3;
1162        slides[0].style.transform = `rotate(${rotationSeq[rotIndex]}deg)`;
1163
1164        if (slides[1]) slides[1].classList.add('pos-2');
1165        if (slides[2]) slides[2].classList.add('pos-3');
1166
1167        rotIndex = (rotIndex + 1) % rotationSeq.length;
1168    }
1169
1170    function slideNext() {
1171        wrapper.appendChild(slides.shift());
1172        slides.push(wrapper.lastElementChild);
1173        updateStackedSlides();
1174    }
1175
1176    updateStackedSlides();
1177    setInterval(slideNext, 1500);
1178
1179    var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
1180    var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
1181        return new bootstrap.Tooltip(tooltipTriggerEl)
1182    })
1183
1184}
1185
1186document.addEventListener('DOMContentLoaded', function () {
1187(function () {
1188  var header = document.querySelector('.main-header');
1189  if (!header) return;
1190
1191  function stickyHeader() {
1192    if (window.pageYOffset > 100) {
1193      header.classList.add('is-sticky');
1194    } else {
1195      header.classList.remove('is-sticky');
1196    }
1197  }
1198
1199  stickyHeader();
1200
1201  window.addEventListener('scroll', stickyHeader);
1202})();
1203});
1204
1205// element page js SH
1206gsap.registerPlugin(ScrollTrigger);
1207
1208const slides = gsap.utils.toArray(".slide");
1209
1210gsap.to(slides, {
1211    yPercent: -100 * (slides.length - 1),
1212    ease: "none",
1213    scrollTrigger: {
1214        trigger: "#slider",
1215        start: "top top",
1216        end: () => "+=" + window.innerHeight * slides.length,
1217        scrub: 1,
1218        pin: true,
1219        snap: {
1220            snapTo: 1 / (slides.length - 1),
1221            duration: 0.5,
1222            ease: "power1.inOut"
1223        },
1224        anticipatePin: 1,
1225        invalidateOnRefresh: true
1226    }
1227});
1228
1229// artful-section js
1230gsap.registerPlugin(ScrollTrigger);
1231
1232const images = gsap.utils.toArray(".image-item");
1233
1234gsap.timeline({
1235    scrollTrigger: {
1236        trigger: ".artful-section",
1237        start: "top top",
1238        end: "+=200%",
1239        scrub: true,
1240        pin: true,
1241        anticipatePin: 1
1242    }
1243})
1244    .fromTo(images, {
1245        y: -120,
1246        opacity: 0
1247    }, {
1248        y: 0,
1249        opacity: 1,
1250        stagger: 0.3,
1251        ease: "power2.out"
1252    });

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.