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.
This commit is contained in:
parent
9a8e78aaf4
commit
ab6b683d90
2 changed files with 64 additions and 44 deletions
|
@ -1,14 +1,46 @@
|
||||||
window.addEventListener('DOMContentLoaded', () => {
|
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');
|
let redoKey = document.getElementById('key_redo');
|
||||||
if (redoKey) {
|
|
||||||
// Don't need to depend on Zotero object here
|
let fileQuitSeparator = document.getElementById('menu_NonMacFileQuitSeparator');
|
||||||
if (AppConstants.platform == 'win') {
|
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('data-l10n-id', 'text-action-redo-shortcut');
|
||||||
redoKey.setAttribute('modifiers', 'accel');
|
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('data-l10n-id', 'text-action-undo-shortcut');
|
||||||
redoKey.setAttribute('modifiers', 'accel,shift');
|
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;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -175,7 +175,29 @@
|
||||||
the children can be modified. All non-menu nodes are ignored
|
the children can be modified. All non-menu nodes are ignored
|
||||||
-->
|
-->
|
||||||
<menubar id="main-menubar"
|
<menubar id="main-menubar"
|
||||||
style="border:0px;padding:0px;margin:0px;-moz-appearance:none">
|
style="border:0px;padding:0px;margin:0px;-moz-appearance:none">
|
||||||
|
<!-- nsMenuBarX hides these and uses them to build the Application menu. -->
|
||||||
|
<menupopup id="mac_application_menu">
|
||||||
|
<menuitem id="menu_preferences"
|
||||||
|
label="&preferencesCmdMac.label;"
|
||||||
|
key="key_preferencesCmdMac"
|
||||||
|
oncommand="Zotero.Utilities.Internal.openPreferences()"/>
|
||||||
|
<menuitem id="menu_mac_services"
|
||||||
|
label="&servicesMenuMac.label;"/>
|
||||||
|
<menuitem id="menu_mac_hide_app"
|
||||||
|
label="&hideThisAppCmdMac.label;"
|
||||||
|
key="key_hideThisAppCmdMac"/>
|
||||||
|
<menuitem id="menu_mac_hide_others"
|
||||||
|
label="&hideOtherAppsCmdMac.label;"
|
||||||
|
key="key_hideOtherAppsCmdMac"/>
|
||||||
|
<menuitem id="menu_mac_show_all"
|
||||||
|
label="&showAllAppsCmdMac.label;"/>
|
||||||
|
<menuitem id="menu_FileQuitItem"
|
||||||
|
label="&quitApplicationCmdMac.label;"
|
||||||
|
key="key_quitApplication"
|
||||||
|
command="cmd_quitApplication"/>
|
||||||
|
</menupopup>
|
||||||
|
|
||||||
<!-- File menu -->
|
<!-- File menu -->
|
||||||
<menu id="fileMenu" label="&fileMenu.label;" accesskey="&fileMenu.accesskey;"
|
<menu id="fileMenu" label="&fileMenu.label;" accesskey="&fileMenu.accesskey;"
|
||||||
onpopupshowing="ZoteroStandalone.onFileMenuOpen()">
|
onpopupshowing="ZoteroStandalone.onFileMenuOpen()">
|
||||||
|
@ -217,15 +239,11 @@
|
||||||
command="cmd_zotero_importFromClipboard" key="key_importFromClipboard"/>
|
command="cmd_zotero_importFromClipboard" key="key_importFromClipboard"/>
|
||||||
<menuitem id="menu_exportLibrary" class="menu-type-library" label="&zotero.toolbar.export.label;"
|
<menuitem id="menu_exportLibrary" class="menu-type-library" label="&zotero.toolbar.export.label;"
|
||||||
command="cmd_zotero_exportLibrary"/>
|
command="cmd_zotero_exportLibrary"/>
|
||||||
<!--
|
<menuseparator id="menu_NonMacFileQuitSeparator"/>
|
||||||
#ifdef XP_WIN
|
<menuitem id="menu_NonMacFileQuitItem"
|
||||||
<menuseparator/>
|
|
||||||
<menuitem id="menu_FileQuitItem"
|
|
||||||
label="&quitApplicationCmdWin.label;"
|
label="&quitApplicationCmdWin.label;"
|
||||||
key="key_quitApplication"
|
key="key_quitApplication"
|
||||||
command="cmd_quitApplication"/>
|
command="cmd_quitApplication"/>
|
||||||
#endif
|
|
||||||
-->
|
|
||||||
</menupopup>
|
</menupopup>
|
||||||
</menu>
|
</menu>
|
||||||
|
|
||||||
|
@ -287,15 +305,9 @@
|
||||||
command="cmd_switchTextDirection"
|
command="cmd_switchTextDirection"
|
||||||
key="key_switchTextDirection"
|
key="key_switchTextDirection"
|
||||||
hidden="true" data-l10n-id="menu-edit-bidi-switch-text-direction"/>
|
hidden="true" data-l10n-id="menu-edit-bidi-switch-text-direction"/>
|
||||||
<!--
|
<menuseparator id="menu_EditPreferencesSeparator"/>
|
||||||
#ifdef XP_UNIX
|
<menuitem id="menu_EditPreferencesItem"
|
||||||
#ifndef XP_MACOSX
|
oncommand="Zotero.Utilities.Internal.openPreferences()" data-l10n-id="menu-settings"/>
|
||||||
<menuseparator/>
|
|
||||||
<menuitem id="menu_preferences"
|
|
||||||
oncommand="Zotero.Utilities.Internal.openPreferences()" data-l10n-id="menu-preferences"/>
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
-->
|
|
||||||
</menupopup>
|
</menupopup>
|
||||||
</menu>
|
</menu>
|
||||||
|
|
||||||
|
@ -548,7 +560,6 @@
|
||||||
</menupopup>
|
</menupopup>
|
||||||
</menu>
|
</menu>
|
||||||
|
|
||||||
<!-- ifdef mac -->
|
|
||||||
<commandset id="macCommandSet"> <!-- was mainCommandSet -->
|
<commandset id="macCommandSet"> <!-- was mainCommandSet -->
|
||||||
<command id="minimizeWindow"
|
<command id="minimizeWindow"
|
||||||
label="&minimizeWindow.label;"
|
label="&minimizeWindow.label;"
|
||||||
|
@ -588,28 +599,6 @@
|
||||||
internal="true"/>
|
internal="true"/>
|
||||||
</keyset>
|
</keyset>
|
||||||
|
|
||||||
<!-- nsMenuBarX hides these and uses them to build the Application menu. -->
|
|
||||||
<menupopup id="menu_FilePopup">
|
|
||||||
<menuitem id="menu_preferences"
|
|
||||||
label="&preferencesCmdMac.label;"
|
|
||||||
key="key_preferencesCmdMac"
|
|
||||||
oncommand="Zotero.Utilities.Internal.openPreferences()"/>
|
|
||||||
<menuitem id="menu_mac_services"
|
|
||||||
label="&servicesMenuMac.label;"/>
|
|
||||||
<menuitem id="menu_mac_hide_app"
|
|
||||||
label="&hideThisAppCmdMac.label;"
|
|
||||||
key="key_hideThisAppCmdMac"/>
|
|
||||||
<menuitem id="menu_mac_hide_others"
|
|
||||||
label="&hideOtherAppsCmdMac.label;"
|
|
||||||
key="key_hideOtherAppsCmdMac"/>
|
|
||||||
<menuitem id="menu_mac_show_all"
|
|
||||||
label="&showAllAppsCmdMac.label;"/>
|
|
||||||
<menuitem id="menu_FileQuitItem"
|
|
||||||
label="&quitApplicationCmdMac.label;"
|
|
||||||
key="key_quitApplication"
|
|
||||||
command="cmd_quitApplication"/>
|
|
||||||
</menupopup>
|
|
||||||
|
|
||||||
<menu id="windowMenu"
|
<menu id="windowMenu"
|
||||||
label="&windowMenu.label;"
|
label="&windowMenu.label;"
|
||||||
datasources="rdf:window-mediator" ref="NC:WindowMediatorRoot"
|
datasources="rdf:window-mediator" ref="NC:WindowMediatorRoot"
|
||||||
|
@ -636,7 +625,6 @@
|
||||||
<menuseparator id="sep-window-list"/>
|
<menuseparator id="sep-window-list"/>
|
||||||
</menupopup>
|
</menupopup>
|
||||||
</menu>
|
</menu>
|
||||||
<!-- endif -->
|
|
||||||
|
|
||||||
<menu id="helpMenu"
|
<menu id="helpMenu"
|
||||||
label="&helpMenu.label;"
|
label="&helpMenu.label;"
|
||||||
|
|
Loading…
Reference in a new issue