Vinoteca: wine shop on 1C-Bitrix (module, template, components, pages)

This commit is contained in:
jimagie committed 2026-10-22 19:35:23 +05:00
commit 0590195880
593 files changed
+27942

No files matched your search

@@ -0,0 +1,107 @@
(function (run) {
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', run);
else run();
})(function () {
(function () {
var header = document.querySelector('[data-header]');
if (header) {
var onScroll = function () { header.classList.toggle('vino-header--scrolled', window.scrollY > 20); };
onScroll();
window.addEventListener('scroll', onScroll, { passive: true });
}
var toggle = document.querySelector('[data-menu-toggle]');
var menu = document.querySelector('[data-menu]');
if (toggle && menu) {
var setMenu = function (open) {
menu.classList.toggle('vino-nav--open', open);
toggle.setAttribute('aria-expanded', open ? 'true' : 'false');
};
toggle.addEventListener('click', function (e) {
e.stopPropagation();
setMenu(!menu.classList.contains('vino-nav--open'));
});
menu.addEventListener('click', function (e) { if (e.target.closest('a, button')) setMenu(false); });
document.addEventListener('click', function (e) { if (!menu.contains(e.target)) setMenu(false); });
document.addEventListener('keydown', function (e) {
if (e.key !== 'Escape' || !menu.classList.contains('vino-nav--open')) return;
setMenu(false);
toggle.focus();
});
}
})();
(function () {
var box = document.querySelector('[data-lang]');
if (!box) return;
var btn = box.querySelector('[data-lang-toggle]');
function set(open) {
box.setAttribute('data-open', open ? 'true' : 'false');
btn.setAttribute('aria-expanded', open ? 'true' : 'false');
}
btn.addEventListener('click', function (e) {
e.stopPropagation();
set(box.getAttribute('data-open') !== 'true');
});
document.addEventListener('click', function (e) { if (!box.contains(e.target)) set(false); });
document.addEventListener('keydown', function (e) {
if (e.key !== 'Escape' || box.getAttribute('data-open') !== 'true') return;
set(false);
btn.focus();
});
})();
(function () {
var root = document.querySelector('[data-search]');
if (!root) return;
var input = root.querySelector('[data-search-input]');
var hideTimer = 0;
var opener = null;
var openers = document.querySelectorAll('[data-search-open]');
function focusable() {
return Array.prototype.filter.call(root.querySelectorAll('a[href], button:not([disabled]), input:not([disabled])'), function (el) { return el.offsetParent !== null; });
}
function open(e) {
if (e) e.preventDefault();
opener = e && e.currentTarget ? e.currentTarget : document.activeElement;
openers.forEach(function (o) { o.setAttribute('aria-expanded', 'true'); });
clearTimeout(hideTimer);
root.hidden = false;
void root.offsetWidth;
root.classList.add('vino-search--open');
if (input) input.focus();
document.documentElement.style.overflow = 'hidden';
}
function close() {
root.classList.remove('vino-search--open');
if (input) input.value = '';
document.dispatchEvent(new CustomEvent('vino:search-close'));
hideTimer = setTimeout(function () { root.hidden = true; }, 280);
document.documentElement.style.overflow = '';
openers.forEach(function (o) { o.setAttribute('aria-expanded', 'false'); });
if (opener && opener.focus) opener.focus();
}
document.querySelectorAll('[data-search-open]').forEach(function (o) { o.addEventListener('click', open); });
root.querySelectorAll('[data-search-close]').forEach(function (b) { b.addEventListener('click', close); });
document.addEventListener('keydown', function (e) {
if (root.hidden) return;
if (e.key === 'Escape') {
close();
return;
}
if (e.key !== 'Tab') return;
var items = focusable();
if (!items.length) return;
var first = items[0], last = items[items.length - 1];
if (e.shiftKey && document.activeElement === first) {
e.preventDefault();
last.focus();
} else if (!e.shiftKey && document.activeElement === last) {
e.preventDefault();
first.focus();
} else if (!root.contains(document.activeElement)) {
e.preventDefault();
first.focus();
}
});
})();
});