{"version":3,"file":"wf-map-locations.js","sources":["wf-map-locations.js"],"sourcesContent":["document.querySelectorAll(\".state-bg\").forEach((item) => {\n item.addEventListener(\"click\", function () {\n var link = this.dataset.linkTarget;\n window.location.href = link;\n });\n});\n\nfunction isSafari() {\n return /^((?!chrome|android).)*safari/i.test(navigator.userAgent);\n}\n\nif (isSafari()) {\n document.addEventListener(\"DOMContentLoaded\", function () {\n let circles = Array.from(\n document.querySelectorAll(\".map-pulse\")\n );\n\n function animate() {\n circles.forEach((circle) => {\n let opacity = parseFloat(\n getComputedStyle(circle).getPropertyValue(\"fill-opacity\").trim()\n );\n let rValue =\n 18.1249 + (43.4998 - 18.1249) * ((opacity - 0.01) / (0.31 - 0.01));\n circle.setAttribute(\"r\", rValue);\n });\n\n requestAnimationFrame(animate);\n }\n\n animate();\n });\n}\n\n// Location filtering\njQuery(document).ready(function ($) {\n var currentAreaFilter = \"\";\n var currentStateFilter = \"\";\n // Function to toggle dropdown visibility\n function toggleDropdown(dropdown) {\n $(\".custom-dropdown\").not(dropdown).find(\".dropdown-options\").hide();\n\n var optionsDiv = dropdown.find(\".dropdown-options\");\n optionsDiv.toggle();\n }\n\n function updateActiveClass() {\n $(\"#location_state_filter .option\").each(function () {\n if ($(this).data(\"value\") === currentStateFilter) {\n $(this).addClass(\"active\");\n } else {\n $(this).removeClass(\"active\");\n }\n });\n\n $(\"#area_type_filter .option\").each(function () {\n if ($(this).data(\"value\") === currentAreaFilter) {\n $(this).addClass(\"active\");\n } else {\n $(this).removeClass(\"active\");\n }\n });\n }\n\n // Click event on dropdown label to show/hide options\n $(\".custom-dropdown\").click(function () {\n var dropdown = $(this);\n toggleDropdown(dropdown);\n });\n\n // Click event on dropdown options\n $(\".custom-dropdown .option\").click(function () {\n var option = $(this);\n var dropdown = $(this).closest(\".custom-dropdown\");\n var options = dropdown.find(\".option\");\n if (options.length === 1) {\n e.preventDefault();\n return;\n }\n var dropdown = option.closest(\".custom-dropdown\");\n var value = option.data(\"value\");\n var label = option.text();\n\n // Update the text part of the dropdown label, preserving the icon\n var dropdownLabel = dropdown.find(\".dropdown-label\").first();\n dropdownLabel\n .contents()\n .first()\n .replaceWith(label + \" \");\n\n // Remove .active from all options and add it to the clicked option\n dropdown.find(\".option\").removeClass(\"active\");\n option.addClass(\"active\");\n\n // Apply filtering logic based on the selected value\n if (dropdown.attr(\"id\") === \"location_state_filter\") {\n currentStateFilter = value;\n\n // State filtering logic\n $(\".location-grid .location-col\").each(function () {\n var anchor = $(this).find(\"a\");\n if (value === \"\") {\n $(this).show();\n } else if (anchor.data(\"location-state\") !== value) {\n $(this).hide();\n } else {\n $(this).show();\n }\n });\n } else if (dropdown.attr(\"id\") === \"area_type_filter\") {\n currentAreaFilter = value;\n\n // Area type filtering logic\n $(\".location-grid .location-col\").each(function () {\n var anchor = $(this).find(\"a\");\n var matchesAreaFilter =\n currentAreaFilter === \"\" ||\n anchor.data(\"location-arrived\") === currentAreaFilter;\n var matchesStateFilter =\n currentStateFilter === \"\" ||\n anchor.data(\"location-state\") === currentStateFilter;\n\n if (matchesAreaFilter && matchesStateFilter) {\n $(this).show();\n } else {\n $(this).hide();\n }\n });\n }\n\n updateActiveClass();\n toggleDropdown(dropdown);\n showHideLocations();\n\n setGridMinHeight();\n });\n\n // Close dropdown if clicked outside\n $(document).click(function (event) {\n // Check if the clicked area is outside the dropdowns and not the load more button\n if (\n !$(event.target).closest(\".custom-dropdown\").length &&\n !$(event.target).closest(\".load-more>button\").length\n ) {\n $(\".dropdown-options\").hide();\n // Instead of removing active class, call updateActiveClass\n updateActiveClass();\n }\n });\n\n // Set default active options\n function setDefaultActiveOption(dropdown) {\n var activeOption = dropdown.find(\".option.active\").first();\n var labelText = activeOption.text();\n var dropdownLabel = dropdown.find(\".dropdown-label\").first();\n dropdownLabel\n .contents()\n .first()\n .replaceWith(labelText + \" \");\n var value = activeOption.data(\"value\");\n\n if (dropdown.attr(\"id\") === \"location_state_filter\") {\n currentStateFilter = value;\n } else if (dropdown.attr(\"id\") === \"area_type_filter\") {\n currentAreaFilter = value;\n }\n }\n\n setDefaultActiveOption($(\"#location_state_filter\"));\n setDefaultActiveOption($(\"#area_type_filter\"));\n\n // Separate function for Load More functionality\n function loadMoreLocations() {\n var shownCount = 0;\n\n $(\".location-grid .location-col\").each(function () {\n var anchor = $(this).find(\"a\");\n var matchesAreaFilter =\n currentAreaFilter === \"\" ||\n anchor.data(\"location-arrived\") === currentAreaFilter;\n var matchesStateFilter =\n currentStateFilter === \"\" ||\n anchor.data(\"location-state\") === currentStateFilter;\n\n if (matchesAreaFilter && matchesStateFilter && !$(this).is(\":visible\")) {\n if (shownCount < 12) {\n $(this).show();\n shownCount++;\n }\n }\n });\n\n showHideLoadMore();\n }\n\n function showHideLoadMore() {\n // Use the :visible selector to count the number of visible .location-col elements\n var visibleCount = $(\".location-grid .location-col:visible\").length;\n var totalMatchedItems = 0;\n\n $(\".location-grid .location-col\").each(function () {\n var anchor = $(this).find(\"a\");\n var matchesAreaFilter =\n currentAreaFilter === \"\" ||\n anchor.data(\"location-arrived\") === currentAreaFilter;\n var matchesStateFilter =\n currentStateFilter === \"\" ||\n anchor.data(\"location-state\") === currentStateFilter;\n if (matchesAreaFilter && matchesStateFilter) {\n totalMatchedItems++;\n }\n });\n // Show 'Load More' only if there are more matched items than visible ones\n if (visibleCount < totalMatchedItems) {\n $(\".load-more\").show();\n } else {\n $(\".load-more\").hide();\n }\n }\n\n function setGridMinHeight() {\n if ($(window).width() <= 767) {\n var grid = document.querySelector(\".location-grid\");\n if (grid !== null) {\n grid.style.minHeight = \"auto\";\n }\n return;\n }\n if (!$(\".wf-map-locations\").hasClass(\"no-map\")) {\n return;\n }\n var grid = document.querySelector(\".location-grid\");\n var rows = grid.querySelectorAll(\".location-col\");\n var maxHeight = 0;\n var originalDisplayStates = [];\n\n if (grid !== null) {\n // Temporarily show all rows to calculate the height\n // temp set min height to auto\n grid.style.minHeight = \"auto\";\n rows.forEach((row, index) => {\n originalDisplayStates[index] = row.style.display;\n row.style.display = \"inline-flex\";\n });\n // console.log(grid.clientHeight);\n\n maxHeight = grid.clientHeight;\n\n // Apply the calculated height as min-height\n grid.style.minHeight = maxHeight + \"px\";\n\n // Re-apply filters to hide/show rows as necessary\n rows.forEach((row, index) => {\n row.style.display = originalDisplayStates[index];\n });\n }\n }\n setGridMinHeight();\n\n // if on small screen size, only show a max of 12 locations. If the .load-more>button is clicked, show more locations\n function showHideLocations() {\n if ($(window).width() >= 768) {\n return;\n }\n var totalMatchedItems = 0;\n\n $(\".location-grid .location-col\").each(function () {\n var anchor = $(this).find(\"a\");\n var matchesAreaFilter =\n currentAreaFilter === \"\" ||\n anchor.data(\"location-arrived\") === currentAreaFilter;\n var matchesStateFilter =\n currentStateFilter === \"\" ||\n anchor.data(\"location-state\") === currentStateFilter;\n\n if (matchesAreaFilter && matchesStateFilter) {\n totalMatchedItems++;\n // Show/hide logic remains the same\n if (\n $(window).width() < 768 &&\n $(\".location-grid .location-col:visible\").length <= 12\n ) {\n $(this).show();\n } else {\n $(this).hide();\n }\n } else {\n $(this).hide();\n }\n if ($(window).width() >= 768) {\n $(\".load-more\").hide();\n $(this).show();\n }\n });\n\n showHideLoadMore();\n }\n\n // Bind Load More button click event\n $(\".load-more>button\")\n .off(\"click\")\n .click(function () {\n loadMoreLocations();\n });\n\n // Initial call and setting up resize event\n showHideLocations();\n $(window).resize(function () {\n showHideLocations();\n setGridMinHeight();\n });\n});\n"],"names":["isSafari","test","navigator","userAgent","document","querySelectorAll","forEach","item","addEventListener","link","this","dataset","linkTarget","window","location","href","let","circles","Array","from","animate","opacity","parseFloat","getComputedStyle","circle","getPropertyValue","trim","setAttribute","requestAnimationFrame","jQuery","ready","$","currentAreaFilter","currentStateFilter","toggleDropdown","dropdown","not","find","hide","toggle","updateActiveClass","each","data","addClass","removeClass","setDefaultActiveOption","activeOption","first","labelText","text","value","contents","replaceWith","attr","showHideLoadMore","visibleCount","length","totalMatchedItems","anchor","matchesAreaFilter","matchesStateFilter","show","setGridMinHeight","grid","rows","maxHeight","originalDisplayStates","width","querySelector","style","minHeight","hasClass","row","index","display","clientHeight","showHideLocations","click","label","option","closest","e","preventDefault","event","target","off","shownCount","is","resize"],"mappings":"AAOA,SAASA,WACP,MAAO,iCAAiCC,KAAKC,UAAUC,SAAS,CAClE,CATAC,SAASC,iBAAiB,WAAW,EAAEC,QAAQ,IAC7CC,EAAKC,iBAAiB,QAAS,WAC7B,IAAIC,EAAOC,KAAKC,QAAQC,WACxBC,OAAOC,SAASC,KAAON,CACzB,CAAC,CACH,CAAC,EAMGT,SAAS,GACXI,SAASI,iBAAiB,mBAAoB,WAC5CQ,IAAIC,EAAUC,MAAMC,KAClBf,SAASC,iBAAiB,YAAY,CACxC,EAeAe,CAbA,SAASA,IACPH,EAAQX,QAAQ,IACdU,IAAIK,EAAUC,WACZC,iBAAiBC,CAAM,EAAEC,iBAAiB,cAAc,EAAEC,KAAK,CACjE,EAGAF,EAAOG,aAAa,IADlB,SAAkCN,EAAU,KAAQ,GAA1C,OACmB,CACjC,CAAC,EAEDO,sBAAsBR,CAAO,CAC/B,EAEQ,CACV,CAAC,EAIHS,OAAOzB,QAAQ,EAAE0B,MAAM,SAAUC,GAC/B,IAAIC,EAAoB,GACpBC,EAAqB,GAEzB,SAASC,EAAeC,GACtBJ,EAAE,kBAAkB,EAAEK,IAAID,CAAQ,EAAEE,KAAK,mBAAmB,EAAEC,KAAK,EAElDH,EAASE,KAAK,mBAAmB,EACvCE,OAAO,CACpB,CAEA,SAASC,IACPT,EAAE,gCAAgC,EAAEU,KAAK,WACnCV,EAAErB,IAAI,EAAEgC,KAAK,OAAO,IAAMT,EAC5BF,EAAErB,IAAI,EAAEiC,SAAS,QAAQ,EAEzBZ,EAAErB,IAAI,EAAEkC,YAAY,QAAQ,CAEhC,CAAC,EAEDb,EAAE,2BAA2B,EAAEU,KAAK,WAC9BV,EAAErB,IAAI,EAAEgC,KAAK,OAAO,IAAMV,EAC5BD,EAAErB,IAAI,EAAEiC,S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