mirror of
https://github.com/samsonjs/spirit-tracker.git
synced 2026-04-27 15:07:43 +00:00
link sku
This commit is contained in:
parent
36460eb5af
commit
b6e30d09f1
1 changed files with 9 additions and 9 deletions
|
|
@ -193,14 +193,12 @@ export async function renderSkuLinker($app) {
|
||||||
)}${esc(plus)}</a>`
|
)}${esc(plus)}</a>`
|
||||||
: `<span class="badge">${esc(store)}${esc(plus)}</span>`;
|
: `<span class="badge">${esc(store)}${esc(plus)}</span>`;
|
||||||
|
|
||||||
const thumbHref = href || "";
|
|
||||||
|
|
||||||
const pinnedBadge = pinned ? `<span class="badge">PINNED</span>` : ``;
|
const pinnedBadge = pinned ? `<span class="badge">PINNED</span>` : ``;
|
||||||
|
|
||||||
return `
|
return `
|
||||||
<div class="item ${pinned ? "pinnedItem" : ""}" data-sku="${esc(it.sku)}">
|
<div class="item ${pinned ? "pinnedItem" : ""}" data-sku="${esc(it.sku)}">
|
||||||
<div class="itemRow">
|
<div class="itemRow">
|
||||||
<div class="thumbBox thumbLink" data-href="${esc(thumbHref)}">
|
<div class="thumbBox thumbInternalLink" data-sku="${esc(it.sku)}">
|
||||||
${renderThumbHtml(it.img)}
|
${renderThumbHtml(it.img)}
|
||||||
</div>
|
</div>
|
||||||
<div class="itemBody">
|
<div class="itemBody">
|
||||||
|
|
@ -271,15 +269,17 @@ export async function renderSkuLinker($app) {
|
||||||
|
|
||||||
function attachHandlers($root, side) {
|
function attachHandlers($root, side) {
|
||||||
|
|
||||||
for (const el of Array.from($root.querySelectorAll(".thumbLink"))) {
|
for (const el of Array.from($root.querySelectorAll(".thumbInternalLink"))) {
|
||||||
el.addEventListener("click", (e) => {
|
el.addEventListener("click", (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
|
||||||
const href = (el.getAttribute("data-href") || "").trim();
|
const sku = (el.getAttribute("data-sku") || "").trim();
|
||||||
if (!href) return;
|
if (!sku) return;
|
||||||
|
|
||||||
window.open(href, "_blank", "noopener,noreferrer");
|
const u = new URL(location.href);
|
||||||
|
u.hash = `#/item/${encodeURIComponent(sku)}`;
|
||||||
|
window.open(u.toString(), "_blank", "noopener,noreferrer");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue