From f6e7cf83fac6273d96368045696cfcb0219430e3 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Wed, 8 Aug 2012 01:56:25 -0400 Subject: [PATCH] Add ability to search for item by key from quick search bar Matches beginning of key only, and only when search string is >= 2 chars --- chrome/content/zotero/xpcom/search.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/chrome/content/zotero/xpcom/search.js b/chrome/content/zotero/xpcom/search.js index b0bdb82c2b..84835d111a 100644 --- a/chrome/content/zotero/xpcom/search.js +++ b/chrome/content/zotero/xpcom/search.js @@ -410,6 +410,11 @@ Zotero.Search.prototype.addCondition = function(condition, operator, value, requ for each(var part in parts) { this.addCondition('blockStart'); + + if (operator == 'contains' && part.text.length > 1) { + this.addCondition('key', 'beginsWith', part.text, false); + } + if (condition == 'quicksearch-titleCreatorYear') { this.addCondition('title', operator, part.text, false); this.addCondition('year', operator, part.text, false); @@ -2180,6 +2185,19 @@ Zotero.SearchConditions = new function(){ noLoad: true }, + { + name: 'key', + operators: { + is: true, + isNot: true, + beginsWith: true + }, + table: 'items', + field: 'key', + special: true, + noLoad: true + }, + { name: 'annotation', operators: {