From 138ebe493d8059146a34322fb2988fd6029087af Mon Sep 17 00:00:00 2001 From: xiangyu <3170102889@zju.edu.cn> Date: Thu, 14 Jul 2022 17:09:42 +0800 Subject: [PATCH] add: preview tab name customize --- addon/chrome/content/preferences.xul | 6 ++++++ addon/chrome/locale/en-US/overlay.dtd | 2 ++ addon/chrome/locale/zh-CN/overlay.dtd | 2 ++ addon/defaults/preferences/defaults.js | 1 + src/events.ts | 9 +++++++++ 5 files changed, 20 insertions(+) diff --git a/addon/chrome/content/preferences.xul b/addon/chrome/content/preferences.xul index 0cbcfe3..d104c27 100644 --- a/addon/chrome/content/preferences.xul +++ b/addon/chrome/content/preferences.xul @@ -9,6 +9,7 @@ + @@ -22,6 +23,11 @@ + + diff --git a/addon/chrome/locale/en-US/overlay.dtd b/addon/chrome/locale/en-US/overlay.dtd index 379b356..da990da 100644 --- a/addon/chrome/locale/en-US/overlay.dtd +++ b/addon/chrome/locale/en-US/overlay.dtd @@ -3,6 +3,8 @@ + + diff --git a/addon/chrome/locale/zh-CN/overlay.dtd b/addon/chrome/locale/zh-CN/overlay.dtd index 6f7757b..62db392 100644 --- a/addon/chrome/locale/zh-CN/overlay.dtd +++ b/addon/chrome/locale/zh-CN/overlay.dtd @@ -3,6 +3,8 @@ + + diff --git a/addon/defaults/preferences/defaults.js b/addon/defaults/preferences/defaults.js index 3da5d39..0d33aba 100644 --- a/addon/defaults/preferences/defaults.js +++ b/addon/defaults/preferences/defaults.js @@ -1,3 +1,4 @@ pref("extensions.zotero.pdfpreview.enable", true); pref("extensions.zotero.pdfpreview.autoPreview", true); pref("extensions.zotero.pdfpreview.previewPageNum", "10"); +pref("extensions.zotero.pdfpreview.previewTabName", "Preview"); diff --git a/src/events.ts b/src/events.ts index 9e50b42..dde4843 100644 --- a/src/events.ts +++ b/src/events.ts @@ -6,6 +6,7 @@ class AddonEvents extends AddonBase { await Zotero.uiReadyPromise; this.initItemSelectListener(); this.initPreviewResizeListener(); + this.updatePreviewTabName(); } private initItemSelectListener() { @@ -30,6 +31,14 @@ class AddonEvents extends AddonBase { ); (tabbox as any).selectedIndex = tabIndex; } + + private updatePreviewTabName() { + let label = ""; + + label = Zotero.Prefs.get("pdfpreview.previewTabName"); + const previewTab = window.document.querySelector("#pdf-preview-tab"); + previewTab.setAttribute("label", label); + } } export default AddonEvents;