Add View menu

The menu includes all user interface options from the General
preferences (now removed from the preferences), toggles for the
collections pane, item pane, and tag selector, and, at long last, a
toggle for recursive collections ("Display Items from Subcollections").

The collections pane and item pane no longer reopen automatically when
restarting Zotero. People might still close them by mistake and not find
this menu, but we'll see how it goes.

Closes #1372
This commit is contained in:
Dan Stillman 2019-08-12 16:18:46 -04:00
parent 6f721098f8
commit 3aeef69ad3
10 changed files with 288 additions and 115 deletions

View file

@ -73,10 +73,6 @@ tab {
-moz-appearance: textfield;
}
#zotero-prefs #noteFontSize {
min-width: 3.8em;
}
#zotero-pane splitter {
border: 0;
width: 6px;

View file

@ -38,8 +38,6 @@ Zotero_Preferences.General = {
);
}
document.getElementById('noteFontSize').value = Zotero.Prefs.get('note.fontSize');
this.updateAutoRenameFilesUI();
this._updateFileHandlerUI();
},

View file

@ -31,9 +31,6 @@
helpTopic="general">
<preferences id="zotero-prefpane-general-preferences">
<preference id="pref-fontSize" name="extensions.zotero.fontSize" type="string"/>
<preference id="pref-layout" name="extensions.zotero.layout" type="string"/>
<preference id="pref-automaticSnapshots" name="extensions.zotero.automaticSnapshots" type="bool"/>
<preference id="pref-downloadAssociatedFiles" name="extensions.zotero.downloadAssociatedFiles" type="bool"/>
<preference id="pref-autoRecognizeFiles" name="extensions.zotero.autoRecognizeFiles" type="bool"/>
@ -50,67 +47,6 @@
</preferences>
<groupbox id="zotero-prefpane-general-groupbox">
<caption label="&zotero.preferences.userInterface;"/>
<grid id="zotero-prefpane-general-grid">
<columns>
<column/>
<column flex="1"/>
</columns>
<rows id="zotero-prefpane-general-rows">
<row>
<hbox align="center">
<label value="&zotero.preferences.layout;" control="layout"/>
</hbox>
<radiogroup id="layout" orient="horizontal" align="center" preference="pref-layout">
<radio id="horizontal" label="&zotero.preferences.layout.standard;" value="standard"/>
<radio id="vertical" label="&zotero.preferences.layout.stacked;" value="stacked"/>
</radiogroup>
</row>
<row>
<hbox align="center">
<label value="&zotero.preferences.fontSize;" control="fontSize"/>
</hbox>
<radiogroup id="fontSize" orient="horizontal" align="center" preference="pref-fontSize">
<radio id="fontSize1" label="&zotero.preferences.fontSize.small;" value="1.0"/>
<radio id="fontSize2" label="&zotero.preferences.fontSize.medium;" value="1.15"/>
<radio id="fontSize3" label="&zotero.preferences.fontSize.large;" value="1.3"/>
<radio id="fontSize4" label="&zotero.preferences.fontSize.xlarge;" value="1.5"/>
</radiogroup>
</row>
<row>
<hbox align="center">
<label value="&zotero.preferences.fontSize.notes;" control="noteFontSize"/>
</hbox>
<hbox>
<menulist id="noteFontSize" editable="true"
onblur="Zotero.Prefs.set('note.fontSize', this.value); this.value = Zotero.Prefs.get('note.fontSize');">
<menupopup>
<menuitem label="11"/>
<menuitem label="12"/>
<menuitem label="13"/>
<menuitem label="14"/>
<menuitem label="18"/>
<menuitem label="24"/>
<menuitem label="36"/>
<menuitem label="48"/>
<menuitem label="64"/>
<menuitem label="72"/>
<menuitem label="96"/>
</menupopup>
</menulist>
<label class="statusLine" value="&zotero.preferences.keys.changesTakeEffect;"/>
</hbox>
</row>
</rows>
</grid>
</groupbox>
<groupbox id="zotero-prefpane-file-handling-groupbox">
<caption label="&zotero.preferences.fileHandling;"/>

View file

