From 0746824c0f0311f042b3779b73e931575602cb9b Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Fri, 6 Mar 2009 21:44:47 +0000 Subject: [PATCH] Addresses #1146, Check for duplicate items functionality Ben's duplicate detection code, with the integration reworked a bit Very rough, so currently requires creation of a boolean extensions.zotero.debugShowDuplicates pref to view the Actions menu option --- chrome/content/zotero/overlay.js | 24 +++++- chrome/content/zotero/overlay.xul | 2 + .../zotero/xpcom/collectionTreeView.js | 12 ++- chrome/content/zotero/xpcom/duplicate.js | 83 +++++++++++++++++++ chrome/locale/en-US/zotero/zotero.dtd | 1 + 5 files changed, 120 insertions(+), 2 deletions(-) create mode 100644 chrome/content/zotero/xpcom/duplicate.js diff --git a/chrome/content/zotero/overlay.js b/chrome/content/zotero/overlay.js index bdfad648e..cfad71d48 100644 --- a/chrome/content/zotero/overlay.js +++ b/chrome/content/zotero/overlay.js @@ -225,6 +225,10 @@ var ZoteroPane = new function() sep.nextSibling.nextSibling.nextSibling.hidden = false; sep.nextSibling.nextSibling.nextSibling.nextSibling.hidden = false; } + + if (Zotero.Prefs.get('debugShowDuplicates')) { + document.getElementById('zotero-tb-actions-showDuplicates').hidden = false; + } } @@ -796,6 +800,7 @@ var ZoteroPane = new function() var itemgroup = this.collectionsView._getItemAtRow(this.collectionsView.selection.currentIndex); itemgroup.setSearch(''); itemgroup.setTags(getTagSelection()); + itemgroup.showDuplicates = false; try { Zotero.UnresponsiveScriptIndicator.disable(); @@ -825,6 +830,23 @@ var ZoteroPane = new function() } + + this.showDuplicates = function () { + if (this.collectionsView.selection.count == 1 && this.collectionsView.selection.currentIndex != -1) { + var itemGroup = this.collectionsView._getItemAtRow(this.collectionsView.selection.currentIndex); + itemGroup.showDuplicates = true; + + try { + Zotero.UnresponsiveScriptIndicator.disable(); + this.itemsView.refresh(); + } + finally { + Zotero.UnresponsiveScriptIndicator.enable(); + } + } + } + + function itemSelected() { if (!Zotero.stateCheck()) { @@ -998,7 +1020,7 @@ var ZoteroPane = new function() if (this.itemsView._itemGroup.isCollection()) { var noPrompt = true; } - // Do nothing in search view + // Do nothing in search and share views else if (this.itemsView._itemGroup.isSearch() || this.itemsView._itemGroup.isShare()) { return; diff --git a/chrome/content/zotero/overlay.xul b/chrome/content/zotero/overlay.xul index 4b0f2acbb..9829b6ace 100644 --- a/chrome/content/zotero/overlay.xul +++ b/chrome/content/zotero/overlay.xul @@ -128,6 +128,8 @@ label="Search for Shared Libraries" oncommand="Zotero.Zeroconf.findInstances()"/> + +