Skip to content
This repository has been archived by the owner on Jan 25, 2024. It is now read-only.

Commit

Permalink
add: preview tab name customize
Browse files Browse the repository at this point in the history
  • Loading branch information
xiangyu committed Jul 14, 2022
1 parent cff8c74 commit 138ebe4
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions addon/chrome/content/preferences.xul
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<preference id="pref-__addonRef__-enable" name="extensions.zotero.__addonRef__.enable" type="bool" />
<preference id="pref-__addonRef__-autoPreview" name="extensions.zotero.__addonRef__.autoPreview" type="bool" />
<preference id="pref-__addonRef__-previewPageNum" name="extensions.zotero.__addonRef__.previewPageNum" type="string" />
<preference id="pref-__addonRef__-previewTabName" name="extensions.zotero.__addonRef__.previewTabName" type="string" />
</preferences>
<rows>
<row>
Expand All @@ -22,6 +23,11 @@
<textbox id="zotero-prefpane-__addonRef__-settings-previewPageNum" preference="pref-__addonRef__-previewPageNum" />
<label value="&zotero.__addonRef__.pref.previewPageNumAfter.label;" />
</row>
<row>
<label control="zotero-prefpane-__addonRef__-settings-previewTabName" value="&zotero.__addonRef__.pref.previewTabNameBefore.label;" />
<textbox id="zotero-prefpane-__addonRef__-settings-previewTabName" preference="pref-__addonRef__-previewTabName" />
<label value="&zotero.__addonRef__.pref.previewTabNameAfter.label;" />
</row>
</rows>
</prefpane>
</prefwindow>
Expand Down
2 changes: 2 additions & 0 deletions addon/chrome/locale/en-US/overlay.dtd
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
<!ENTITY zotero.__addonRef__.pref.autoPreview.label "Auto Preview PDF">
<!ENTITY zotero.__addonRef__.pref.previewPageNumBefore.label "Preview First">
<!ENTITY zotero.__addonRef__.pref.previewPageNumAfter.label "Pages">
<!ENTITY zotero.__addonRef__.pref.previewTabNameBefore.label "Preview Tab Name">
<!ENTITY zotero.__addonRef__.pref.previewTabNameAfter.label "(Restart Zotero to Apply Changes)">

<!ENTITY zotero.__addonRef__.tab.label "Preview">

Expand Down
2 changes: 2 additions & 0 deletions addon/chrome/locale/zh-CN/overlay.dtd
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
<!ENTITY zotero.__addonRef__.pref.autoPreview.label "自动预览PDF">
<!ENTITY zotero.__addonRef__.pref.previewPageNumBefore.label "预览前">
<!ENTITY zotero.__addonRef__.pref.previewPageNumAfter.label "页">
<!ENTITY zotero.__addonRef__.pref.previewTabNameBefore.label "预览标签名称">
<!ENTITY zotero.__addonRef__.pref.previewTabNameAfter.label "(重启Zotero以应用更改)">

<!ENTITY zotero.__addonRef__.tab.label "预览">

Expand Down
1 change: 1 addition & 0 deletions addon/defaults/preferences/defaults.js
Original file line number Diff line number Diff line change
@@ -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");
9 changes: 9 additions & 0 deletions src/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class AddonEvents extends AddonBase {
await Zotero.uiReadyPromise;
this.initItemSelectListener();
this.initPreviewResizeListener();
this.updatePreviewTabName();
}

private initItemSelectListener() {
Expand All @@ -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;

0 comments on commit 138ebe4

Please sign in to comment.