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,33 @@
(function (run) {
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', run);
else run();
})(function () {
var root = document.querySelector('[data-favorites]');
if (!root || !window.BX || !BX.ajax || !BX.ajax.runAction) return;
var status = root.querySelector('[data-favorites-status]');
document.addEventListener('click', function (event) {
var button = event.target.closest('[data-favorites] [data-fav-toggle]');
if (!button) return;
event.preventDefault();
event.stopImmediatePropagation();
var card = button.closest('.vino-card');
if (!card) return;
var parent = card.parentNode;
var next = card.nextSibling;
var neighbour = card.nextElementSibling || card.previousElementSibling;
card.remove();
if (status) status.textContent = root.getAttribute('data-favorites-removed') || '';
var focus = (neighbour && neighbour.querySelector('.vino-card__link')) || document.querySelector('h1');
if (focus) {
if (focus.tagName === 'H1') focus.setAttribute('tabindex', '-1');
focus.focus();
}
BX.ajax.runAction('jinove:vinoteca.favorite.set', { data: { id: button.getAttribute('data-fav-toggle'), on: 'N' } }).then(function (response) {
document.dispatchEvent(new CustomEvent('vino:favorite', { detail: response.data }));
if (!root.querySelector('.vino-card')) window.location.href = window.location.pathname;
}, function () {
parent.insertBefore(card, next);
if (status) status.textContent = '';
});
}, true);
});