(function (global, $) { //es5 strict mode "use strict"; /* Script on ready ---------------------------------*/ $(document).ready(function () { changeHeaderClass(); nav(); mobileMenu(); sticky_menu(); // stickyFooter(); hoverBars(); sliders(); //eventMap(); learnMoreEvents(); joinForm(); volunteer(); featuredEvents(); }); /* Script on resize ---------------------------------*/ $(window).resize(function () { changeHeaderClass(); // adjustPopupPosition(); learnMoreButtons(); }); $(document).mouseup(function (e) {}); /* Script functions ----------------------------------*/ // change header class function changeHeaderClass() { if ($(window).width() <= 610) { $("body").removeClass("is-header-desktop"); $("body").addClass("is-header-mobile"); } else { $("body").addClass("is-header-desktop"); $("body").removeClass("is-header-mobile"); } } // mobile menu function mobileMenu() { var level0 = $("#mobile-menu-trigger"); level0.click(function (e) { if ($(this).attr("aria-expanded") == "false") { $("html,body").animate({ scrollTop: 0 }, 0); $(this).attr("aria-expanded", "true"); $(this).attr("aria-label", "Close Menu"); $(this).stop().addClass("is-open"); $("#header").stop().addClass("is-mobile-open"); } else { $(this).attr("aria-expanded", "false"); $(this).attr("aria-label", "Open Menu"); $(this).stop().removeClass("is-open"); $("#header").stop().removeClass("is-mobile-open"); } }); } // nav function nav() { if ($(window).width() > 768) { $(".nav") .on("mouseenter focus", ".level-1-trigger", function (e) { var el = $(this); el.toggleClass("has-focus"); el.parents(".has-dropdown-menu").attr("aria-expanded", "true"); el.siblings(".dropdown-menu").attr("aria-hidden", "false"); }) .on("mouseleave blur", ".level-1-trigger", function (e) { var el = $(this); el.toggleClass("has-focus"); setTimeout(function () { if ( el.siblings(".dropdown-menu").attr("data-has-focus") !== "true" ) { el.parents(".has-dropdown-menu").attr("aria-expanded", "false"); el.siblings(".dropdown-menu").attr("aria-hidden", "true"); } }, 100); }) .on("mouseenter focusin", ".dropdown-menu", function (e) { var el = $(this); el.attr("data-has-focus", "true"); el.attr("aria-hidden", "false"); }) .on("mouseleave focusout", ".dropdown-menu", function (e) { var el = $(this); setTimeout(function () { if (el.find(":focus").length === 0) { el.attr("data-has-focus", "false"); el.attr("aria-hidden", "true"); if (el.siblings(".level-1-trigger.has-focus").length === 0) { el.parents(".has-dropdown-menu").attr("aria-expanded", "false"); el.siblings(".dropdown-menu").attr("aria-hidden", "true"); } } }, 100); }); } } function sticky_menu() { var stickyHeader = $("#header"); var body = $("body"); let hOffset = ""; if ($(window).width() > 610) { hOffset = "-105"; } else { hOffset = "-70"; } if (stickyHeader.length) { stickyHeader.wrap('
${stateFullName}
${ this.eventsCount === 0 ? "No Events Currently Scheduled" : `${this.eventsCount} events in the next month` } `; return stateToolTip; } else { const stateToolTip = `
${this.eventName}
`; return stateToolTip; } }, }, series: [ { name: "Basemap", borderColor: "#FFFFFF", color: "#dcddde", nullColor: "#dcddde", showInLegend: false, states: { hover: { color: "#dc2633", }, }, data: USMapStates, zIndex: 1, }, { type: "mappoint", name: "Upcoming Events", data: parsedEventsData, states: { hover: { brightness: 0, }, }, cursor: "pointer", marker: { symbol: "circle", radius: 6, fillColor: "#213875", }, cluster: { enabled: true, allowOverlap: false, layoutAlgorithm: { type: 'grid', gridSize: 80, }, marker: { symbol: 'circle', fillColor: '#213875', radius: 15, }, animation: false, zones: [{ from: 1, to: 5, marker: { radius: 15, fillColor: '#213875' } }, { from: 6, to: 20, marker: { radius: 17, fillColor: '#213875' } }, { from: 21, to: 1000, marker: { radius: 20, fillColor: '#213875' } }] }, point: { events: { click: function () { if (!this.eventName) { return; } const popup = $("#popup"); const $eventsMapChart = $("#events-map-chart"); const offset = $eventsMapChart.offset(); const height = $eventsMapChart.outerHeight(); const popupHeight = popup.outerHeight(); const popupHeightValue = { height: popupHeight > height ? height : "unset", }; const timezoneHTML = this.timezone ? `
${this.timezone}
` : ''; const descriptionHTML = this.description ? `${this.description}
` : ''; popup.html(`${this.date}
${this.time}
${timezoneHTML}${this.venue}
${descriptionHTML} Get Tickets `); popup.css({ display: "block", top: offset.top, left: offset.left, ...popupHeightValue, }); const isActive = popup.css("display") === "block"; if (isActive) { $(".highcharts-point.active-event-dot").removeClass( "active-event-dot" ); $(`.highcharts-map-series path`).css({ fill: "", }); this.graphic.addClass("active-event-dot"); $( `.highcharts-map-series path:not(.highcharts-key-us-${this.stateCode})` ).css({ fill: "#edeeee", }); } else { this.graphic.removeClass("active-event-dot"); } const stateCode = this.stateCode.toLowerCase(); const currentStateBoundary = eventMapChart.series[0].points.find((state) => state["hc-key"].includes(`us-${stateCode.toLowerCase()}`) ); const stateXCenter = currentStateBoundary.bounds.midX; const stateYCenter = currentStateBoundary.bounds.midY; const stateWidthHeight = Math.max( currentStateBoundary.bounds.x2 - currentStateBoundary.bounds.x1, currentStateBoundary.bounds.y2 - currentStateBoundary.bounds.y1 ); const zoomValue = stateWidthHeight / 10000 + 0.1; eventMapChart.mapZoom(100); eventMapChart.mapZoom(zoomValue, stateXCenter, stateYCenter); }, }, }, zIndex: 2, }, ], }); const screenWidth = window.innerWidth; if (screenWidth < 768) { eventMapChart.series[1].update( { marker: { radius: 7, symbol: "circle", fillColor: "#213875", }, }, false ); eventMapChart.redraw(); } $(document).on("click", function (event) { const popup = $("#popup"); const statePopup = $("#state-info-popup"); const popupCloseButton = $(event.target).closest('.event__close-btn'); const isClickInsidePopup = popup.has(event.target).length > 0 && popupCloseButton.length === 0; const isClickOnEventDot = $(event.target).hasClass("highcharts-point"); const isClickOnSelect = $(event.target).closest(".learn-more__select").length > 0; const statePopupCloseButton = $(event.target).closest('.state-info-popup__close-btn'); const isClickOnStatePopup = statePopup.has(event.target).length > 0 && statePopupCloseButton.length === 0; if ( !isClickInsidePopup && !isClickOnEventDot && !isClickOnSelect && !isClickOnStatePopup ) { popup.hide(); statePopup.hide(); $(".highcharts-point.active-event-dot").removeClass("active-event-dot"); $(`.highcharts-map-series path`).css({ fill: "", }); } }); $(".highcharts-map-series path.highcharts-point").on( "click", function (event) { const clickedElement = $(this); const allClasses = clickedElement.attr("class").split(" "); const matchingClass = allClasses.find((className) => className.startsWith("highcharts-key-us-") ); if (!matchingClass) { return; } const stateName = matchingClass ? matchingClass.replace("highcharts-key-us-", "") : null; focusOnState(stateName); } ); $(".featured-events__select").change(function () { const selectedState = $(this).val(); focusOnState(selectedState); }); $(".featured-events__custom-select__options span").click(function () { const selectedStateValue = $(this).attr('data-value'); const selectedStateText = $(this).text(); $('.featured-events__custom-select .selected-option').text(selectedStateText); $('.featured-events__custom-select .selected-option').attr('data-value', selectedStateValue); $('.featured-events__custom-select__options span.active').removeClass('active'); $(".featured-events__custom-select__options").hide(); $(this).addClass('active'); focusOnState(selectedStateValue); }); $(".featured-events__custom-select").click(function() { $(".featured-events__custom-select__options").toggle(); }); $('.highcharts-cluster-point').hover( function() { $('.highcharts-tooltip').hide(); }, function() { $('.highcharts-tooltip').show(); } ); function focusOnState(selectedState) { if (selectedState === "all") { $(`.highcharts-map-series path`).css({ fill: "", }); eventMapChart.mapZoom(100); return; } $(`.highcharts-map-series path`).css({ fill: "", }); $( `.highcharts-map-series path:not(.highcharts-key-us-${selectedState})` ).css({ fill: "#edeeee", }); const currentStateBoundary = eventMapChart.series[0].points.find( (state) => state["hc-key"].includes(`us-${selectedState.toLowerCase()}`) ); const stateXCenter = currentStateBoundary.bounds.midX; const stateYCenter = currentStateBoundary.bounds.midY; const stateWidthHeight = Math.max( currentStateBoundary.bounds.x2 - currentStateBoundary.bounds.x1, currentStateBoundary.bounds.y2 - currentStateBoundary.bounds.y1 ); const zoomValue = stateWidthHeight / 10000 + 0.1; eventMapChart.mapZoom(100); eventMapChart.mapZoom(zoomValue, stateXCenter, stateYCenter); showStatePopup(selectedState); } } const showStatePopup = (selectedState) => { const activeState = perStateEvents.find( (state) => state.state === selectedState ); if (perStateEvents.length === 0 || !activeState) { $("#state-info-popup").hide(); return; } const activeStateEventsHTML = activeState.events.map((stateEvents) => { return `${stateEvents.cityState}
${stateEvents.date} | ${stateEvents.time}
More Info${event.date} | ${event.time}
${event.timezone}