Add Firefox-wide shortcut (Ctrl/Cmd-Shift-S) for "Save to Zotero"

Also: Don't show Firefox-specific shortcut keys in Standalone prefs
This commit is contained in:
Dan Stillman 2013-07-31 23:19:19 -04:00
parent f0c5c50bd4
commit dc8998c5bc
8 changed files with 112 additions and 52 deletions

View File

@ -54,6 +54,7 @@ overlay chrome://zotero/content/preferences/preferences.xul chrome://zotero/cont
overlay chrome://zotero/content/preferences/preferences.xul#cite chrome://zotero/content/preferences/preferences_firefox.xul application={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
overlay chrome://zotero/content/preferences/preferences_general.xul chrome://zotero/content/preferences/preferences_general_firefox.xul application={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
overlay chrome://zotero/content/preferences/preferences_export.xul chrome://zotero/content/preferences/preferences_export_firefox.xul application={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
overlay chrome://zotero/content/preferences/preferences_keys.xul chrome://zotero/content/preferences/preferences_keys_firefox.xul application={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
overlay chrome://zotero/content/preferences/preferences_advanced.xul chrome://zotero/content/preferences/preferences_advanced_firefox.xul application={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
overlay chrome://zotero/content/preferences/preferences_advanced.xul chrome://zotero/content/preferences/preferences_advanced_standalone.xul application=zotero@chnm.gmu.edu

View File

@ -95,5 +95,9 @@
key="Z"
oncommand="ZoteroOverlay.toggleDisplay();"
modifiers="accel shift" />
<key id="key_saveToZotero"
key="S"
oncommand="Zotero_Browser.scrapeThisPage();"
modifiers="accel shift" />
</keyset>
</overlay>

View File

