File size: 3,936 Bytes
34be7eb | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | (function () {
"use strict";
function show(node, visible) {
if (!node) return;
node.hidden = !visible;
node.classList.toggle("mfp-hide", !visible);
node.classList.toggle("sf-hidden", !visible);
node.setAttribute("aria-hidden", visible ? "false" : "true");
}
function renderLocalPanel(panel) {
if (!panel || panel.dataset.referenceRendered === "true") return;
panel.dataset.referenceRendered = "true";
panel.classList.add("non-airport-reference");
panel.innerHTML = [
"<h2>What location do you want to pick up near?</h2>",
'<input type="hidden" name="location_type" value="non-airport">',
'<input class="non-airport-location" name="location" autocomplete="off" required>',
"<p class=\"non-airport-copy\">You can enter a city name or a specific address and we'll search for the closest rental locations near that point.</p>",
'<label class="nearby-airports"><input type="checkbox" name="include_nearby_airports" value="1"> <span>Include Nearby Airports</span></label>',
'<button type="submit" class="non-airport-next nav-control-btn nav-control-next btn">Next</button>'
].join("");
}
function locationMode(localMode) {
var airport = document.getElementById("tab-airport");
var local = document.getElementById("tab-non-airport");
var airportTab = document.getElementById("airport-tab");
var localTab = document.getElementById("local-tab");
if (!airport || !local) return;
if (localMode) renderLocalPanel(local);
if (airportTab) airportTab.classList.toggle("active", !localMode);
if (localTab) localTab.classList.toggle("active", localMode);
if (airportTab && airportTab.querySelector("a")) {
airportTab.querySelector("a").setAttribute("aria-selected", localMode ? "false" : "true");
}
if (localTab && localTab.querySelector("a")) {
localTab.querySelector("a").setAttribute("aria-selected", localMode ? "true" : "false");
}
show(airport, !localMode);
show(local, localMode);
document.querySelectorAll(".nav-controls, .nav-control-next").forEach(function (node) {
if (!local.contains(node)) {
node.hidden = localMode;
node.style.display = localMode ? "none" : "";
}
});
var airportInput = document.getElementById("AirportId-display");
if (airportInput) airportInput.disabled = localMode;
}
document.addEventListener("click", function (event) {
var target = event.target.closest("a, button, [role=button]");
if (!target) return;
var href = target.getAttribute("href") || "";
var text = (target.textContent || "").trim().toLowerCase();
if (href.indexOf("#tab-non-airport") === 0 || text === "non-airport" || text === "click here") {
if (document.getElementById("tab-non-airport")) {
event.preventDefault();
locationMode(true);
history.replaceState(null, "", "#tab-non-airport");
}
return;
}
if (href.indexOf("#tab-airport") === 0 || text === "airport") {
if (document.getElementById("tab-airport")) {
event.preventDefault();
locationMode(false);
history.replaceState(null, "", "#tab-airport");
}
return;
}
if (href.indexOf("#modal-") === 0) {
event.preventDefault();
show(document.getElementById(href.slice(1)), true);
return;
}
if (target.matches(".mfp-close, .modal-close, [data-dismiss]")) {
event.preventDefault();
show(target.closest(".modal, [role=dialog]"), false);
return;
}
if (href === "#" || href === "#!") event.preventDefault();
}, true);
document.addEventListener("keydown", function (event) {
if (event.key !== "Escape") return;
var open = document.querySelector(".modal:not(.mfp-hide)");
if (open) show(open, false);
});
if (window.location.hash.replace("#!", "#") === "#tab-non-airport") {
locationMode(true);
}
})();
|