2024-03-07 16:18:21 +10:00
|
|
|
const tabs_lists = document.querySelectorAll('.nav-tabs[role="tablist"]');
|
|
|
|
let tabs = [];
|
|
|
|
|
|
|
|
tabs_lists.forEach((tabs_list) => {
|
|
|
|
tabs = [...tabs, ...tabs_list.querySelectorAll('[role="tab"]')];
|
|
|
|
})
|
|
|
|
|
2024-03-07 16:32:16 +10:00
|
|
|
function setInputsState(section, disabled = false) {
|
|
|
|
section.querySelectorAll('input, textarea, button, select').forEach((el) => {
|
|
|
|
// console.log(el);
|
|
|
|
el.disabled = disabled;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2024-03-07 16:18:21 +10:00
|
|
|
tabs.forEach((tab) => {
|
|
|
|
tab.addEventListener('hide.bs.tab', event => {
|
|
|
|
const id_content_hide = event.target.getAttribute('data-bs-target');
|
|
|
|
const id_content_show = event.relatedTarget.getAttribute('data-bs-target');
|
|
|
|
|
2024-03-07 16:32:16 +10:00
|
|
|
// console.log('==== Hide ====');
|
2024-03-07 16:18:21 +10:00
|
|
|
const content_hide = document.querySelector(id_content_hide);
|
2024-03-07 16:32:16 +10:00
|
|
|
setInputsState(content_hide, true);
|
2024-03-07 16:18:21 +10:00
|
|
|
|
2024-03-07 16:32:16 +10:00
|
|
|
// console.log('==== Show ====');
|
2024-03-07 16:18:21 +10:00
|
|
|
const content_show = document.querySelector(id_content_show);
|
2024-03-07 16:32:16 +10:00
|
|
|
setInputsState(content_show);
|
2024-03-07 16:18:21 +10:00
|
|
|
});
|
|
|
|
|
|
|
|
if (!tab.getAttribute('aria-selected')) {
|
2024-03-07 16:32:16 +10:00
|
|
|
const id_content_hide = tab.getAttribute('data-bs-target');
|
|
|
|
const content_hide = document.querySelector(id_content_hide);
|
|
|
|
setInputsState(content_hide, true);
|
2024-03-07 16:18:21 +10:00
|
|
|
}
|
|
|
|
})
|