@ -29,6 +29,10 @@ Components.utils.import("resource://gre/modules/Services.jsm");
* This object contains the various functions for the interface
*/
const ZoteroStandalone = new function() {
const FONT_SIZES = ["1.0", "1.15", "1.3", "1.5", "1.7", "1.9", "2.1"];
//const NOTE_FONT_SIZES = ["11", "12", "13", "14", "18", "24", "36", "48", "64", "72", "96"];
const NOTE_FONT_SIZE_DEFAULT = "12";
/**
* Run when standalone window first opens
*/
@ -174,6 +178,216 @@ const ZoteroStandalone = new function() {
};
this.onViewMenuOpen = function () {
// Layout mode
var mode = Zotero.Prefs.get('layout');
this.updateMenuItemCheckmark('standard', mode != 'stacked');
this.updateMenuItemCheckmark('stacked', mode == 'stacked');
// Panes
this.updateMenuItemCheckmark(
'collections-pane',
document.getElementById('zotero-collections-pane').getAttribute('collapsed') != 'true'
);
this.updateMenuItemCheckmark(
'item-pane',
document.getElementById('zotero-item-pane').getAttribute('collapsed') != 'true'
);
this.updateMenuItemCheckmark(
'tag-selector',
document.getElementById('zotero-tag-selector-container').getAttribute('collapsed') != 'true'
);
// Font size
var fontSize = Zotero.Prefs.get('fontSize');
this.updateMenuItemDisabled('font-size-bigger', fontSize >= FONT_SIZES[FONT_SIZES.length - 1]);
this.updateMenuItemDisabled('font-size-smaller', fontSize <= FONT_SIZES[0]);
this.updateMenuItemDisabled('font-size-reset', fontSize == FONT_SIZES[0]);
var noteFontSize = Zotero.Prefs.get('note.fontSize');
for (let menuitem of document.querySelectorAll(`#note-font-size-menu menuitem`)) {
if (parseInt(menuitem.getAttribute('label')) == noteFontSize) {
menuitem.setAttribute('checked', true);
}
else {
menuitem.removeAttribute('checked');
}
}
this.updateMenuItemDisabled('note-font-size-reset', noteFontSize == NOTE_FONT_SIZE_DEFAULT);
// Recursive collections
this.updateMenuItemCheckmark('recursive-collections', Zotero.Prefs.get('recursiveCollections'));
};
this.updateMenuItemCheckmark = function (idSuffix, checked) {
var id = 'view-menuitem-' + idSuffix;
var menuitem = document.getElementById(id);
if (checked) {
menuitem.setAttribute('checked', true);
}
else {
menuitem.removeAttribute('checked');
}
};
this.updateMenuItemDisabled = function (idSuffix, disabled) {
var id = 'view-menuitem-' + idSuffix;
var menuitem = document.getElementById(id);
if (disabled) {
menuitem.setAttribute('disabled', true);
}
else {
menuitem.removeAttribute('disabled');
}
};
this.updateViewOption = function (event) {
var menuitem = event.originalTarget;
var id = menuitem.id;
if (menuitem.disabled || !id.startsWith('view-menuitem-')) {
return;
}
id = id.substr(14);
switch (id) {
case 'standard':
Zotero.Prefs.set('layout', 'standard');
break;
case 'stacked':
Zotero.Prefs.set('layout', 'stacked');
break;
case 'collections-pane':
// Show
if (menuitem.getAttribute('checked') != 'true') {
document.getElementById('zotero-collections-splitter').setAttribute('state', 'open');
document.getElementById('zotero-collections-pane').setAttribute('collapsed', false);
}
// Hide
else {
document.getElementById('zotero-collections-splitter').setAttribute('state', 'collapsed');
document.getElementById('zotero-collections-pane').setAttribute('collapsed', true);
}
ZoteroPane.updateToolbarPosition();
break;
case 'item-pane':
// Show
if (menuitem.getAttribute('checked') != 'true') {
document.getElementById('zotero-items-splitter').setAttribute('state', 'open');
document.getElementById('zotero-item-pane').setAttribute('collapsed', false);
}
// Hide
else {
document.getElementById('zotero-items-splitter').setAttribute('state', 'collapsed');
document.getElementById('zotero-item-pane').setAttribute('collapsed', true);
}
ZoteroPane.updateToolbarPosition();
break;
case 'tag-selector':
ZoteroPane.toggleTagSelector();
break;
case 'font-size-bigger':
increaseFontSize('fontSize', FONT_SIZES);
break;
case 'font-size-smaller':
decreaseFontSize('fontSize', FONT_SIZES);
break;
case 'font-size-reset':
Zotero.Prefs.clear('fontSize');
break;
/*case 'note-font-size-bigger':
increaseFontSize('note.fontSize', NOTE_FONT_SIZES);
break;
case 'note-font-size-smaller':
decreaseFontSize('note.fontSize', NOTE_FONT_SIZES);
break;
*/
case 'note-font-size-reset':
Zotero.Prefs.clear('note.fontSize');
this.promptForRestart();
break;
case 'recursive-collections':
this.toggleBooleanPref('recursiveCollections');
break;
}
};
this.toggleBooleanPref = function (pref) {
Zotero.Prefs.set(pref, !Zotero.Prefs.get(pref));
};
function decreaseFontSize(pref, sizes) {
var fontSize = Zotero.Prefs.get(pref);
var lastSize = fontSize;
// Get the highest font size below the current one
for (let i = sizes.length - 1; i >= 0; i--) {
if (fontSize > sizes[i]) {
lastSize = sizes[i];
break;
}
}
Zotero.Prefs.set(pref, lastSize);
}
function increaseFontSize(pref, sizes) {
var fontSize = Zotero.Prefs.get(pref);
var lastSize = fontSize;
// Get the font size above the current one
for (let i = 0; i < sizes.length; i++) {
if (sizes[i] > fontSize) {
lastSize = sizes[i];
break;
}
}
Zotero.Prefs.set(pref, lastSize);
}
this.updateNoteFontSize = function (event) {
var size = event.originalTarget.getAttribute('label');
Zotero.Prefs.set('note.fontSize', size);
this.promptForRestart();
};
this.promptForRestart = function () {
// Prompt to restart
var ps = Services.prompt;
var buttonFlags = ps.BUTTON_POS_0 * ps.BUTTON_TITLE_IS_STRING
+ ps.BUTTON_POS_1 * ps.BUTTON_TITLE_IS_STRING;
var index = ps.confirmEx(
null,
Zotero.getString('general.restartRequired'),
Zotero.getString('general.restartRequiredForChange', [ZOTERO_CONFIG.CLIENT_NAME]),
buttonFlags,
Zotero.getString('general.restartNow'),
Zotero.getString('general.restartLater'),
null, null, {}
);
if (index == 0) {
Zotero.Utilities.Internal.quitZotero(true);
}
};
this.updateAddonsPane = function (doc) {
// Hide unsigned add-on verification warnings
//

View file

@ -184,6 +184,64 @@
</menupopup>
</menu>
<menu id="view-menu"
label="&viewMenu.label;"
onpopupshowing="ZoteroStandalone.onViewMenuOpen()">
<menupopup id="menu_viewPopup">
<menu id="layout-menu"
label="&layout.label;">
<menupopup oncommand="ZoteroStandalone.updateViewOption(event)">
<menuitem id="view-menuitem-standard" label="&standardView.label;"/>
<menuitem id="view-menuitem-stacked" label="&stackedView.label;"/>
<menuseparator/>
<menuitem id="view-menuitem-collections-pane" label="&collectionsPane.label;"/>
<menuitem id="view-menuitem-item-pane" label="&itemPane.label;"/>
<menuitem id="view-menuitem-tag-selector" label="&tagSelector.label;"/>
</menupopup>
</menu>
<menu id="font-size-menu"
label="&fontSize.label;">
<menupopup oncommand="ZoteroStandalone.updateViewOption(event)">
<menuitem id="view-menuitem-font-size-bigger" label="&zotero.general.bigger;"/>
<menuitem id="view-menuitem-font-size-smaller" label="&zotero.general.smaller;"/>
<menuseparator/>
<menuitem id="view-menuitem-font-size-reset" label="&zotero.general.reset;"/>
</menupopup>
</menu>
<menu id="note-font-size-menu"
label="&noteFontSize.label;">
<!-- TODO: Maybe switch to Bigger/Smaller once we can update without restarting -->
<!--<menupopup oncommand="ZoteroStandalone.updateViewOption(event)">
<menuitem id="view-menuitem-note-font-size-bigger" label="&zotero.general.bigger;"/>
<menuitem id="view-menuitem-note-font-size-smaller" label="&zotero.general.smaller;"/>
<menuseparator/>
<menuitem id="view-menuitem-note-font-size-reset" label="&zotero.general.reset;"/>-->
<menupopup oncommand="ZoteroStandalone.updateNoteFontSize(event)">
<menuitem label="11"/>
<menuitem label="12"/>
<menuitem label="13"/>
<menuitem label="14"/>
<menuitem label="18"/>
<menuitem label="24"/>
<menuitem label="36"/>
<menuitem label="48"/>
<menuitem label="64"/>
<menuitem label="72"/>
<menuitem label="96"/>
<menuitem/>
<menuitem
id="view-menuitem-note-font-size-reset"
label="&zotero.general.reset;"
oncommand="ZoteroStandalone.updateViewOption(event); event.stopPropagation();"/>
</menupopup>
</menu>
<menuseparator/>
<menuitem id="view-menuitem-recursive-collections"
label="&recursiveCollections.label;"
oncommand="ZoteroStandalone.updateViewOption(event)"/>
</menupopup>
</menu>
<menu id="toolsMenu" label="&toolsMenu.label;" accesskey="&toolsMenu.accesskey;">
<menupopup id="menu_ToolsPopup">
<menuitem id="menu_createTimeline" label="&zotero.toolbar.timeline.label;"

View file

@ -1126,6 +1126,7 @@ var ZoteroPane = new function()
});
// Keep in sync with ZoteroStandalone.updateViewOption()
this.toggleTagSelector = function () {
var container = document.getElementById('zotero-tag-selector-container');
var showing = container.getAttribute('collapsed') == 'true';
@ -4889,9 +4890,6 @@ var ZoteroPane = new function()
if(!el) return;
var elValues = serializedValues[id];
for(var attr in elValues) {
// TEMP: For now, ignore persisted collapsed state for collection and item pane splitters
if ((el.id == 'zotero-collections-splitter' || el.id == 'zotero-items-splitter')
&& attr == 'state') continue;
el.setAttribute(attr, elValues[attr]);
}
}

