PageSourceSearch

https://circlesconference.com/wp-content/themes/circlescocollective-2024/js/init.js?1787344062

js circlesconference.com collected 2026-09-24 18:25:09 UTC 48,240 bytes, 1,436 lines download raw bytes

1
2function writeEmail(contact, email, emailHost) {
3  document.write("<a href=" + "&#109a&#105l" + "&#116&#111:" + email + "@" + emailHost+ "?Subject=Panhan%20Creative%20Agency%20Project%20Request&Body=How%20can%20Panhan%20Creative%20help%20you%3F>" + contact + "@" + emailHost+"</a>");
4}
5
6jQuery(document).ready(function ($) {
7 
8 
9    $('.slick-center').slick({
10		centerMode: true,
11		centerPadding: '10%',
12		slidesToShow: 1,
13    prevArrow: '<a href="javascript:void(0)" class="video-slick-prev center-v"><svg viewBox="0 0 89.94 39.51"><path class="white" d="M11.58,22.39h38.02c2.24,0,34.94.95,37.9.12,1.77-.36,3.07-2.36,2.12-4.49-1.06-2.6-8.62-1.77-13.22-1.77-12.28,0-24.56-.47-37.07-.47l-28.45.23c2.36-4.49,12.99-11.81,8.14-15.23-2.95-2.24-4.61.95-5.67,2.13C9.1,7.74,5.68,11.99,1.78,17.07c-4.72,6.26.47,5.67,9.21,13.46,1.65,1.54,8.14,8.27,8.97,8.62,2.36,1.18,4.72-.71,4.49-3.19-.23-3.07-12.28-12.4-12.87-13.58h0Z"/></svg></a>',
14    nextArrow: '<a href="javascript:void(0)" class="video-slick-next center-v"><svg viewBox="0 0 89.94 39.51"><path class="white" d="M78.36,17.12h-38.02c-2.24,0-34.94-.95-37.9-.12-1.77.36-3.07,2.36-2.12,4.49,1.06,2.6,8.62,1.77,13.22,1.77,12.28,0,24.56.47,37.07.47l28.45-.23c-2.36,4.49-12.99,11.81-8.14,15.23,2.95,2.24,4.61-.95,5.67-2.13,4.25-4.84,7.68-9.09,11.57-14.17,4.72-6.26-.47-5.67-9.21-13.46-1.65-1.54-8.14-8.27-8.97-8.62-2.36-1.18-4.72.71-4.49,3.19.23,3.07,1"/></svg></a>',
15		responsive: [
16			{
17				breakpoint: 768,
18				settings: {
19					centerMode: true,
20					centerPadding: '6%',
21					slidesToShow: 1
22				}
23			},
24			{
25				breakpoint: 480,
26				settings: {
27					centerMode: true,
28					centerPadding: '5%',
29					slidesToShow: 1
30				}
31			}
32		]
33	});
34
35    $('.flex-gallery').each(function() {
36        $(this).magnificPopup({
37            delegate: 'a.popup-link',
38            type: 'image',
39            gallery: {
40                enabled: true,
41                navigateByImgClick: true,
42                preload: [0,1] // Preload previous/next
43            }
44        });
45    });
46
47    /**
48    *
49    *     Links to a map image anywhere on the page open in a gallery popup
50    *     Matches any image filename containing "map" — Map-Conference.webp,
51    *     Map-Workshops.webp, full-map.webp, etc.
52    *
53    */
54
55    var mapLinkPattern = /\/[^\/]*map[^\/]*\.(webp|jpe?g|png|gif)(\?.*)?$/i;
56    var $mapLinks = $('a[href]').filter(function() {
57        return mapLinkPattern.test(this.href);
58    });
59
60    if ($mapLinks.length) {
61        // One entry per unique map, so the arrows cycle each one once even when
62        // the same map is linked more than once on a page (body + footer).
63        var mapItems = [];
64        var mapItemIndex = {};
65
66        $mapLinks.each(function() {
67            if (!(this.href in mapItemIndex)) {
68                mapItemIndex[this.href] = mapItems.length;
69                mapItems.push({
70                    src: this.href,
71                    title: $(this).attr('title') || $.trim($(this).text())
72                });
73            }
74        });
75
76        $mapLinks.off('click.mapPopup').on('click.mapPopup', function(e) {
77            e.preventDefault();
78            $.magnificPopup.open({
79                items: mapItems,
80                type: 'image',
81                preloader: false,
82                removalDelay: 160,
83                mainClass: 'mfp-fade',
84                gallery: {
85                    enabled: mapItems.length > 1,
86                    navigateByImgClick: true,
87                    preload: [0,1]
88                }
89            }, mapItemIndex[this.href]);
90        });
91    }
92
93
94        /**
95	*
96	*     Tabs and content
97	*
98	*/
99
100
101    if ($('body').hasClass('page-template-page-day-schedule')) {
102
103    // --------------------------
104    // Day-level tabs
105    // --------------------------
106    $('.tab-container > .tabs li a').on('click', function (e) {
107        e.preventDefault();
108
109        var tab_id = $(this).data('tab');
110
111        // Toggle day tabs
112        $('.tab-container > .tabs li').removeClass('active');
113        $(this).parent().addClass('active');
114
115        // Show correct day content
116        $('.tab-container > .tab-content').removeClass('active').addClass('hidden-div');
117        $('#' + tab_id).addClass('active').removeClass('hidden-div');
118
119        // Inside that day: default to DESIGN (or first subtab)
120        var $dayContent = $('#' + tab_id);
121        var $subTabs = $dayContent.children('ul.tabs');
122        if ($subTabs.length) {
123        var $designLink = $subTabs.find('a[data-tab$="-design"]').first();
124        var $firstLink  = $subTabs.find('li:first-child a');
125        var $linkToClick = $designLink.length ? $designLink : $firstLink;
126        $linkToClick.trigger('click');
127        }
128    });
129
130    // --------------------------
131    // Subtabs (Design / Film)
132    // --------------------------
133    $('.tab-container').on('click', '.tab-content ul.tabs li a', function (e) {
134        e.preventDefault();
135
136        var $subTabs = $(this).closest('ul.tabs');
137        var tab_id   = $(this).data('tab');
138        var $dayContent = $(this).closest('.tab-content'); // current day wrapper
139
140        // Toggle subtab active
141        $subTabs.find('li').removeClass('active');
142        $(this).parent().addClass('active');
143
144        // Show correct subtab content inside this day only
145        $dayContent.children('.tab-content').removeClass('active').addClass('hidden-div');
146        $('#' + tab_id).addClass('active').removeClass('hidden-div');
147    });
148
149    // --------------------------
150    // Auto-select today’s day tab if it exists
151    // --------------------------
152    var todaySelected = false;
153    (function selectTodayTab() {
154        var today = new Date();
155        var weekday = today.toLocaleDateString('en-US', { weekday: 'long' }); // e.g. "Tuesday"
156
157        // Look for a tab link that contains today's weekday
158        var $todayLink = $('.tab-container > .tabs li a').filter(function () {
159        return $(this).text().trim().startsWith(weekday);
160        });
161
162        if ($todayLink.length) {
163        $todayLink.trigger('click'); // simulate click to activate day + default subtab
164        todaySelected = true;
165        }
166    })();
167
168    // --------------------------
169    // Initial load defaults (only if no today tab)
170    // --------------------------
171    if (!todaySelected) {
172        (function initDesignDefault() {
173        var $firstDay = $('.tab-container > .tab-content.active').first();
174        if (!$firstDay.length) {
175            $firstDay = $('.tab-container > .tab-content').first().addClass('active').removeClass('hidden-div');
176            var firstDayId = $firstDay.attr('id');
177            $('.tab-container > .tabs a[data-tab="' + firstDayId + '"]').parent().addClass('active');
178        }
179
180        var $subTabs = $firstDay.children('ul.tabs');
181        if ($subTabs.length) {
182            var $designLink = $subTabs.find('a[data-tab$="-design"]').first();
183            var $firstLink  = $subTabs.find('li:first-child a');
184            var $linkToClick = $designLink.length ? $designLink : $firstLink;
185            $linkToClick.trigger('click');
186        }
187        })();
188    }
189
190    // --------------------------
191    // Hide past sessions only for today's date
192    // but keep current slot visible until next session starts
193    // --------------------------
194    (function hidePastSessionsForToday() {
195    var now = new Date();
196    var nowCST = new Date(now.toLocaleString("en-US", { timeZone: "America/Chicago" }));
197
198    // Build today's YYYY-MM-DD in CST
199    var todayDateStr = nowCST.toLocaleDateString('en-CA', { timeZone: 'America/Chicago' }); // e.g. "2025-09-13"
200
201    // Look for a tab that matches today's date
202    var $todayTab = $('.tab-container > .tabs li a').filter(function () {
203        var tabId = $(this).data('tab'); // e.g. "tab-2025-09-13"
204        return tabId && tabId.indexOf(todayDateStr) !== -1;
205    });
206
207    if ($todayTab.length) {
208        var todayTabId = $todayTab.data('tab');
209        var $todayContent = $('#' + todayTabId);
210
211        var $rows = $todayContent.find('.schedule-row');
212        var times = [];
213
214        // Collect times
215        $rows.each(function () {
216        var $row = $(this);
217        var t = $row.find('.schedule-time').text().trim();
218        if (t) {
219            var dt = new Date(todayDateStr + ' ' + t);
220            times.push({ row: $row, time: dt });
221        }
222        });
223
224        // Sort by time
225        times.sort((a, b) => a.time - b.time);
226
227        // Walk through and hide rows that ended before now
228        for (var i = 0; i < times.length; i++) {
229        var start = times[i].time;
230        var end = (i + 1 < times.length) ? times[i + 1].time : null;
231
232        if (end) {
233            // Hide if the slot fully ended before now
234            if (end <= nowCST) {
235            times[i].row.hide();
236            }
237        } else {
238            // Last slot of the day: hide only if it's fully past
239            if (start < nowCST) {
240            // Let it stay visible until end-of-day, if you want:
241            // times[i].row.hide();
242            }
243        }
244        }
245    }
246    })();
247
248
249    } else {
250    // --------------------------
251    // Default handler for other pages
252    // --------------------------
253    $('.tab-container .tabs li a').on('click', function() {
254        var $parentContainer = $(this).closest('.tab-container');
255        var tab_id = $(this).data('tab');
256
257        $parentContainer.find('.tabs li').removeClass('active');
258        $(this).parent().addClass('active');
259
260        $parentContainer.find('.tab-content').removeClass('active').addClass('hidden-div');
261        $parentContainer.find('#' + tab_id).addClass('active').removeClass('hidden-div');
262    });
263    }
264
265
266	/**
267	*
268	*     Tabs/Content show and hide btn
269	*
270	*/
271
272    $('.schedule-row .btn-show-more').on('click', function() {
273        var $this = $(this);
274        var isExpanded = $this.hasClass('expanded');
275    
276        // Toggle SVG and 'expanded' class
277        $this.html(isExpanded ? 
278            '<svg viewBox="0 0 62.5 59.38"><path class="main-color" d="M28.12,26.56H3.12c-1.73,0-3.12,1.4-3.12,3.12s1.4,3.12,3.12,3.12h25v23.44c0,1.73,1.4,3.12,3.12,3.12s3.12-1.4,3.12-3.12v-23.44h25c1.73,0,3.12-1.4,3.12-3.12s-1.4-3.12-3.12-3.12h-25V3.12c0-1.73-1.4-3.12-3.12-3.12s-3.12,1.4-3.12,3.12v23.44Z"/></svg>' :
279            '<svg viewBox="0 0 62.5 6.25"><path class="main-color" d="M3.12,0C1.4,0,0,1.4,0,3.12s1.4,3.12,3.12,3.12h56.25c1.73,0,3.12-1.4,3.12-3.12s-1.4-3.12-3.12-3.12H3.12Z"/></svg>'
280        ).toggleClass('expanded');
281    
282        // Toggle hidden content within the same schedule-row
283        $this.closest('.schedule-row').find('.schedule-hidden').toggle();
284    });
285
286    $('.sold-out select').prop('disabled', true).css('pointer-events', 'n
286one').css('opacity', '0.5');
287    
288    $('.popup-video').magnificPopup({
289        type: 'iframe',
290        preloader: false,
291        removalDelay: 160,
292        fixedContentPos: false,
293        mainClass: 'mfp-fade',
294        iframe: {
295            patterns: {
296                youtube: {
297                    index: 'youtube.com/',
298                    id: 'v=',
299                    src: 'https://www.youtube.com/embed/%id%?autoplay=1&mute=1'
300                },
301                youtu_be: {
302                    index: 'youtu.be/',
303                    id: null,
304                    src: 'https://www.youtube.com/embed/%id%?autoplay=1&mute=1'
305                },
306                vimeo: {
307                    index: 'vimeo.com/',
308                    id: '/',
309                    src: 'https://player.vimeo.com/video/%id%?autoplay=1'
310                }
311            }
312        }
313    });
314
315    // Check for hash like #video=123456789
316    var hash = window.location.hash;
317    if (hash && hash.startsWith("#video=")) {
318        var videoId = hash.replace("#video=", "");
319
320        // Open Vimeo popup directly
321        $.magnificPopup.open({
322            items: {
323                src: 'https://player.vimeo.com/video/' + videoId + '?autoplay=1'
324            },
325            type: 'iframe',
326            mainClass: 'mfp-fade'
327        });
328    }
329
330
331    var videoId = new URLSearchParams(window.location.search).get('video');
332    if (videoId) {
333        var $target = $('.popup-video[data-video="' + videoId + '"]');
334        if ($target.length) {
335        setTimeout(function () {
336            $target.trigger('click');
337        }, 300);
338        }
339    }
340
341	$('.count').each(function () {
342	    $(this).prop('Counter',0).animate({
343	        Counter: $(this).text()
344	    }, {
345	        duration: 4000,
346	        easing: 'swing',
347	        step: function (now) {
348	            $(this).text(Math.ceil(now));
349	        }
350	    });
351	});
352
353	$('body').on('click touchstart', function ()  {var videoElement = document.getElementsByClassName('inlinevideo');if (videoElement.playing) {} else {$('.inlinevideo').trigger('play');}});		
354
355	$("a.anchorLink").anchorAnimate();
356	$("li.anchorLink a").anchorAnimate();
357
358	if(window.matchMedia("(max-width: 767px)").matches){
359	} else{
360		$('.pricing-plans, .schedule-program').each(function(){  
361			var highestBox = 0;
362			$('.panel', this).each(function(){
363			if($(this).height() > highestBox) {
364			  highestBox = $(this).height(); 
365			}
366			});  
367			$('.panel',this).height(highestBox);
368		});		
369	}
370
371	$("a.btn-1").click(function() {
372		$("#input_14_183").val("$960");
373	});
374	$("a.btn-2").click(function() {
375		$("#input_14_183").val("$2,500");
376	});
377	$("a.btn-3").click(function() {
378		$("#input_14_183").val("$3,500");
379	});
380	$("a.btn-4").click(function() {
381		$("#input_14_183").val("$4,500");
382	});
383  
384    $('#btnMenu').off('click').on('click', function() {
385        $('.overlay-menu').stop(true, true).slideToggle();
386    });
387
388    $('#btnClose, .menu-links a').off('click').on('click', function() {
389        $('.overlay-menu').stop(true, true).slideToggle();
390    });
391
392	$( "#btnThursday" ).click(function() {
393	  $( "#divThursday" ).show();
394	  $( "#divFriday" ).hide();
395	  $( "#divWednesday" ).hide();
396	  $( "#btnThursday" ).addClass('active');
397	  $( "#btnFriday" ).removeClass('active');
398	  $( "#btnWednesday" ).removeClass('active');
399	});
400	$( "#btnFriday" ).click(function() {
401	  $( "#divThursday" ).hide();
402	  $( "#divFriday" ).show();
403	  $( "#divWednesday" ).hide();
404	  $( "#btnThursday" ).removeClass('active');
405	  $( "#btnFriday" ).addClass('active');
406	  $( "#btnWednesday" ).removeClass('active');
407	});
408	$( "#btnWednesday" ).click(function() {
409	  $( "#divThursday" ).hide();
410	  $( "#divFriday" ).hide();
411	  $( "#divWednesday" ).show();
412	  $( "#btnThursday" ).removeClass('active');
413	  $( "#btnFriday" ).removeClass('active');
414	  $( "#btnWednesday" ).addClass('active');
415	});
416
417    $( "#btnDesignWKSPS" ).click(function() {
418        $( "#divDesignWKSPS" ).show();
419        $( "#divFilmWKSPS" ).hide();
420        $( "#btnDesignWKSPS" ).addClass('active');
421        $( "#btnFilmWKSPS" ).removeClass('active');
422      });
423      $( "#btnFilmWKSPS" ).click(function() {
424        $( "#divDesignWKSPS" ).hide();
425        $( "#divFilmWKSPS" ).show();
426        $( "#btnDesignWKSPS" ).removeClass('active');
427        $( "#btnFilmWKSPS" ).addClass('active');
428      });
429  
430
431    // 👇 Add this right below that
432    if (window.location.hash === "#FilmWorkshops") {
433        $("#btnFilmWKSPS").trigger("click");
434        setTimeout(() => {
435            const target = document.querySelector("#Tracks");
436            if (target) target.scrollIntoView({ behavior: "smooth" });
437        }, 100);
438    }
439
440      
441    /**
442     *
443     *     JS to make sidebars same height (non-mobile only)
444     *
445     */
446
447    function adjustSidebarHeight() {
448        // Skip on mobile (screen width 767px or less)
449        if (window.innerWidth <= 767) return;
450
451        var mainHeight = $(".main-registration").outerHeight();
452        var sidebarHeight = $(".sidebar-registration").outerHeight();
453
454        if (mainHeight > sidebarHeight) {
455            $(".sidebar-registration").css("height", mainHeight + "px");
456        }
457    }
458
459    // Run on page load
460    adjustSidebarHeight();
461
462    // Run on window resize to handle dynamic content
463    $(window).resize(function () {
464        adjustSidebarHeight();
465    });
466
467    // Run after images or dynamic content loads
468    $(window).on("load", function () {
469        adjustSidebarHeight();
470    });
471
472 
473     /**
474     *
475     *     SHOW HIDE WORKSHOP CONFLICTS
476     *
477     */
478
479// Define conflict rules for workshops (existing + new film track conflicts)
480const conflictRules = [
481    // 🎨 Design Track Conflicts
482    { group: ["#input_15_181", "#input_15_185", "#input_15_196", "#input_32_181", "#input_32_185", "#input_32_196"] },
483    { group: ["#input_15_182", "#input_15_202", "#input_15_185", "#input_32_182", "#input_32_202", "#input_32_185"] },
484    { group: ["#input_15_183", "#input_15_186", "#input_15_198", "#input_32_183", "#input_32_186", "#input_32_198"] },
485    { group: ["#input_15_184", "#input_15_186", "#input_15_200", "#input_32_184", "#input_32_186", "#input_32_200"] },
486
487    // 🎬 Film Track Conflicts
488    { group: ["#input_15_210", "#input_15_228", "#input_15_220", "#input_32_210", "#input_32_228", "#input_32_220"] }, // 8:30 AM - Cannot be taken together
489    { group: ["#input_15_212", "#input_15_228", "#input_15_222", "#input_32_212", "#input_32_228", "#input_32_222"] }, // 10:30 AM - Cannot be taken together
490    { group: ["#input_15_214", "#input_15_230", "#input_15_224", "#input_32_214", "#input_32_230", "#input_32_224"] }, // 1:30 PM - Cannot be taken together
491    { group: ["#input_15_216", "#input_15_230", "#input_15_226", "#input_32_216", "#input_32_230", "#input_32_226"] }  // 3:30 PM - Cannot be taken together
492];
493
494// 🛠️ Function to handle conflicts
495function handleWorkshopConflicts(selectedWorkshop) {
496    const selectedValue = $(selectedWorkshop).val();
497
498    console.log(`Handling conflicts for: ${selectedWorkshop} | Selected Value: ${selectedValue}`);
499
500    // ✅ Preserve existing disabled states for non-conflicting fields
501    $(".gfield_price select").each(function () {
502        const $this = $(this);
503        if (!$this.prop("disabled")) {
504            $this.closest("li").removeClass("disabled");
505        }
506    });
507
508    conflictRules.forEach((rule) => {
509        if (rule.group.includes(selectedWorkshop)) {
510            rule.group.forEach((workshop) => {
511                if (workshop !== selectedWorkshop) {
512                    const $workshop = $(workshop);
513
514                    if ($workshop.length) {
515                        console.log(`Checking conflict for: ${workshop}`);
516
517                        // Apply disable logic based on the selected value
518                        const isDisabled = selectedValue === "1|97" || selectedValue === "1|197";
519
520                        // Only disable if visible and not already disabled
521                        if ($workshop.closest(".gfield_price").is(":visible") && !$workshop.prop("disabled")) {
522                            $workshop
523                                .val(isDisabled ? "0|0" : $workshop.val())
524                                .prop("disabled", isDisabled)
525                                .closest("li")
526                                .toggleClass("disabled", isDisabled);
527                        }
528
529                        // ✅ If the selected workshop is set back to "0|0", enable previously disabled fields
530                        if (!isDisabled) {
531                            $workshop.prop("disabled", false).closest("li").removeClass("disabled");
532                        }
533                    }
534                }
535            });
536        }
537    });
538}
539
540// 🛠️ Function to reinitialize event handlers for .gfield_price
541function initializeWorkshopHandlers() {
542    $(".gfield_price select").off("change").on("change", function () {
543        console.log(`Workshop changed: ${this.id}`);
544        handleWorkshopConflicts(`#${this.id}`);
545    });
546}
547
548function handleFormChanges(formId) {
549    console.log(`Form ${formId}_204 changed:`, $(`#input_${formId}_204`).val());
550
551    const selectedTrack = $(`#input_${formId}_204`).val();
552
553    // ✅ Reset all fields to "0|0" before showing relevant ones
554    $(".gfield_price select").each(function () {
555        $(this).val("0|0").prop("disabled", true).hide().closest("li").addClass("disabled");
556    });
557
558    if (selectedTrack === "Design" || selectedTrack === "Both") {
559        $(".gfield_price select").each(function () {
560            const workshopId = $(this).attr("id");
561
562            if (
563                [`#input_${formId}_181`, `#input_${formId}_185`, `#input_${formId}_196`,
564                 `#input_${formId}_182`, `#input_${formId}_202`, `#input_${formId}_185`,
565                 `#input_${formId}_183`, `#input_${formId}_186`, `#input_${formId}_198`,
566                 `#input_${formId}_184`, `#input_${formId}_186`, `#input_${formId}_200`
567                ].includes(`#${workshopId}`)
568            ) {
569                $(this).show().prop("disabled", false).closest("li").removeClass("disabled");
570            }
571        });
572    }
573
574    if (selectedTrack === "Film" || selectedTrack === "Both") {
575        $(".gfield_price select").each(function () {
576            const workshopId = $(this).attr("id");
577
578            if (
579                [`#input_${formId}_210`, `#input_${formId}_228`, `#input_${formId}_220`,
580                 `#input_${formId}_212`, `#input_${formId}_228`, `#input_${formId}_222`,
581                 `#input_${formId}_214`, `#input_${formId}_230`, `#input_${formId}_224`,
582                 `#input_${formId}_216`, `#input_${formId}_230`, `#input_${formId}_226`
583                ].includes(`#${workshopId}`)
584            ) {
585                $(this).show().prop("disabled", false).closest("li").removeClass("disabled");
586            }
587        });
588    }
589
590    setTimeout(() => {
591        initializeWorkshopHandlers();
592    }, 100);
593}
594
595// Attach events to both #input_15_204 and #input_32_204
596$("#input_15_204, #input_32_204").off("change").on("change", function () {
597    handleFormChanges(this.id.split("_")[1]); // Extracts "15" or "32" and passes to function
598});
599
600// 🛠️ Watch for changes in both forms
601["15", "32"].forEach((formId) => {
602    const formWrapper = document.getElementById(`gform_wrapper_${formId}`);
603    if (formWrapper) {
604        const observer = new MutationObserver(() => {
605            console.log(`Visibility change detected in form ${formId}, reinitializing handlers...`);
606            initializeWorkshopHandlers();
607        });
608
609        observer.observe(formWrapper, { childList: true, subtree: true, attributes: true });
610    }
611});
612
613// Initialize handlers
614initializeWorkshopHandlers();
615    
616        /**
617     *
618     *     SHOW X on INPUT & CLEAR
619     *
620     */
621
622    // Function to check the value of #s and show/hide the clear button
623    function checkInputValue() {
624        if ($('#s').length && $('#s').val().trim() !== '') {
625            $('.btn-clear-search').removeClass('hidden-div');
626        } else {
627            $('.btn-clear-search').addClass('hidden-div');
628        }
629    }
630
631    // Check the input value on page load
632    if ($('#s').length) {
633        checkInputValue();
634    }
635
636    // Monitor input value changes
637    $('#s').on('input', function() {
638        checkInputValue();
639    });
640
641    // Clear the input and hide the clear button
642    $('.btn-clear-search').on('click', function () {
643        $('#s').val('');
644        $(this).addClass('hidden-div');
645        console.log('Clear button clicked. Input cleared.');
646    });
647    
648    // Preselect Sponsors
649
650    $('.btn-main-1').click(function() {
651        $('#input_11_183').val('Package I - $1,000');
652    });
653    
654    $('.btn-main-2').click(function() {
655        $('#input_11_183').val('Package II - $3,000');
656    });
657    
658    $('.btn-main-3').click(function() {
659        $('#input_11_183').val('Package III - $7,500');
660    });
661    
662    $('.btn-main-4').click(function() {
663        $('#input_11_183').val('Package IV - $12,500');
664    });
665    
666    $('.btn-main-5').click(function() {
667        $('#input_11_183').val('Package V - $18,500');
668    });
669    
670    $('.btn-main-6').click(function() {
671        $('#input_11_183').val('Rockstar - $25,000');
672    });
673    
674    $('.btn-add-1').click(function() {
675        $('#input_11_183').val('Coffee - $5,500');
676    });
677    
678    $('.btn-add-2').click(function() {
679        $('#input_11_183').val('Drinks and Water - $3,500');
680    });
681    
682    $('.btn-add-3').click(function() {
683        $('#input_11_183').val('Food and Snacks - $6,000');
684    });
685    
686    $('.btn-add-4').click(function() {
687        $('#input_11_183').val('VIP Dinner - $5,000');
688    });
689    
690    $('.btn-add-5').click(function() {
691        $('#input_11_183').val('Photobooth - $2,500');
692    });
693    
694    $('.btn-add-6').click(function() {
695        $('#input_11_183').val('Video Sessions - $4,000');
696    });
697    
698    $('.btn-add-7').click(function() {
699        $('#input_11_183').val('Lanyards - $5,000');
700    });
701    
702    $('.btn-add-8').click(function() {
703        $('#input_11_183').val('Booze - $6,000');
704    });
705    
706    $('.btn-add-9').click(function() {
707        $('#input_11_183').val('Biz - $650');
708    });
709    
710    $('.btn-add-10').click(function() {
711        $('#input_11_183').val('VIP Pass - $650');
712    });
713    
714    $('.btn-add-11').click(function() {
715        $('#input_11_183').val('After Party - $6,000');
716    });
717    
718    $('.btn-add-12').click(function() {
719        $('#input_11_183').val('Kickoff Party - $3,500');
720    });
721    
722    $('.btn-add-13').click(function() {
723        $('#input_11_183').val('Closing Party - $2,000');
724    });
725    
726    $('.btn-add-14').click(function() {
727        $('#input_11_183').val('Coffee Mugs - $2,500');
728    });
729    
730    $('.btn-film-1').click(function() {
731        $('#input_11_183').val('Short Film Level I - $5,000');
732    });
733    
734    $('.btn-film-2').click(function() {
735        $('#input_11_183').val('Short Film Level II - $10,000');
736    });
737    
738
739	$('#input_1_9').on('input', function() {
740		$('#input_1_22').val($(this).val());
741		$('#input_1_34').val($(this).val());
742		$('#input_1_49').val($(this).val());
743	}); 
744
745	$('#input_3_9').on('input', function() {
746		$('#input_3_22').val($(this).val());
747		$('#input_3_34').val($(this).val());
748		$('#input_3_49').val($(this).val());
749		$('#input_3_49').val($(this).val());
750		$('#input_3_57').val($(this).val());
751		$('#input_3_65').val($(this).val());
752		$('#input_3_73').val($(this).val());
753		$('#input_3_81').val($(this).val());
754		$('#input_3_90').val($(this).val());
755		$('#input_3_98').val($(this).val());
756		$('#input_3_107').val($(this).val());
757		$('#input_3_116').val($(this).val());
758		$('#input_3_124').val($(this).val());
759		$('#input_3_132').val($(this).val());
760		$('#input_3_140').val($(this).val());
761	}); 
762
763	$('#input_4_9').on('input', function() {
764		$('#input_4_22').val($(this).val());
765		$('#input_4_34').val($(this).val());
766		$('#input_4_49').val($(this).val());
767		$('#input_4_49').val($(this).val());
768		$('#input_4_57').val($(this).val());
769		$('#input_4_65').val($(this).val());
770		$('#input_4_73').val($(this).val());
771		$('#input_4_81').val($(this).val());
772		$('#input_4_90').val($(this).val());
773		$('#input_4_98').val($(this).val());
774		$('#input_4_107').val($(this).val());
775		$('#input_4_116').val($(this).val());
776		$('#input_4_124').val($(this).val());
777		$('#input_4_132').val($(this).val());
778		$('#input_4_140').val($(this).val());
779	}); 
780
781    $('.outfit-link').on('click', function() {
782        $('.outfit-link').removeClass('active');
783        $(this).addClass('active');
784        var index = $('.outfit-link').index(this);
785        $('.outfit-panel').hide();
786        $('.outfit-panel').eq(index).fadeIn(200);
787      });
788
789    // View Past Photos button — opens marquee gallery
790    $('.view-photos-btn').on('click', function() {
791        var $gallery = $(this).siblings('.flex-gallery');
792        $gallery.find('.popup-link:first').trigger('click');
793    });
794
795    /**
796    *
797    *     /sponsors/ photo marquee — the gallery is built once from the unique
798    *     photos so the duplicated marquee tiles don't double the image count.
799    *     Shareable link: /sponsors/?gallery=photos opens on the first image,
800    *     &photo=3 opens on a specific one.
801    *
802    */
803
804    $('.sponsor-photos-wrap').each(function() {
805        var $wrap = $(this);
806        var items = [];
807        var position = {};
808
809        $wrap.find('.sponsor-photo[data-photo-index]').each(function() {
810            var key = String($(this).attr('data-photo-index'));
811            if (key in position) return;
812            position[key] = items.length;
813            items.push({ src: this.href, title: $(this).attr('title') || '' });
814        });
815
816        if (!items.length) return;
817
818        function scrollToStrip() {
819            var section = $wrap.closest('.sponsor-photos-section').get(0) || $wrap.get(0);
820            if (section && section.scrollIntoView) {
821                section.scrollIntoView({ block: 'center' });
822            }
823        }
824
825        // parkOnStrip is for the shareable links: land on the strip so closing the
826        // popup leaves the visitor watching the photos scroll, not back at the top
827        // of the page. Re-parked in afterClose because Magnific restores the scroll
828        // offset it captured on open, and images loading above can shift it.
829        function openSponsorGallery(index, parkOnStrip) {
830            $.magnificPopup.open({
831                items: items,
832                type: 'image',
833                preloader: false,
834                removalDelay: 160,
835                mainClass: 'mfp-fade',
836                gallery: {
837                    enabled: items.length > 1,
838                    navigateByImgClick: true,
839                    preload: [0,1]
840                },
841                callbacks: parkOnStrip ? { afterClose: scrollToStrip } : {}
842            }, index);
843        }
844
845        $wrap.on('click', '.sponsor-photo', function(e) {
846            e.preventDefault();
847            var key = String($(this).attr('data-photo-index'));
848            openSponsorGallery(key in position ? position[key] : 0);
849        });
850
851        $wrap.on('click', '.sponsor-view-photos', function(e) {
852            e.preventDefault();
853            openSponsorGallery(0);
854        });
855
856        // Deep link, same shape as the #video= links: /sponsors/#gallery=photos
857        // opens on the first image, /sponsors/#gallery=photos&photo=5 on the fifth.
858        // ?gallery=photos&photo=5 works too. photo=N counts positions in the ACF
859        // field, not the shuffled strip, so a link handed to a sponsor always
860        // lands on the same image.
861        var galleryParams = new URLSearchParams(
862            window.location.search.replace(/^\?/, '') + '&' + window.location.hash.replace(/^#/, '')
863        );
864
865        if (galleryParams.get('gallery') === $wrap.attr('data-gallery')) {
866            var photoParam = parseInt(galleryParams.get('photo'), 10);
867            var photoKey = String(photoParam - 1);
868            var startIndex = (photoParam > 0 && photoKey in position) ? position[photoKey] : 0;
869            setTimeout(function() {
870                scrollToStrip();
871                openSponsorGallery(startIndex, true);
872            }, 300);
873        }
874    });
875
876    // Prize product fade-up on scroll
877    var prizeImg = document.querySelector('.prize-product');
878    if (prizeImg) {
879        var prizeObserver = new IntersectionObserver(function(entries) {
880            entries.forEach(function(entry) {
881                if (entry.isIntersecting) {
882                    entry.target.classList.add('fadeIn');
883                    prizeObserver.unobserve(entry.target);
884                }
885            });
886        }, { threshold: 0.2 });
887        prizeObserver.observe(prizeImg);
888    }
889
890    // Auto-rotate outfit gallery every 3s, pause on hover
891    var outfitTimer = null;
892    var outfitIndex = 0;
893    function rotateOutfit() {
894        var $links = $('.outfit-link');
895        if (!$links.length) return;
896        outfitIndex = (outfitIndex + 1) % $links.length;
897        $links.removeClass('active');
898        $links.eq(outfitIndex).addClass('active');
899        $('.outfit-panel').hide();
900        $('.outfit-panel').eq(outfitIndex).fadeIn(400);
901    }
902    function startOutfitRotation() {
903        if (outfitTimer) clearInterval(outfitTimer);
904        outfitTimer = setInterval(rotateOutfit, 3000);
905    }
906    if ($('.outfit-link').length) {
907        startOutfitRotation();
908        $('.outfits-wrap, .outfit-links').on('mouseenter', function() { clearInterval(outfitTimer); });
909        $('.outfits-wrap, .outfit-links').on('mouseleave', function() { startOutfitRotation(); });
910    }
911        
912	var clearButton = $('#clear-search-results');
913	clearButton.on('click', function(e) {
914		e.preventDefault();
915		$('#search-results').html('');
916		$('input#s').val('');
917		clearButton.hide();
918	});
919	$('input#s').on('input', function() {
920		if ($(this).val().length === 0) {
921		  clearButton.hide();
922		} else {
923		  clearButton.show();
924		}
925	});
926 
927    var pageHero = $('.page-hero');
928
929    if (pageHero.length > 0) { // Only run if .page-hero exists
930        var header = $('.header');
931        var scrollThreshold = pageHero.offset().top;
932        var pageHeroHeight = pageHero.height();
933
934        $(window).scroll(function() {
935            var windowTop = $(window).scrollTop();
936            if (windowTop >= scrollThreshold + pageHeroHeight) {
937                header.addClass('alternate');
938            } else {
939                header.removeClass('alternate');
940            }
941        });
942    }
943
944    $('.marquee').marquee({
945        duration: 40000, // Adjust as needed
946        gap: 20,         // Adjust as needed
947        delayBeforeStart: 0,
948        direction: 'left',
949        duplicated: false, // Prevents duplication
950        startVisible: true
951    });
952
953    // Handle manual gallery opening
954    $('.popup-gallery').on('click', function(e) {
955        e.preventDefault();
956        $(this).next('.speaker-gallery').magnificPopup({
957            delegate: 'a',
958            type: 'image',
959            gallery: {
960                enabled: true
961            },
962            mainClass: 'mfp-fade'
963        }).magnificPopup('open');
964    });
965
966    // Auto-open gallery by post slug in URL
967    var gallerySlug = new URLSearchParams(window.location.search).get('gallery');
968    if (gallerySlug) {
969        var $galleryTrigger = $('.popup-gallery[data-gallery="' + gallerySlug + '"]');
970        if ($galleryTrigger.length) {
971            setTimeout(function () {
972                $galleryTrigger.trigger('click');
973            }, 300);
974        }
975    }
976
977    $('.owl-carousel').owlCarousel({
978        loop: false,
979        margin: 60,
980        nav: false,
981        dots: false,
982        items: 1,
983        autoplay: false,
984        slideTransition: 'linear',
985        autoplayHoverPause: false,
986        autoHeight: true // Dynamically adjust height
987    });
988    
989    // Custom prev button
990    $('.left-owl').click(function(e) {
991        e.preventDefault();
992        if (!$(this).hasClass('arrow-disabled')) {
993            $('.owl-carousel').trigger('prev.owl.carousel', [300]); // 300ms speed for the transition
994        }
995    });
996    
997    // Custom next button
998    $('.right-owl').click(function(e) {
999        e.preventDefault();
1000        if (!$(this).hasClass('arrow-disabled')) {
1001            $('.owl-carousel').trigger('next.owl.carousel', [300]); // 300ms speed for the transition
1002        }
1003    });
1004    
1005    // Show/hide buttons based on carousel position
1006    $('.owl-carousel').on('changed.owl.carousel', function(event) {
1007        var current = event.item.index; // Current index
1008        var total = event.item.count;   // Total items
1009        
1010        // Add/remove arrow-disabled class for prev button
1011        if (current === 0) {
1012            $('.left-owl').addClass('arrow-disabled');
1013        } else {
1014            $('.left-owl').removeClass('arrow-disabled');
1015        }
1016    
1017        // Add/remove arrow-disabled class for next button
1018        if (current === total - 1) {
1019            $('.right-owl').addClass('arrow-disabled');
1020        } else {
1021            $('.right-owl').removeClass('arrow-disabled');
1022        }
1023    });
1024    
1025    // Initial check to set button visibility
1026    $('.owl-carousel').trigger('changed.owl.carousel');
1027    
1028    // Disable prev button initially
1029    $('.left-owl').addClass('arrow-disabled');
1030    
1031});
1032
1033
1034$(window).on('load', function() {
1035
1036	$('.split-image-height').equalize();
1037	$('.split-image-height-two').equalize();
1038
1039}
1039);
1040
1041
1042/**
1043 *
1044 *     Make Divs same height
1045 *
1046 */
1047
1048
1049$.fn.equalize = function(){
1050    var maxHeight = 0;
1051    this.each(function(){
1052        var $this = $(this);
1053        if($this.height() > maxHeight){maxHeight = $this.height();}
1054    });
1055
1056    return this.each(function(){
1057        $(this).height(maxHeight);
1058    });
1059};
1060
1061function traverseAndWrap(node) {
1062  if (node.nodeType === Node.TEXT_NODE) {
1063    // Wrap "$" and "&" in the desired span
1064    node.textContent = node.textContent.replace(/(\$|&)/g, '<span class="proxima bold">$1</span>');
1065  } else if (node.nodeType === Node.ELEMENT_NODE) {
1066    for (var i = 0; i < node.childNodes.length; i++) {
1067      traverseAndWrap(node.childNodes[i]);
1068    }
1069  }
1070}
1071
1072/**
1073 *
1074 *     Scroll Party Balls
1075 *
1076 */
1077
1078
1079document.addEventListener('DOMContentLoaded', function() {
1080    const options = {
1081      threshold: 0.1
1082    };
1083  
1084    const observer = new IntersectionObserver((entries, observer) => {
1085      entries.forEach(entry => {
1086        if (entry.isIntersecting) {
1087          entry.target.classList.add('animate-up');
1088          entry.target.classList.remove('animate-down');
1089        } else {
1090          entry.target.classList.remove('animate-up');
1091          entry.target.classList.add('animate-down');
1092        }
1093      });
1094    }, options);
1095  
1096    const elements = document.querySelectorAll('.text-ball, .text-paddle');
1097    elements.forEach(element => {
1098      observer.observe(element);
1099    });
1100  });
1101  
1102
1103document.addEventListener("DOMContentLoaded", function () {
1104    const typewriterEffect = (element) => {
1105        const text = element.textContent.trim(); // Get the text
1106        element.textContent = ''; // Clear text for typing effect
1107        element.style.visibility = 'visible'; // Make the element visible
1108
1109        let index = 0;
1110        const speed = 40; // Typing speed in ms
1111
1112        const type = () => {
1113            if (index < text.length) {
1114                element.textContent += text.charAt(index);
1115                index++;
1116                setTimeout(type, speed);
1117            }
1118        };
1119        type();
1120    };
1121
1122    const observer = new IntersectionObserver(
1123        (entries) => {
1124            entries.forEach((entry) => {
1125                if (entry.isIntersecting) {
1126                    typewriterEffect(entry.target);
1127                    observer.unobserve(entry.target); // Stop observing once triggered
1128                }
1129            });
1130        },
1131        { threshold: 0.1 } // Trigger when 10% visible
1132    );
1133
1134    document.querySelectorAll(".typewriter-effect").forEach((el) => {
1135        observer.observe(el);
1136    });
1137});
1138
1139
1140document.addEventListener('DOMContentLoaded', function() {
1141    const numberElements = document.querySelectorAll('.data-number');
1142
1143    if (numberElements.length === 0) return; // Exit if no elements with 'data-number' class
1144
1145    // data-final can carry more than digits — "50%", "$1,200", "3x". Animate the
1146    // number and put whatever wrapped it back on. Elements with a data-suffix
1147    // attribute render their own suffix (see the churches template), so the
1148    // parsed prefix/suffix is left off those to avoid printing it twice.
1149    function parseFinal(element) {
1150        const raw = (element.getAttribute('data-final') || '').trim();
1151        const match = raw.match(/^([^0-9-]*)(-?[0-9][0-9.,]*)([\s\S]*)$/);
1152
1153        if (!match) {
1154            return { prefix: '', suffix: '', value: 0, decimals: 0, grouped: false };
1155        }
1156
1157        const digits = match[2].replace(/,/g, '');
1158        const dot = digits.indexOf('.');
1159        const ownSuffix = element.hasAttribute('data-suffix');
1160
1161        return {
1162            prefix: ownSuffix ? '' : match[1],
1163            suffix: ownSuffix ? '' : match[3],
1164            value: parseFloat(digits) || 0,
1165            decimals: dot === -1 ? 0 : digits.length - dot - 1,
1166            grouped: match[2].indexOf(',') !== -1
1167        };
1168    }
1169
1170    function formatNumber(parts, value) {
1171        let text = parts.decimals ? value.toFixed(parts.decimals) : String(Math.floor(value));
1172
1173        if (parts.grouped) {
1174            text = Number(text).toLocaleString('en-US', {
1175                minimumFractionDigits: parts.decimals,
1176                maximumFractionDigits: parts.decimals
1177            });
1178        }
1179
1180        return text;
1181    }
1182
1183    // The "%" / "$" sits in its own span so CSS can drop it to half size on the
1184    // number's baseline. Plain numbers keep writing through textContent so the
1185    // churches template's data-suffix override still gets its hook.
1186    function renderNumber(element, parts, value) {
1187        const text = formatNumber(parts, value);
1188
1189        if (!parts.prefix && !parts.suffix) {
1190            element.textContent = text;
1191            return;
1192        }
1193
1194        element.textContent = '';
1195
1196        if (parts.prefix) {
1197            element.appendChild(affix(parts.prefix));
1198        }
1199
1200        element.appendChild(document.createTextNode(text));
1201
1202        if (parts.suffix) {
1203            element.appendChild(affix(parts.suffix));
1204        }
1205    }
1206
1207    function affix(value) {
1208        const span = document.createElement('span');
1209        span.className = 'data-number-affix';
1210        span.textContent = value;
1211        return span;
1212    }
1213
1214    function animateNumbers(element) {
1215        const parts = parseFinal(element);
1216        const finalNumber = parts.value;
1217        const duration = 500; // Faster animation duration in ms
1218        const frameRate = 30; // Target frame rate for smoother updates
1219        const startTime = performance.now();
1220        const interval = 1000 / frameRate; // Time between updates
1221
1222        function updateNumber() {
1223            const elapsed = performance.now() - startTime;
1224
1225            if (elapsed < duration) {
1226                renderNumber(element, parts, Math.random() * finalNumber);
1227                setTimeout(() => requestAnimationFrame(updateNumber), interval);
1228            } else {
1229                renderNumber(element, parts, finalNumber);
1230            }
1231        }
1232
1233        requestAnimationFrame(updateNumber);
1234    }
1235
1236    function isInViewport(element) {
1237        const rect = element.getBoundingClientRect();
1238        return rect.top < window.innerHeight && rect.bottom > 0;
1239    }
1240
1241    function onScroll() {
1242        numberElements.forEach(element => {
1243            if (isInViewport(element) && !element.classList.contains('animated')) {
1244                element.classList.add('animated');
1245                animateNumbers(element);
1246            }
1247        });
1248    }
1249
1250    window.addEventListener('scroll', onScroll);
1251    onScroll(); // Trigger animation for elements already in view on page load
1252});
1253
1254
1255
1256function copyToClipboard(input) {
1257    input.select();
1258    input.setSelectionRange(0, 99999); // For mobile devices
1259    navigator.clipboard.writeText(input.value).then(function() {
1260        let tooltip = input.nextElementSibling;
1261        tooltip.classList.add('speaker-referral-show-tooltip');
1262
1263        setTimeout(() => {
1264            tooltip.classList.remove('speaker-referral-show-tooltip');
1265        }, 1500);
1266    }).catch(function(err) {
1267        console.error('Could not copy text: ', err);
1268    });
1269}
1270
1271
1272/**
1273 * Gravity Form Speaker Role Filter
1274 * Filters field 188 ("Keynote" or "Workshop Leader") based on selected speaker (field 192)
1275 * Hides field 188 until a speaker is selected
1276 * Also injects post ID as data-id to field 192 options
1277 */
1278document.addEventListener('DOMContentLoaded', function () {
1279  const speakerField = document.querySelector('#input_12_192');
1280  const roleField = document.querySelector('#input_12_188');
1281  const roleFieldWrapper = roleField?.closest('.gfield');
1282
1283  if (!speakerField || !roleField || !window.speakerRoles) return;
1284
1285  const defaultOptions = {
1286    keynote: 'Keynote',
1287    workshop: 'Workshop Leader',
1288  };
1289
1290  // Add post IDs to speaker options
1291  for (const option of speakerField.options) {
1292    const name = option.textContent.trim();
1293    const data = window.speakerRoles[name];
1294    if (data && data.id) {
1295      option.dataset.id = data.id;
1296    }
1297  }
1298
1299  function updateRoleDropdown() {
1300    const selectedSpeaker = speakerField.value;
1301    const data = window.speakerRoles[selectedSpeaker];
1302
1303    if (!selectedSpeaker || !data) {
1304      roleField.innerHTML = '';
1305      if (roleFieldWrapper) roleFieldWrapper.style.display = 'none';
1306      return;
1307    }
1308
1309    const roles = data.roles || [];
1310    const hasSessionTitle = data.session_title && data.session_title.length > 0;
1311    const hasWorkshopTitle = data.workshop_title && data.workshop_title.length > 0;
1312
1313    const isSpeaker = roles.includes('design_speaker') || roles.includes('film_speaker');
1314    const isWorkshop = roles.includes('design_workshop_leader') || roles.includes('film_workshop_leader');
1315
1316    roleField.innerHTML = '';
1317    let hasValidOptions = false;
1318
1319    if (isSpeaker && !hasSessionTitle) {
1320      roleField.add(new Option(defaultOptions.keynote, defaultOptions.keynote));
1321      hasValidOptions = true;
1322    }
1323
1324    if (isWorkshop && !hasWorkshopTitle) {
1325      roleField.add(new Option(defaultOptions.workshop, defaultOptions.workshop));
1326      hasValidOptions = true;
1327    }
1328
1329    if (!hasValidOptions) {
1330      const opt = new Option('No roles available', '', false, false);
1331      opt.disabled = true;
1332      roleField.add(opt);
1333    }
1334
1335    if (roleFieldWrapper) roleFieldWrapper.style.display = 'block';
1336  }
1337
1338  speakerField.addEventListener('change', updateRoleDropdown);
1339  if (roleFieldWrapper) roleFieldWrapper.style.display = 'none';
1340  updateRoleDropdown();
1341});
1342
1343
1344document.addEventListener('DOMContentLoaded', function() {
1345    const header = document.querySelector('.header');
1346    const hero = document.querySelector('.page-hero');
1347    const gradient = document.querySelector('.gradient-2026-6');
1348    const darkGrey = document.querySelector('.bg-dark-grey');
1349
1350    if (!header || (!hero && !gradient && !darkGrey)) return;
1351
1352    const getTriggerOffset = () => {
1353        const heroBottom = hero ? hero.offsetTop + hero.offsetHeight : 0;
1354        const gradientTop = gradient ? gradient.offsetTop : Infinity;
1355        const darkGreyTop = darkGrey ? darkGrey.offsetTop : Infinity;
1356        return Math.min(heroBottom, gradientTop, darkGreyTop);
1357    };
1358
1359    let triggerOffset = getTriggerOffset();
1360
1361    window.addEventListener('resize', () => {
1362        triggerOffset = getTriggerOffset();
1363    });
1364
1365    window.addEventListener('scroll', () => {
1366        header.classList.toggle('alternate', window.scrollY >= triggerOffset);
1367    });
1368});
1369
1370
1371
1372(function () {
1373
1374  let sent = false;
1375
1376  const waitForBraveForm = setInterval(function () {
1377
1378    const form = document.querySelector(
1379      "#brave_form_-NTJw4Mt1oRTObIKG9HN"
1380    );
1381
1382    if (!form) return;
1383
1384    clearInterval(waitForBraveForm);
1385
1386    form.addEventListener("submit", function () {
1387      if (sent) return;
1388
1389      const emailField = form.querySelector(".brave_newsletter_emailField");
1390      const nameField  = form.querySelector(".brave_newsletter_nameField");
1391      const heardField = form.querySelector(
1392        'select[name="-Ny0m_KgrMn31NTB3gtm"]'
1393      );
1394
1395      if (!emailField || !emailField.value) return;
1396
1397      sent = true;
1398
1399      fetch("/wp-json/circles/v1/brave-to-flodesk", {
1400        method: "POST",
1401        headers: {
1402          "Content-Type": "application/json"
1403        },
1404        body: JSON.stringify({
1405          email: emailField.value.trim(),
1406          name: nameField ? nameField.value.trim() : "",
1407          heard: heardField ? heardField.value : ""
1408        })
1409      });
1410
1411    });
1412
1413  }, 300);
1414
1415})();
1416
1417
1418/**
1419 * Registration form submit button — disable + show overlay
1420 * Payment forms: "Processing payment..."
1421 * Non-payment forms: "Loading..."
1422 */
1423(function () {
1424    var paymentForms = [1, 4, 5, 8, 15, 21, 23, 24, 25, 29, 30, 37];
1425    var otherForms   = [2, 6, 16, 32];
1426    var allForms     = paymentForms.concat(otherForms);
1427
1428    allForms.forEach(function (formId) {
1429        jQuery(document).on('submit', '#gform_' + formId, function () {
1430            var isPayment = paymentForms.indexOf(formId) !== -1;
1431            var msg = isPayment ? 'PROCESSING PAYMENT...' : 'LOADING...';
1432            jQuery('.overlay-loading-text').text(msg);
1433            jQuery('.overlay-loading').fadeIn(150);
1434        });
1435    });
1436})();

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.