diff --git a/README.md b/README.md index 47415fe..1bf61e1 100644 --- a/README.md +++ b/README.md @@ -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); diff --git a/extends.js b/extends.js new file mode 100644 index 0000000..465f016 --- /dev/null +++ b/extends.js @@ -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 `${text}`; + }) + .join(""); + + labelMarkup += html; + } + + return labelMarkup; + } +} \ No newline at end of file diff --git a/klasa.js b/klasa.js index 7610268..cb2f959 100644 --- a/klasa.js +++ b/klasa.js @@ -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=>{ - idmPrepareHotspotObject(currentHotspot); -}); \ No newline at end of file + +document.addEventListener("DOMContentLoaded", ()=>{ + document.querySelectorAll(".hotspot__wrapper.idm__hotspot:not(.--init)").forEach(currentHotspot=>{ + idmPrepareHotspotObject(currentHotspot); + }); +}) \ No newline at end of file diff --git a/ramka.txt b/ramka.txt index a7612d7..daa9041 100644 --- a/ramka.txt +++ b/ramka.txt @@ -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 \ No newline at end of file