@ -27,9 +27,9 @@
Zotero_Preferences.Keys = {
init: function () {
// Display the appropriate modifier keys for the platform
var rows = document.getElementById('zotero-prefpane-keys').getElementsByTagName('row');
for (var i=0; i<rows.length; i++) {
// Display the appropriate modifier keys for the platform
rows[i].firstChild.nextSibling.value = Zotero.isMac ? 'Cmd+Shift+' : 'Ctrl+Shift+';
}
}

View File

@ -31,50 +31,27 @@
helpTopic="shortcut_keys">
<preferences>
<preference id="pref-keys-openZotero" name="extensions.zotero.keys.openZotero" type="string"/>
<preference id="pref-keys-saveToZotero" name="extensions.zotero.keys.saveToZotero" type="string"/>
<preference id="pref-keys-toggleFullscreen" name="extensions.zotero.keys.toggleFullscreen" type="string"/>
<preference id="pref-keys-library" name="extensions.zotero.keys.library" type="string"/>
<preference id="pref-keys-quicksearch" name="extensions.zotero.keys.quicksearch" type="string"/>
<preference id="pref-keys-toggleTagSelector" name="extensions.zotero.keys.toggleTagSelector" type="string"/>
<preference id="pref-keys-newItem" name="extensions.zotero.keys.newItem" type="string"/>
<preference id="pref-keys-newNote" name="extensions.zotero.keys.newNote" type="string"/>
<preference id="pref-keys-toggleTagSelector" name="extensions.zotero.keys.toggleTagSelector" type="string"/>
<preference id="pref-keys-importFromClipboard" name="extensions.zotero.keys.importFromClipboard" type="string"/>
<preference id="pref-keys-copySelectedItemCitationsToClipboard" name="extensions.zotero.keys.copySelectedItemCitationsToClipboard" type="string"/>
<preference id="pref-keys-copySelectedItemsToClipboard" name="extensions.zotero.keys.copySelectedItemsToClipboard" type="string"/>
<preference id="pref-keys-importFromClipboard" name="extensions.zotero.keys.importFromClipboard" type="string"/>
</preferences>
<grid>
<grid id="zotero-keys-grid">
<columns>
<column flex="1"/>
<column/>
<column/>
</columns>
<rows>
<row>
<label value="&zotero.preferences.keys.openZotero;" control="key-textbox-openZotero"/>
<label/>
<textbox id="textbox-openZotero" maxlength="1" size="1" preference="pref-keys-openZotero"/>
</row>
<row>
<label value="&zotero.preferences.keys.toggleFullscreen;" control="textbox-toggleFullscreen"/>
<label/>
<textbox id="textbox-toggleFullscreen" maxlength="1" size="1" preference="pref-keys-toggleFullscreen"/>
</row>
<row>
<label value="&zotero.preferences.keys.focusLibrariesPane;" control="textbox-library"/>
<label/>
<textbox id="textbox-library" maxlength="1" size="1" preference="pref-keys-library"/>
</row>
<row>
<label value="&zotero.preferences.keys.quicksearch;" control="textbox-quicksearch"/>
<label/>
<textbox id="textbox-quicksearch" maxlength="1" size="1" preference="pref-keys-quicksearch"/>
</row>
<row>
<rows id="zotero-keys-rows">
<row id="zotero-keys-new-item">
<label value="&zotero.preferences.keys.newItem;" control="textbox-newItem"/>
<label/>
<textbox id="textbox-newItem" maxlength="1" size="1" preference="pref-keys-newItem"/>
@ -87,9 +64,21 @@
</row>
<row>
<label value="&zotero.preferences.keys.toggleTagSelector;" control="textbox-toggleTagSelector"/>
<label value="&zotero.preferences.keys.importFromClipboard;" control="textbox-importFromClipboard"/>
<label/>
<textbox id="textbox-toggleTagSelector" maxlength="1" size="1" preference="pref-keys-toggleTagSelector"/>
<textbox id="textbox-importFromClipboard" maxlength="1" size="1" preference="pref-keys-importFromClipboard"/>
</row>
<row id="zotero-keys-focus-libraries-pane">
<label value="&zotero.preferences.keys.focusLibrariesPane;" control="textbox-library"/>
<label/>
<textbox id="textbox-library" maxlength="1" size="1" preference="pref-keys-library"/>
</row>
<row>
<label value="&zotero.preferences.keys.quicksearch;" control="textbox-quicksearch"/>
<label/>
<textbox id="textbox-quicksearch" maxlength="1" size="1" preference="pref-keys-quicksearch"/>
</row>
<row>
@ -109,9 +98,9 @@
</row>
<row>
<label value="&zotero.preferences.keys.importFromClipboard;" control="textbox-importFromClipboard"/>
<label value="&zotero.preferences.keys.toggleTagSelector;" control="textbox-toggleTagSelector"/>
<label/>
<textbox id="textbox-importFromClipboard" maxlength="1" size="1" preference="pref-keys-importFromClipboard"/>
<textbox id="textbox-toggleTagSelector" maxlength="1" size="1" preference="pref-keys-toggleTagSelector"/>
</row>
</rows>
</grid>

View File

@ -0,0 +1,52 @@
<?xml version="1.0"?>
<!--
***** BEGIN LICENSE BLOCK *****
Copyright © 20062013 Center for History and New Media
George Mason University, Fairfax, Virginia, USA
http://zotero.org
This file is part of Zotero.
Zotero is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Zotero is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
***** END LICENSE BLOCK *****
-->
<!DOCTYPE prefwindow SYSTEM "chrome://zotero/locale/preferences.dtd">
<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<prefpane id="zotero-prefpane-keys">
<grid id="zotero-keys-grid">
<rows id="zotero-keys-rows">
<row position="1">
<label value="&zotero.preferences.keys.openZotero;" control="key-textbox-openZotero"/>
<label/>
<textbox id="textbox-openZotero" maxlength="1" size="1" preference="pref-keys-openZotero"/>
</row>
<row position="2">
<label value="&zotero.preferences.keys.toggleFullscreen;" control="textbox-toggleFullscreen"/>
<label/>
<textbox id="textbox-toggleFullscreen" maxlength="1" size="1" preference="pref-keys-toggleFullscreen"/>
</row>
<row insertbefore="zotero-keys-new-item">
<label value="&zotero.preferences.keys.saveToZotero;" control="key-textbox-saveToZotero"/>
<label/>
<textbox id="textbox-saveToZotero" maxlength="1" size="1" preference="pref-keys-saveToZotero"/>
</row>
</rows>
</grid>
</prefpane>
</overlay>

View File

@ -2294,6 +2294,7 @@ Zotero.Keys = new function() {
// Get the key=>command mappings from the prefs
for each(var action in actions) {
var action = action.substr(5); // strips 'keys.'
// Remove old pref
if (action == 'overrideGlobal') {
Zotero.Prefs.clear('keys.overrideGlobal');
continue;
@ -2307,18 +2308,30 @@ Zotero.Keys = new function() {
* Called by ZoteroPane.onLoad()
*/
function windowInit(document) {
// Zotero pane shortcut
var keyElem = document.getElementById('key_openZotero');
if(keyElem) {
var zKey = Zotero.Prefs.get('keys.openZotero');
// Only override the default with the pref if the <key> hasn't
// been manually changed and the pref has been
if (keyElem.getAttribute('key') == 'Z'
&& keyElem.getAttribute('modifiers') == 'accel shift'
&& zKey != 'Z') {
keyElem.setAttribute('key', zKey);
var globalKeys = [
{
name: 'openZotero',
defaultKey: 'Z'
},
{
name: 'saveToZotero',
defaultKey: 'S'
}
}
];
globalKeys.forEach(function (x) {
let keyElem = document.getElementById('key_' + x.name);
if (keyElem) {
let prefKey = Zotero.Prefs.get('keys.' + x.name);
// Only override the default with the pref if the <key> hasn't
// been manually changed and the pref has been
if (keyElem.getAttribute('key') == x.defaultKey
&& keyElem.getAttribute('modifiers') == 'accel shift'
&& prefKey != x.defaultKey) {
keyElem.setAttribute('key', prefKey);
}
}
});
}

View File

@ -126,16 +126,16 @@
<!ENTITY zotero.preferences.prefpane.keys "Shortcuts">
<!ENTITY zotero.preferences.keys.openZotero "Open/Close Zotero Pane">
<!ENTITY zotero.preferences.keys.saveToZotero "Save to Zotero (address bar icon)">
<!ENTITY zotero.preferences.keys.toggleFullscreen "Toggle Fullscreen Mode">
<!ENTITY zotero.preferences.keys.focusLibrariesPane "Focus Libraries Pane">
<!ENTITY zotero.preferences.keys.quicksearch "Quick Search">
<!ENTITY zotero.preferences.keys.newItem "Create a new item">
<!ENTITY zotero.preferences.keys.newNote "Create a new note">
<!ENTITY zotero.preferences.keys.newItem "Create a New Item">
<!ENTITY zotero.preferences.keys.newNote "Create a New Note">
<!ENTITY zotero.preferences.keys.toggleTagSelector "Toggle Tag Selector">
<!ENTITY zotero.preferences.keys.copySelectedItemCitationsToClipboard "Copy Selected Item Citations to Clipboard">
<!ENTITY zotero.preferences.keys.copySelectedItemsToClipboard "Copy Selected Items to Clipboard">
<!ENTITY zotero.preferences.keys.importFromClipboard "Import from Clipboard">
<!ENTITY zotero.preferences.keys.overrideGlobal "Try to override conflicting shortcuts">
<!ENTITY zotero.preferences.keys.changesTakeEffect "Changes take effect in new windows only">
<!ENTITY zotero.preferences.prefpane.proxies "Proxies">

View File

@ -65,14 +65,15 @@ pref("extensions.zotero.tagCloud", false);
// Keyboard shortcuts
pref("extensions.zotero.keys.openZotero", 'Z');
pref("extensions.zotero.keys.toggleFullscreen", 'F');
pref("extensions.zotero.keys.library", 'L');
pref("extensions.zotero.keys.quicksearch", 'K');
pref("extensions.zotero.keys.saveToZotero", 'S');
pref("extensions.zotero.keys.newItem", 'N');
pref("extensions.zotero.keys.newNote", 'O');
pref("extensions.zotero.keys.toggleTagSelector", 'T');
pref("extensions.zotero.keys.importFromClipboard", 'V');
pref("extensions.zotero.keys.library", 'L');
pref("extensions.zotero.keys.quicksearch", 'K');
pref("extensions.zotero.keys.copySelectedItemCitationsToClipboard", 'A');
pref("extensions.zotero.keys.copySelectedItemsToClipboard", 'C');
pref("extensions.zotero.keys.importFromClipboard", 'V');
pref("extensions.zotero.keys.toggleTagSelector", 'T');
// Fulltext indexing
pref("extensions.zotero.fulltext.textMaxLength", 500000);