View file

@ -8,17 +8,6 @@
<!ENTITY zotero.preferences.prefpane.general "General">
<!ENTITY zotero.preferences.userInterface "User Interface">
<!ENTITY zotero.preferences.layout "Layout:">
<!ENTITY zotero.preferences.layout.standard "Standard">
<!ENTITY zotero.preferences.layout.stacked "Stacked">
<!ENTITY zotero.preferences.fontSize "Font size:">
<!ENTITY zotero.preferences.fontSize.small "Small">
<!ENTITY zotero.preferences.fontSize.medium "Medium">
<!ENTITY zotero.preferences.fontSize.large "Large">
<!ENTITY zotero.preferences.fontSize.xlarge "X-Large">
<!ENTITY zotero.preferences.fontSize.notes "Note font size:">
<!ENTITY zotero.preferences.fileHandling "File Handling">
<!ENTITY zotero.preferences.automaticSnapshots "Automatically take snapshots when creating items from web pages">
<!ENTITY zotero.preferences.downloadAssociatedFiles "Automatically attach associated PDFs and other files when saving items">

View file

@ -42,6 +42,18 @@
<!ENTITY bidiSwitchTextDirectionItem.accesskey "w">
<!ENTITY bidiSwitchTextDirectionItem.commandkey "X">
<!--VIEW MENU-->
<!ENTITY viewMenu.label "View">
<!ENTITY layout.label "Layout">
<!ENTITY standardView.label "Standard View">
<!ENTITY stackedView.label "Stacked View">
<!ENTITY collectionsPane.label "Collections Pane">
<!ENTITY itemPane.label "Item Pane">
<!ENTITY tagSelector.label "Tag Selector">
<!ENTITY recursiveCollections.label "Show Items from Subcollections">
<!ENTITY fontSize.label "Font Size">
<!ENTITY noteFontSize.label "Note Font Size">
<!--TOOLS MENU-->
<!ENTITY toolsMenu.label "Tools">
<!ENTITY toolsMenu.accesskey "T">

View file

@ -18,6 +18,9 @@
<!ENTITY zotero.general.close "Close">
<!ENTITY zotero.general.minimize "Minimize">
<!ENTITY zotero.general.other "Other…">
<!ENTITY zotero.general.bigger "Bigger">
<!ENTITY zotero.general.smaller "Smaller">
<!ENTITY zotero.general.reset "Reset">
<!ENTITY zotero.errorReport.title "Zotero Error Report">

View file

@ -52,37 +52,6 @@ grid row hbox:first-child
-moz-box-pack: end; /* Right-justify left column */
}
#fontSize
{
font-size: 3mm; /* Firefox default */
}
#fontSize1
{
font-size: 1.0em;
}
#fontSize2
{
font-size: 1.15em;
}
#fontSize3
{
font-size: 1.3em;
}
#fontSize4
{
font-size: 1.5em;
}
#fontSize radio
{
margin-right: 20px;
}
#zotero-prefpane-general .statusLine {
margin-left: .75em;
}