Poprawa tworzenia ramek z HTML

This commit is contained in:
2025-12-15 09:13:21 +01:00
parent 4319ffef03
commit a1d1a64aac
4 changed files with 37 additions and 12 deletions

View File

@@ -22,7 +22,7 @@ Można użyć extends w innym miejscu (np tym razem w wydzielonym JS) żeby nadp
**Przykład**
```
class IdmRaypathHotspot extends IdmHotspot {
IdmHotspot = class extends IdmHotspot {
markupLabel(prod) {
// Standardowe labelki
let labelMarkup = super.markupLabel(prod);

24
extends.js Normal file
View File

@@ -0,0 +1,24 @@
IdmHotspot = class extends IdmHotspot {
markupLabel(prod) {
// Standardowe labelki
let labelMarkup = super.markupLabel(prod);
// Customowe labelki
const awards = prod?.awardedParameters;
if (awards?.length) {
const awardParam = awards.find(award => award.name === "Idm_custom_label");
const values = awardParam?.values?.map(v => v.name) || [];
const html = values
.map(label => {
const [text, bgColor, color] = label.split("||");
return `<span class="label --custom" style="background-color:${bgColor}; color:${color}">${text}</span>`;
})
.join("");
labelMarkup += html;
}
return labelMarkup;
}
}

View File

@@ -2146,10 +2146,12 @@ async function idmPrepareHotspotObject(selectedContainerEl){
};
if(selectedContainerEl?.dataset?.lazy) idmHotspotObj.options = {lazy: selectedContainerEl?.dataset?.lazy === "true" ? true : false};
new IdmHotspot(idmHotspotObj);
}
document.querySelectorAll(".hotspot__wrapper.idm__hotspot").forEach(currentHotspot=>{
document.addEventListener("DOMContentLoaded", ()=>{
document.querySelectorAll(".hotspot__wrapper.idm__hotspot:not(.--init)").forEach(currentHotspot=>{
idmPrepareHotspotObject(currentHotspot);
});
})

View File

@@ -22,11 +22,10 @@ Stara ramka
- getProductXML=t
- slick
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
BUG Z RAMKAMI HTML jak się używa extends!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
cacheowanie ramek do indexedDB
awaitowanie idmHotspot
fix cssVariables jak nie ma wesji
zapisywanie querySelectorów produktów