From 088577b1b79bf93929ccec8ee1e2dd50e226c6a8 Mon Sep 17 00:00:00 2001 From: dtookey Date: Tue, 20 Oct 2020 11:19:34 -0400 Subject: [PATCH] fixed a regression with file-cards in viewFactory.ts --- src/assets/pages/styles/default.css | 4 ++-- src/ts_source/viewFactory.ts | 19 ++++++++++++------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/assets/pages/styles/default.css b/src/assets/pages/styles/default.css index e714ab2..0e1cefd 100644 --- a/src/assets/pages/styles/default.css +++ b/src/assets/pages/styles/default.css @@ -8,8 +8,8 @@ body { } .thumbnail32 { - width: 16px; - height: 32px; + width: 32px; + height: 48px; } .file-card{ diff --git a/src/ts_source/viewFactory.ts b/src/ts_source/viewFactory.ts index be837af..56325ae 100644 --- a/src/ts_source/viewFactory.ts +++ b/src/ts_source/viewFactory.ts @@ -18,17 +18,22 @@ export class CardModel { } } -export function buildFileCard(filePath: string, elem: Element, append: boolean = false) { +export function buildFileCard(filePath: string, elem: Element, append: boolean = false, $: any = require('jquery')) { let model = new CardModel(getImagePathFromDocumentName(filePath), fileNameToPrettyString(filePath)); loadTemplateSingle("file-card.mustache", model, (content: string, id: string) => { + let snip = $(content); + let container = $("#" + elem.id); + if (append) { - elem.innerHTML = elem.innerHTML + content; + container.append(snip); } else { - elem.innerHTML = content; + container.empty().append(snip); } - document.querySelector("#" + id).addEventListener('click', () => { - launchDocument(filePath); - }) + setTimeout(() => { + $(`#${id}`).on("click", () => { + launchDocument(filePath); + }); + }, 1); //for some reason we have to let the dom breathe before it will let us do this? }); } @@ -77,7 +82,7 @@ export function buildWebCard(urlText: string, elem: Element, append: boolean = f launchWebsite(url.toString()); }); }).catch(reason => { - let card = $("

", {id:"come on", class: "pr-3 mb-0"}); + let card = $("

", {id: "come on", class: "pr-3 mb-0"}); card.text(urlText); $(`#${id}-title`).html(card); });