Add pref to control auto-turnoff of note, text, image annotation tools (#4851)
This commit is contained in:
parent
ddacfc0b8a
commit
75fb301f0a
6 changed files with 56 additions and 2 deletions
|
@ -59,6 +59,7 @@ Zotero_Preferences.General = {
|
|||
this.updateAutoRenameFilesUI();
|
||||
this._updateFileHandlerUI();
|
||||
this._initEbookFontFamilyMenu();
|
||||
this._initAutoDisableToolCheckbox();
|
||||
},
|
||||
|
||||
_getAutomaticLocaleMenuLabel: function () {
|
||||
|
@ -548,4 +549,32 @@ Zotero_Preferences.General = {
|
|||
popup.append(menuitem);
|
||||
}
|
||||
},
|
||||
|
||||
_initAutoDisableToolCheckbox() {
|
||||
let checkbox = document.getElementById('auto-disable-tool');
|
||||
checkbox.addEventListener('command', () => {
|
||||
let value = checkbox.checked;
|
||||
Zotero.Prefs.set('reader.autoDisableTool.note', value);
|
||||
Zotero.Prefs.set('reader.autoDisableTool.text', value);
|
||||
Zotero.Prefs.set('reader.autoDisableTool.image', value);
|
||||
checkbox.querySelector('.checkbox-check').style.opacity = 'unset';
|
||||
});
|
||||
|
||||
let values = [
|
||||
Zotero.Prefs.get('reader.autoDisableTool.note'),
|
||||
Zotero.Prefs.get('reader.autoDisableTool.text'),
|
||||
Zotero.Prefs.get('reader.autoDisableTool.image')
|
||||
];
|
||||
if (values.every(x => x)) {
|
||||
checkbox.checked = true;
|
||||
}
|
||||
else if (values.every(x => !x)) {
|
||||
checkbox.checked = false;
|
||||
}
|
||||
else {
|
||||
checkbox.checked = true;
|
||||
// XUL checkbox doesn't support 'indeterminate' property, therefore making it grayish instead
|
||||
checkbox.querySelector('.checkbox-check').style.opacity = '0.5';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -218,7 +218,15 @@
|
|||
</menupopup>
|
||||
</menulist>
|
||||
</hbox>
|
||||
|
||||
|
||||
<vbox>
|
||||
<checkbox
|
||||
id="auto-disable-tool"
|
||||
data-l10n-id="preferences-reader-auto-disable-tool"
|
||||
native="true"
|
||||
/>
|
||||
</vbox>
|
||||
|
||||
<hbox align="center">
|
||||
<label data-l10n-id="preferences-reader-ebook-font" control="reader-ebook-font-family"/>
|
||||
<menulist id="reader-ebook-font-family" preference="extensions.zotero.reader.ebookFontFamily" native="true">
|
||||
|
|
|
@ -210,6 +210,9 @@ class ReaderInstance {
|
|||
useDarkModeForContent: Zotero.Prefs.get('reader.contentDarkMode'),
|
||||
fontFamily: Zotero.Prefs.get('reader.ebookFontFamily'),
|
||||
hyphenation: Zotero.Prefs.get('reader.ebookHyphenate'),
|
||||
autoDisableNoteTool: Zotero.Prefs.get('reader.autoDisableTool.note'),
|
||||
autoDisableTextTool: Zotero.Prefs.get('reader.autoDisableTool.text'),
|
||||
autoDisableImageTool: Zotero.Prefs.get('reader.autoDisableTool.image'),
|
||||
onOpenContextMenu: () => {
|
||||
// Functions can only be passed over wrappedJSObject (we call back onClick for context menu items)
|
||||
this._openContextMenu(this._iframeWindow.wrappedJSObject.contextMenuParams);
|
||||
|
@ -555,6 +558,9 @@ class ReaderInstance {
|
|||
Zotero.Prefs.registerObserver('reader.contentDarkMode', this._handleContentDarkModeChange),
|
||||
Zotero.Prefs.registerObserver('reader.ebookFontFamily', this._handleEbookPrefChange),
|
||||
Zotero.Prefs.registerObserver('reader.ebookHyphenate', this._handleEbookPrefChange),
|
||||
Zotero.Prefs.registerObserver('reader.autoDisableTool.note', this._handleAutoDisableToolPrefChange),
|
||||
Zotero.Prefs.registerObserver('reader.autoDisableTool.text', this._handleAutoDisableToolPrefChange),
|
||||
Zotero.Prefs.registerObserver('reader.autoDisableTool.image', this._handleAutoDisableToolPrefChange),
|
||||
];
|
||||
|
||||
return true;
|
||||
|
@ -1014,6 +1020,12 @@ class ReaderInstance {
|
|||
this._internalReader.setHyphenate(Zotero.Prefs.get('reader.ebookHyphenate'));
|
||||
};
|
||||
|
||||
_handleAutoDisableToolPrefChange = () => {
|
||||
this._internalReader.setAutoDisableNoteTool(Zotero.Prefs.get('reader.autoDisableTool.note'));
|
||||
this._internalReader.setAutoDisableTextTool(Zotero.Prefs.get('reader.autoDisableTool.text'));
|
||||
this._internalReader.setAutoDisableImageTool(Zotero.Prefs.get('reader.autoDisableTool.image'));
|
||||
};
|
||||
|
||||
_dataURLtoBlob(dataurl) {
|
||||
let parts = dataurl.split(',');
|
||||
let mime = parts[0].match(/:(.*?);/)[1];
|
||||
|
|
|
@ -36,6 +36,8 @@ preferences-reader-open-epubs-using = Open EPUBs using
|
|||
preferences-reader-open-snapshots-using = Open snapshots using
|
||||
preferences-reader-open-in-new-window =
|
||||
.label = Open files in new windows instead of tabs
|
||||
preferences-reader-auto-disable-tool =
|
||||
.label = Turn off note, text, and image annotation tools after each use
|
||||
preferences-reader-ebook-font = Ebook font:
|
||||
preferences-reader-ebook-hyphenate =
|
||||
.label = Enable automatic hyphenation
|
||||
|
|
|
@ -227,6 +227,9 @@ pref("extensions.zotero.reader.textSelectionAnnotationMode", "highlight");
|
|||
pref("extensions.zotero.reader.contentDarkMode", true);
|
||||
pref("extensions.zotero.reader.ebookFontFamily", "Georgia, serif");
|
||||
pref("extensions.zotero.reader.ebookHyphenate", true);
|
||||
pref("extensions.zotero.reader.autoDisableTool.note", true);
|
||||
pref("extensions.zotero.reader.autoDisableTool.text", true);
|
||||
pref("extensions.zotero.reader.autoDisableTool.image", true);
|
||||
|
||||
// Set color scheme to auto by default
|
||||
pref("browser.theme.toolbar-theme", 2);
|
||||
|
|
2
reader
2
reader
|
@ -1 +1 @@
|
|||
Subproject commit 4643dccca930f643a9f79a2722b664358fb2c1f9
|
||||
Subproject commit e62baf16ecaac54469f2ea8b4fbd14cd7c5ca01e
|
Loading…
Reference in a new issue