From ab6b683d901bece556efd84a3dbce20a25a8625e Mon Sep 17 00:00:00 2001 From: Abe Jellinek Date: Thu, 7 Jul 2022 00:04:13 -0400 Subject: [PATCH] fx-compat: More progress on platform menus (#2675) Not able to test on non-Mac yet, but this behavior should be right. Removes all the #ifdefs and moves the behavior into platformKeys.js. --- chrome/content/zotero/platformKeys.js | 40 +++++++++++++-- chrome/content/zotero/zoteroPane.xhtml | 68 +++++++++++--------------- 2 files changed, 64 insertions(+), 44 deletions(-) diff --git a/chrome/content/zotero/platformKeys.js b/chrome/content/zotero/platformKeys.js index c49f68d62a..ec1948ecd8 100644 --- a/chrome/content/zotero/platformKeys.js +++ b/chrome/content/zotero/platformKeys.js @@ -1,14 +1,46 @@ window.addEventListener('DOMContentLoaded', () => { + // Don't need to depend on Zotero object here + let isWin = AppConstants.platform == 'win'; + let isMac = AppConstants.platform == 'macosx'; + let redoKey = document.getElementById('key_redo'); - if (redoKey) { - // Don't need to depend on Zotero object here - if (AppConstants.platform == 'win') { + + let fileQuitSeparator = document.getElementById('menu_NonMacFileQuitSeparator'); + let fileQuitItem = document.getElementById('menu_NonMacFileQuitItem'); + + let editPreferencesSeparator = document.getElementById('menu_EditPreferencesSeparator'); + let editPreferencesItem = document.getElementById('menu_EditPreferencesItem'); + + let applicationMenu = document.getElementById('mac_application_menu'); + let windowMenu = document.getElementById('windowMenu'); + let macKeyset = document.getElementById('macKeyset'); + + if (isWin) { + // Set behavior on Windows only + if (redoKey) { redoKey.setAttribute('data-l10n-id', 'text-action-redo-shortcut'); redoKey.setAttribute('modifiers', 'accel'); } - else { + } + else { + // Set behavior on all non-Windows platforms + if (redoKey) { redoKey.setAttribute('data-l10n-id', 'text-action-undo-shortcut'); redoKey.setAttribute('modifiers', 'accel,shift'); } } + + if (isMac) { + // Set behavior on macOS only + if (fileQuitSeparator) fileQuitSeparator.hidden = true; + if (fileQuitItem) fileQuitItem.hidden = true; + if (editPreferencesSeparator) editPreferencesSeparator.hidden = true; + if (editPreferencesItem) editPreferencesItem.hidden = true; + } + else { + // Set behavior on all non-macOS platforms + if (applicationMenu) applicationMenu.hidden = true; + if (windowMenu) windowMenu.hidden = true; + if (macKeyset) macKeyset.disabled = true; + } }); diff --git a/chrome/content/zotero/zoteroPane.xhtml b/chrome/content/zotero/zoteroPane.xhtml index 4eea1fe43b..a0e2093ca1 100644 --- a/chrome/content/zotero/zoteroPane.xhtml +++ b/chrome/content/zotero/zoteroPane.xhtml @@ -175,7 +175,29 @@ the children can be modified. All non-menu nodes are ignored --> + style="border:0px;padding:0px;margin:0px;-moz-appearance:none"> + + + + + + + + + + @@ -217,15 +239,11 @@ command="cmd_zotero_importFromClipboard" key="key_importFromClipboard"/> - @@ -287,15 +305,9 @@ command="cmd_switchTextDirection" key="key_switchTextDirection" hidden="true" data-l10n-id="menu-edit-bidi-switch-text-direction"/> - + + @@ -548,7 +560,6 @@ - - - - - - - - - - - -