2022-11-24 08:39:31 +03:00

82 lines
2.0 KiB
JavaScript

var faq_section_index = 0;
var faq_item_index = 0;
$(function()
{
var hash = document.location.hash.replace("#", "");
if(hash !== "")
{
$(".faq_item_title").each(function()
{
if($(this).data('id') == hash)
{
faq_section_index = $(this).data('section');
faq_item_index = $(this).data('index');
$(".faq_section_button").removeClass("active");
$(".faq_section_button_"+faq_section_index).addClass("active");
$(".faq_items_list").css("display", "none");
$(".faq_items_list_"+faq_section_index).css("display", "block");
$(".faq_item").removeClass("open");
$(".faq_item_"+faq_item_index).addClass("open");
return false;
}
});
}
$(".faq_item_title").on("click", function()
{
let index = $(this).data('index');
faq_item_index = index;
});
$("#faq_search_form_field").on("keydown", function(event)
{
if(event.keyCode === 13)
{
event.preventDefault();
$("#faq_search_form").submit();
}
});
$("#faq_search_form_field").on("input", function()
{
if($("#faq_search_form_field").val() !== "")
{
$("#faq_search_form_clear_button").css("display", "block");
//$("#faq_search_form_search_button").attr("disabled", false);
}
else
{
$("#faq_search_form_clear_button").css("display", "none");
//$("#faq_search_form_search_button").attr("disabled", "disabled");
}
});
$("#faq_search_form_clear_button").on("click", function(event)
{
event.preventDefault();
$("#faq_search_form_field").val("");
$("#faq_search_form_clear_button").css("display", "none");
//$("#faq_search_form_search_button").attr("disabled", "disabled");
});
$(".faq_section_button").on("click", function()
{
let section = $(this).data('section');
faq_section_index = section;
faq_item_index = 0;
$(".faq_section_button").removeClass("active");
$(".faq_section_button_"+section).addClass("active");
$(".faq_items_list").css("display", "none");
$(".faq_items_list_"+section).css("display", "block");
$(".faq_item").removeClass("open");
$(".faq_item_"+faq_item_index).addClass("open");
});
});