1
Some checks failed
Deploy / deploy (push) Has been cancelled

This commit is contained in:
ssww23
2026-03-17 01:59:00 +03:00
parent 93a655235a
commit 0ee9f05416
48 changed files with 1193 additions and 413 deletions

View File

@@ -54,6 +54,8 @@ const initChatWidget = () => {
const fetchUrl = widget.dataset.fetchUrl;
const sendUrl = widget.dataset.sendUrl;
const csrf = widget.dataset.csrf;
const sendLabel = widget.dataset.sendLabel || 'Send';
const restartLabel = widget.dataset.restartLabel || 'Restart';
const textarea = form.querySelector('textarea[name="message"]');
const submitButton = form.querySelector('button[type="submit"]');
@@ -83,7 +85,7 @@ const initChatWidget = () => {
note.textContent = conversationClosed && closedNotice !== '' ? closedNotice : defaultNoteText;
}
submitButton.textContent = conversationClosed ? 'Начать новый чат' : 'Отправить';
submitButton.textContent = conversationClosed ? restartLabel : sendLabel;
if (conversationClosed) {
stopPolling();
@@ -560,6 +562,46 @@ const initCategoryFilterToggle = () => {
});
};
const initLanguageSwitchers = () => {
const switchers = Array.from(document.querySelectorAll('[data-locale-switcher]')).filter(
(switcher) => switcher instanceof HTMLDetailsElement,
);
if (switchers.length === 0) {
return;
}
document.addEventListener('click', (event) => {
switchers.forEach((switcher) => {
if (!(switcher instanceof HTMLDetailsElement) || !switcher.open) {
return;
}
if (event.target instanceof Node && switcher.contains(event.target)) {
return;
}
switcher.open = false;
});
});
switchers.forEach((switcher) => {
const summary = switcher.querySelector('summary');
switcher.addEventListener('keydown', (event) => {
if (event.key !== 'Escape') {
return;
}
switcher.open = false;
if (summary instanceof HTMLElement) {
summary.focus();
}
});
});
};
document.addEventListener('submit', (event) => {
const form = event.target;
if (!(form instanceof HTMLFormElement)) {
@@ -620,3 +662,4 @@ initHomeSliders();
initProductCarousels();
initProductGallery();
initCategoryFilterToggle();
initLanguageSwitchers();