|
|
@ -8,12 +8,39 @@ function setActiveNav() { |
|
|
link.classList.toggle("is-active", active); |
|
|
link.classList.toggle("is-active", active); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
function activateFaqTab($btn) { |
|
|
|
|
|
$btn.addClass("is-active").attr("aria-selected", "true"); |
|
|
|
|
|
$btn.siblings(".f-tabs__item").removeClass("is-active").attr("aria-selected", "false"); |
|
|
|
|
|
} |
|
|
|
|
|
function getActiveTabId() { |
|
|
|
|
|
return $(".f-tabs__item.is-active").attr("data-tab") || ""; |
|
|
|
|
|
} |
|
|
|
|
|
function activateTabById(tabId) { |
|
|
|
|
|
if (!tabId) return; |
|
|
|
|
|
const $target = $(`.f-tabs__item[data-tab="${tabId}"]`).first(); |
|
|
|
|
|
if ($target.length) activateFaqTab($target); |
|
|
|
|
|
} |
|
|
|
|
|
function initTabKeywordsSearch() { |
|
|
|
|
|
$("[data-tab-search]").on("submit", function(event) { |
|
|
|
|
|
event.preventDefault(); |
|
|
|
|
|
const params = new URLSearchParams(); |
|
|
|
|
|
const keywords = $(this).find('[name="keywords"]').val().trim(); |
|
|
|
|
|
const tabId = getActiveTabId(); |
|
|
|
|
|
if (tabId) params.set("tab", tabId); |
|
|
|
|
|
if (keywords) params.set("keywords", keywords); |
|
|
|
|
|
const query = params.toString(); |
|
|
|
|
|
window.location.href = query ? `${window.location.pathname}?${query}` : window.location.pathname; |
|
|
|
|
|
}); |
|
|
|
|
|
const searchParams = new URLSearchParams(window.location.search); |
|
|
|
|
|
const tabParam = searchParams.get("tab"); |
|
|
|
|
|
const keywordsParam = searchParams.get("keywords"); |
|
|
|
|
|
if (keywordsParam) $("[data-tab-search] [name='keywords']").val(keywordsParam); |
|
|
|
|
|
if (tabParam) activateTabById(tabParam); |
|
|
|
|
|
} |
|
|
$(function() { |
|
|
$(function() { |
|
|
setActiveNav(); |
|
|
setActiveNav(); |
|
|
$(".f-tabs__item").on("click", function() { |
|
|
$(".f-tabs__item").on("click", function() { |
|
|
const $btn = $(this); |
|
|
|
|
|
$btn.addClass("is-active").attr("aria-selected", "true"); |
|
|
|
|
|
$btn.siblings(".f-tabs__item").removeClass("is-active").attr("aria-selected", "false"); |
|
|
|
|
|
|
|
|
activateFaqTab($(this)); |
|
|
}); |
|
|
}); |
|
|
$(".f-item__trigger").on("click", function() { |
|
|
$(".f-item__trigger").on("click", function() { |
|
|
const $item = $(this).closest(".f-item"); |
|
|
const $item = $(this).closest(".f-item"); |
|
|
@ -22,5 +49,6 @@ $(function() { |
|
|
$item.toggleClass("is-open", willOpen); |
|
|
$item.toggleClass("is-open", willOpen); |
|
|
$(this).attr("aria-expanded", willOpen ? "true" : "false"); |
|
|
$(this).attr("aria-expanded", willOpen ? "true" : "false"); |
|
|
}); |
|
|
}); |
|
|
|
|
|
initTabKeywordsSearch(); |
|
|
}); |
|
|
}); |
|
|
//#endregion
|
|
|
//#endregion
|