(function () {
function prepareProductCards(container) {
var root = container || document;
root.querySelectorAll('.products .product-block').forEach(function (card) {
var content = card.querySelector('.product-content');
var caption = content
? content.querySelector('.caption')
: null;
var actions = content
? content.querySelector('.group-buttons')
: null;
if (!content || !caption || !actions) {
return;
}
if (!actions.classList.contains('pbr-card-actions')) {
actions.classList.add('pbr-card-actions');
caption.insertAdjacentElement('afterend', actions);
}
var cartTitle = actions.querySelector('.add-cart .title-cart');
if (cartTitle) {
cartTitle.textContent = 'Adaugă';
}
});
}
function initializeCards() {
prepareProductCards(document);
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', initializeCards);
} else {
initializeCards();
}
window.addEventListener('load', initializeCards);
new MutationObserver(function (mutations) {
mutations.forEach(function (mutation) {
mutation.addedNodes.forEach(function (node) {
if (node.nodeType === 1) {
prepareProductCards(node);
}
});
});
}).observe(document.body, {
childList: true,
subtree: true
});
})();