From 5f717d3bde0f761ecca8844ffa42d582d44867ed Mon Sep 17 00:00:00 2001 From: Abe Jellinek Date: Thu, 7 Mar 2024 10:12:36 -0500 Subject: [PATCH] Show first-run banner on upgrade (#3807) --- chrome/content/zotero/xpcom/prefs.js | 6 +- chrome/content/zotero/zoteroPane.js | 31 ++++++++ chrome/content/zotero/zoteroPane.xhtml | 57 +++++++++++--- chrome/locale/en-US/zotero/zotero.ftl | 8 ++ chrome/skin/default/zotero/overlay.css | 61 --------------- defaults/preferences/zotero.js | 1 + resource/config.js | 1 + scss/_zotero.scss | 1 + scss/components/_banners.scss | 103 +++++++++++++++++++++++++ 9 files changed, 198 insertions(+), 71 deletions(-) create mode 100644 scss/components/_banners.scss diff --git a/chrome/content/zotero/xpcom/prefs.js b/chrome/content/zotero/xpcom/prefs.js index df6b6f48ed..d405a23669 100644 --- a/chrome/content/zotero/xpcom/prefs.js +++ b/chrome/content/zotero/xpcom/prefs.js @@ -44,7 +44,7 @@ Zotero.Prefs = new function() { // Process pref version updates var fromVersion = this.get('prefVersion'); - var toVersion = 11; + var toVersion = 12; if (!fromVersion) { this.set('prefVersion', toVersion); } @@ -138,6 +138,10 @@ Zotero.Prefs = new function() { case 11: await Zotero.LocateManager.migrateEngines(); break; + + case 12: + Zotero.Prefs.set('firstRunGuidanceShown.z7Banner', false); + break; } } this.set('prefVersion', toVersion); diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js index baf6d9199d..bf086ed77e 100644 --- a/chrome/content/zotero/zoteroPane.js +++ b/chrome/content/zotero/zoteroPane.js @@ -114,6 +114,7 @@ var ZoteroPane = new function() zp.addEventListener('UIPropertiesChanged', () => { this.collectionsView?.updateFontSize(); this.itemsView?.updateFontSize(); + this.updatePostUpgradeBanner(); }); Zotero.UIProperties.registerRoot(document.getElementById('zotero-context-pane')); this.itemPane = document.querySelector("#zotero-item-pane"); @@ -629,6 +630,7 @@ var ZoteroPane = new function() } setTimeout(function () { + ZoteroPane.showPostUpgradeBanner(); ZoteroPane.showRetractionBanner(); ZoteroPane.showArchitectureWarning(); ZoteroPane.initSyncReminders(true); @@ -6143,6 +6145,35 @@ var ZoteroPane = new function() }; + this.showPostUpgradeBanner = function () { + if (Zotero.isBetaBuild || Zotero.Prefs.get('firstRunGuidanceShown.z7Banner')) { + return; + } + document.getElementById('post-upgrade-container').removeAttribute('collapsed'); + this.updatePostUpgradeBanner(); + }; + + + this.updatePostUpgradeBanner = function () { + document.getElementById('post-upgrade-density').value = Zotero.Prefs.get('uiDensity'); + }; + + + this.hidePostUpgradeBanner = function (remindMeLater = false) { + document.getElementById('post-upgrade-container').setAttribute('collapsed', true); + if (remindMeLater) { + // The pref should already be false if the banner was showing, but just in case + Zotero.Prefs.set('firstRunGuidanceShown.z7Banner', false); + setTimeout(() => { + this.showPostUpgradeBanner(); + }, 1000 * 60 * 60 * 24); // 24 hours + } + else { + Zotero.Prefs.set('firstRunGuidanceShown.z7Banner', true); + } + }; + + /** * Sets the layout to either a three-vertical-pane layout and a layout where itemsPane is above itemPane */ diff --git a/chrome/content/zotero/zoteroPane.xhtml b/chrome/content/zotero/zoteroPane.xhtml index 6cd0cbec0f..49fff6b8d5 100644 --- a/chrome/content/zotero/zoteroPane.xhtml +++ b/chrome/content/zotero/zoteroPane.xhtml @@ -1081,23 +1081,62 @@ onkeyup="ZoteroPane_Local.handleKeyUp(event, this.id)" onkeypress="ZoteroPane_Local.handleKeyPress(event)"> + + + + + + + + + + + + + + +