diff --git a/chrome/content/zotero-platform/unix/overlay.css b/chrome/content/zotero-platform/unix/overlay.css index 5fb28ea65a..fba2f7c8b6 100644 --- a/chrome/content/zotero-platform/unix/overlay.css +++ b/chrome/content/zotero-platform/unix/overlay.css @@ -73,10 +73,6 @@ tab { -moz-appearance: textfield; } -#zotero-prefs #noteFontSize { - min-width: 3.8em; -} - #zotero-pane splitter { border: 0; width: 6px; diff --git a/chrome/content/zotero/preferences/preferences_general.js b/chrome/content/zotero/preferences/preferences_general.js index 883cf8e7f1..73c261fa63 100644 --- a/chrome/content/zotero/preferences/preferences_general.js +++ b/chrome/content/zotero/preferences/preferences_general.js @@ -38,8 +38,6 @@ Zotero_Preferences.General = { ); } - document.getElementById('noteFontSize').value = Zotero.Prefs.get('note.fontSize'); - this.updateAutoRenameFilesUI(); this._updateFileHandlerUI(); }, diff --git a/chrome/content/zotero/preferences/preferences_general.xul b/chrome/content/zotero/preferences/preferences_general.xul index aa021b424f..cb86b27d62 100644 --- a/chrome/content/zotero/preferences/preferences_general.xul +++ b/chrome/content/zotero/preferences/preferences_general.xul @@ -31,9 +31,6 @@ helpTopic="general"> - - - @@ -50,67 +47,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/chrome/content/zotero/standalone/standalone.js b/chrome/content/zotero/standalone/standalone.js index 038d6533e9..3c4d4980f8 100644 --- a/chrome/content/zotero/standalone/standalone.js +++ b/chrome/content/zotero/standalone/standalone.js @@ -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 // diff --git a/chrome/content/zotero/standalone/standalone.xul b/chrome/content/zotero/standalone/standalone.xul index 901350b30e..5a36486ab0 100644 --- a/chrome/content/zotero/standalone/standalone.xul +++ b/chrome/content/zotero/standalone/standalone.xul @@ -184,6 +184,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - diff --git a/chrome/locale/en-US/zotero/standalone.dtd b/chrome/locale/en-US/zotero/standalone.dtd index e389966d89..0743d89005 100644 --- a/chrome/locale/en-US/zotero/standalone.dtd +++ b/chrome/locale/en-US/zotero/standalone.dtd @@ -42,6 +42,18 @@ + + + + + + + + + + + + diff --git a/chrome/locale/en-US/zotero/zotero.dtd b/chrome/locale/en-US/zotero/zotero.dtd index 639d98b1a7..1147537097 100644 --- a/chrome/locale/en-US/zotero/zotero.dtd +++ b/chrome/locale/en-US/zotero/zotero.dtd @@ -18,6 +18,9 @@ + + + diff --git a/chrome/skin/default/zotero/preferences.css b/chrome/skin/default/zotero/preferences.css index e1f5364e95..bf2b547095 100644 --- a/chrome/skin/default/zotero/preferences.css +++ b/chrome/skin/default/zotero/preferences.css @@ -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; }