mirror of
https://github.com/samsonjs/spirit-tracker.git
synced 2026-03-25 09:25:51 +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>`
|
||||
: `<span class="badge">${esc(store)}${esc(plus)}</span>`;
|
||||
|
||||
const thumbHref = href || "";
|
||||
|
||||
const pinnedBadge = pinned ? `<span class="badge">PINNED</span>` : ``;
|
||||
|
||||
return `
|
||||
<div class="item ${pinned ? "pinnedItem" : ""}" data-sku="${esc(it.sku)}">
|
||||
<div class="itemRow">
|
||||
<div class="thumbBox thumbLink" data-href="${esc(thumbHref)}">
|
||||
<div class="thumbBox thumbInternalLink" data-sku="${esc(it.sku)}">
|
||||
${renderThumbHtml(it.img)}
|
||||
</div>
|
||||
<div class="itemBody">
|
||||
|
|
@ -271,15 +269,17 @@ export async function renderSkuLinker($app) {
|
|||
|
||||
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) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
const href = (el.getAttribute("data-href") || "").trim();
|
||||
if (!href) return;
|
||||
|
||||
window.open(href, "_blank", "noopener,noreferrer");
|
||||
|
||||
const sku = (el.getAttribute("data-sku") || "").trim();
|
||||
if (!sku) return;
|
||||
|
||||
const u = new URL(location.href);
|
||||
u.hash = `#/item/${encodeURIComponent(sku)}`;
|
||||
window.open(u.toString(), "_blank", "noopener,noreferrer");
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue