From 0d4025e9fbd4fd532db4f381612d6e2ede861c3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adomas=20Ven=C4=8Dkauskas?= Date: Thu, 11 Feb 2016 10:37:20 +0000 Subject: [PATCH] Add preferences for feed sorting and toggle read hotkey --- .../preferences/preferences_advanced.js | 5 ++- .../preferences/preferences_advanced.xul | 23 ++++++---- .../preferences_advanced_firefox.xul | 6 +-- .../preferences/preferences_general.xul | 14 ++++++ chrome/content/zotero/xpcom/itemTreeView.js | 2 +- chrome/content/zotero/zoteroPane.js | 45 ++++++++++--------- chrome/locale/en-US/zotero/preferences.dtd | 6 +++ defaults/preferences/zotero.js | 4 +- 8 files changed, 71 insertions(+), 34 deletions(-) diff --git a/chrome/content/zotero/preferences/preferences_advanced.js b/chrome/content/zotero/preferences/preferences_advanced.js index 04ad854c8..88c84a885 100644 --- a/chrome/content/zotero/preferences/preferences_advanced.js +++ b/chrome/content/zotero/preferences/preferences_advanced.js @@ -815,7 +815,10 @@ Zotero_Preferences.Keys = { var rows = document.getElementById('zotero-prefpane-advanced-keys-tab').getElementsByTagName('row'); for (var i=0; i + @@ -217,37 +218,37 @@ diff --git a/chrome/content/zotero/preferences/preferences_advanced_firefox.xul b/chrome/content/zotero/preferences/preferences_advanced_firefox.xul index 0ead16e42..da52cda30 100644 --- a/chrome/content/zotero/preferences/preferences_advanced_firefox.xul +++ b/chrome/content/zotero/preferences/preferences_advanced_firefox.xul @@ -51,19 +51,19 @@ diff --git a/chrome/content/zotero/preferences/preferences_general.xul b/chrome/content/zotero/preferences/preferences_general.xul index 2654273bb..1626ae490 100644 --- a/chrome/content/zotero/preferences/preferences_general.xul +++ b/chrome/content/zotero/preferences/preferences_general.xul @@ -43,6 +43,8 @@ + + @@ -130,6 +132,18 @@ + + + + + diff --git a/chrome/content/zotero/xpcom/itemTreeView.js b/chrome/content/zotero/xpcom/itemTreeView.js index 3cc34fb6b..bd808a66e 100644 --- a/chrome/content/zotero/xpcom/itemTreeView.js +++ b/chrome/content/zotero/xpcom/itemTreeView.js @@ -2137,7 +2137,7 @@ Zotero.ItemTreeView.prototype.getSortFields = function () { */ Zotero.ItemTreeView.prototype.getSortDirection = function() { if (this.collectionTreeRow.isFeed) { - return Zotero.Prefs.get('feedSortAsc') ? 'ascending' : 'descending'; + return Zotero.Prefs.get('feeds.sortAsc') ? 'ascending' : 'descending'; } var column = this._treebox.columns.getSortedColumn(); if (!column) { diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js index 002594a51..f48cc3df4 100644 --- a/chrome/content/zotero/zoteroPane.js +++ b/chrome/content/zotero/zoteroPane.js @@ -512,17 +512,6 @@ var ZoteroPane = new function() } ZoteroPane_Local.collectionsView.setHighlightedRows(); return; - } else if (event.keyCode == event.DOM_VK_BACK_QUOTE) { - // Toggle read/unread - let row = this.collectionsView.getRow(this.collectionsView.selection.currentIndex); - if (!row || !row.isFeed()) return; - if(itemReadTimeout) { - itemReadTimeout.cancel(); - itemReadTimeout = null; - } - - let itemIDs = this.getSelectedItems(true); - Zotero.FeedItems.toggleReadByID(itemIDs); } } } @@ -564,6 +553,11 @@ var ZoteroPane = new function() event.preventDefault(); return; } + + var key = String.fromCharCode(event.which); + if (key) { + var command = Zotero.Keys.getCommand(key); + } if (from == 'zotero-collections-tree') { if ((event.keyCode == event.DOM_VK_BACK_SPACE && Zotero.isMac) || @@ -577,7 +571,7 @@ var ZoteroPane = new function() else if (from == 'zotero-items-tree') { // Focus TinyMCE explicitly on tab key, since the normal focusing // doesn't work right - if (!event.shiftKey && event.keyCode == event.DOM_VK_TAB) { + if (!event.shiftKey && event.keyCode == String.fromCharCode(event.which)) { var deck = document.getElementById('zotero-item-pane-content'); if (deck.selectedPanel.id == 'zotero-view-note') { setTimeout(function () { @@ -607,12 +601,19 @@ var ZoteroPane = new function() //event.stopPropagation(); return; } - } - - var key = String.fromCharCode(event.which); - if (!key) { - Zotero.debug('No key'); - return; + else if (command == 'toggleRead') { + // Toggle read/unread + let row = this.collectionsView.getRow(this.collectionsView.selection.currentIndex); + if (!row || !row.isFeed()) return; + if(itemReadTimeout) { + itemReadTimeout.cancel(); + itemReadTimeout = null; + } + + let itemIDs = this.getSelectedItems(true); + Zotero.FeedItems.toggleReadByID(itemIDs); + return; + } } // Ignore modifiers other than Ctrl-Shift/Cmd-Shift @@ -620,12 +621,16 @@ var ZoteroPane = new function() return; } - var command = Zotero.Keys.getCommand(key); + if (!key) { + Zotero.debug('No key'); + return; + } + if (!command) { return; } - Zotero.debug(command); + Zotero.debug('Keyboard shortcut: ', command); // Errors don't seem to make it out otherwise try { diff --git a/chrome/locale/en-US/zotero/preferences.dtd b/chrome/locale/en-US/zotero/preferences.dtd index b3c8bce24..b6f345456 100644 --- a/chrome/locale/en-US/zotero/preferences.dtd +++ b/chrome/locale/en-US/zotero/preferences.dtd @@ -39,6 +39,11 @@ + + + + + @@ -133,6 +138,7 @@ + diff --git a/defaults/preferences/zotero.js b/defaults/preferences/zotero.js index 70dc4cb87..669fcaefd 100644 --- a/defaults/preferences/zotero.js +++ b/defaults/preferences/zotero.js @@ -52,6 +52,8 @@ pref("extensions.zotero.groups.copyChildFileAttachments", true); pref("extensions.zotero.groups.copyChildNotes", true); pref("extensions.zotero.groups.copyTags", true); +pref("extensions.zotero.feeds.sortAsc", false); + pref("extensions.zotero.backup.numBackups", 2); pref("extensions.zotero.backup.interval", 1440); @@ -62,7 +64,6 @@ pref("extensions.zotero.lastLongTagMode", 0); pref("extensions.zotero.lastLongTagDelimiter", ";"); pref("extensions.zotero.fallbackSort", 'firstCreator,date,title,dateAdded'); -pref("extensions.zotero.feedSortAsc", false); pref("extensions.zotero.sortCreatorAsString", false); //Tag Cloud @@ -81,6 +82,7 @@ pref("extensions.zotero.keys.copySelectedItemCitationsToClipboard", 'A'); pref("extensions.zotero.keys.copySelectedItemsToClipboard", 'C'); pref("extensions.zotero.keys.toggleTagSelector", 'T'); pref("extensions.zotero.keys.sync", 'Y'); +pref("extensions.zotero.keys.toggleRead", '`'); // Fulltext indexing pref("extensions.zotero.fulltext.textMaxLength", 500000);