From 0b9b72edfff15d2f9b17a0dd2563a72823d1c825 Mon Sep 17 00:00:00 2001 From: opus1217 Date: Fri, 12 Feb 2021 12:14:37 -0800 Subject: [PATCH] 0.4.1l 12-Feb-2021 Display static "Loading..." message the first time tab is shown -> Want it with dynamic results and to not replace existing data feat-browser.html, spell-browser.html - Use items array on first load so that we pick up "Loading..." message --- compendium-browser.js | 15 +++++++++++++-- template/feat-browser.html | 2 +- template/spell-browser.html | 2 +- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/compendium-browser.js b/compendium-browser.js index 739d4bc..69a6a43 100644 --- a/compendium-browser.js +++ b/compendium-browser.js @@ -25,7 +25,9 @@ 12-Feb-2021 0.4.1j: Correct compactItem for feats and items required display items Rename itemType -> browserTab to differentiate candidate item's type from the tab it appears on (spell, feat/class, item, NPC) Fixed: Was calling the wrong sort for feat and NPC - 0.4.1k: Don't call loadItems() during initalize; getData() just displays static elements + 0.4.1k: Don't call loadItems() during initalize; getData() just displays static elements + 0.4.1l: Display progress indicator for loading - for now just a static one + 0.4.1m; PLANNED: Want loading message with dynamic results and to not replace existing data; need to localize as well */ const CMPBrowser = { @@ -136,9 +138,13 @@ class CompendiumBrowser extends Application { //0.4.1 Filter as we load to support new way of filtering //Previously loaded all data and filtered in place; now loads minimal (preload) amount, filtered as we go //First time (when you press Compendium Browser button) is called with filters unset - + const loadingItem = { + name: "Loading...", + img: "icons/sundries/books/book-open-turquoise.webp" + } //0.4.1k: Don't do any item/npc loading until tab is visible let data = { + items : {"Loading" : loadingItem}, spellFilters : this.spellFilters, showSpellBrowser : (game.user.isGM || this.settings.allowSpellBrowser), featFilters : this.featFilters, @@ -440,6 +446,11 @@ class CompendiumBrowser extends Application { this.replaceList(html, browserTab); }); + + //Just for the loading image + if (this.observer) { + html.find("img").each((i,img) => this.observer.observe(img)); + } } async checkListsLoaded() { diff --git a/template/feat-browser.html b/template/feat-browser.html index 2b3b493..26076aa 100644 --- a/template/feat-browser.html +++ b/template/feat-browser.html @@ -16,7 +16,7 @@ {{> "modules/compendium-browser/template/filter-container.html" filters=featFilters}} \ No newline at end of file diff --git a/template/spell-browser.html b/template/spell-browser.html index 36aaeaf..cad827e 100644 --- a/template/spell-browser.html +++ b/template/spell-browser.html @@ -16,6 +16,6 @@ {{> "modules/compendium-browser/template/filter-container.html" filters=spellFilters}} \ No newline at end of file