Zabezpieczenie kodu tooltipa

This commit is contained in:
2025-11-21 08:55:52 +01:00
parent 1c3c5e8334
commit 49ff211062
2 changed files with 54 additions and 12 deletions

View File

@@ -191,6 +191,7 @@ const IDM_PRODUCT_QUERY = `id
iconSecond
iconSmall
iconSmallSecond
link
}
}
opinion{
@@ -591,18 +592,19 @@ class IdmHotspot{
${this.markupAdditional(prod)}
</div>
<a class="product__icon d-flex justify-content-center align-items-center" tabindex="-1" href="${prod.link}">
${this.markupImage(prod)}
<strong class="label_icons">
${this.markupLabel(prod)}
</strong>
${this.markupImage(prod)}
<strong class="label_icons">
${this.markupLabel(prod)}
</strong>
</a>
<div class="product__content_wrapper">
${this.markupOpinions(prod)}
<a class="product__name" tabindex="0" href="${prod.link}" title="${prod.name}">${prod.name}</a>
<div class="product__prices mb-auto ${prodExchangedData?.classes?.add?.reduce((acc,val) => acc + " " + val,"")}">
${this.markupPrice(prod, prodExchangedData)}
</div>
${this.markupAddToBasket(prod)}
${this.markupVersions(prod)}
${this.markupOpinions(prod)}
<a class="product__name" tabindex="0" href="${prod.link}" title="${prod.name}">${prod.name}</a>
<div class="product__prices mb-auto ${prodExchangedData?.classes?.add?.reduce((acc,val) => acc + " " + val,"")}">
${this.markupPrice(prod, prodExchangedData)}
</div>
${this.markupAddToBasket(prod)}
</div>
</div>`;
@@ -633,6 +635,16 @@ class IdmHotspot{
data-product-size="${prod.sizes?.[0]?.id || 'uniw'}" aria-label="${idmHotspotTextObject["Dodaj do ulubionych"]}">
</span>`;
}
markupVersions(prod){
if(!this.options?.selectVersion || !prod.group?.versions || prod.group?.versions?.length === 1 ) return "";
return `<div class="product__versions">
${prod.group.versions.reduce((acc, val)=>{
return acc + `<a class="product__version_single" href="${val.link}"><img class="product__version_img" src="${val.icon}" alt="${val.name}"/></a>`;
},"")}
</div>`
}
markupImage(prod){
let markup = "";
@@ -1407,7 +1419,7 @@ function idmHideTooltip(tooltipEl){
}
// document.addEventListener("DOMContentLoaded", ()=>{
document.addEventListener("DOMContentLoaded", ()=>{
document.body.addEventListener("click", e=>{
const tooltipEl = e.target.closest(".idm_tooltip");
if(!e.target.closest(".idm_tooltip__info_icon") || !tooltipEl) return;
@@ -1415,7 +1427,7 @@ function idmHideTooltip(tooltipEl){
e.preventDefault();
idmShowTooltip(tooltipEl);
});
// });
});
// new IdmHotspot({
// id: "idmTestHotspot1",
// title: "tescik",