From a972a035c7633670e06b1408e06c635c31552950 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sun, 1 Oct 2006 08:09:53 +0000 Subject: [PATCH] Closes #260, Add auto-complete to search window And fixed a bug that caused the text of some search conditions to not display when editing a previously saved search Also added autocomplete to more fields in metadata pane: - creator - publisher - place - publicationTitle - journalAbbreviation - seriesTitle - seriesText It should also do the type and medium fields, but they need to be separated out first--e.g. artworkType, interviewMedium--since they're describing different data --- .../scholar/bindings/searchtextbox.xml | 35 ++++++++++++++++++- .../chromeFiles/content/scholar/itemPane.js | 31 ++++++++++++---- 2 files changed, 59 insertions(+), 7 deletions(-) diff --git a/chrome/chromeFiles/content/scholar/bindings/searchtextbox.xml b/chrome/chromeFiles/content/scholar/bindings/searchtextbox.xml index 4f72e449c7..a151e12749 100644 --- a/chrome/chromeFiles/content/scholar/bindings/searchtextbox.xml +++ b/chrome/chromeFiles/content/scholar/bindings/searchtextbox.xml @@ -14,7 +14,7 @@ + onset="document.getAnonymousNodes(this)[0].setAttribute('value', val); return val"/> diff --git a/chrome/chromeFiles/content/scholar/itemPane.js b/chrome/chromeFiles/content/scholar/itemPane.js index 1018a34c27..f38388fcc4 100644 --- a/chrome/chromeFiles/content/scholar/itemPane.js +++ b/chrome/chromeFiles/content/scholar/itemPane.js @@ -746,14 +746,33 @@ var ScholarItemPane = new function() t.setAttribute('multiline', true); t.setAttribute('rows', 8); } - // TODO: only have autocomplete on a few fields else { - t.setAttribute('type', 'autocomplete'); - t.setAttribute('autocompletesearch', 'zotero'); - t.setAttribute('autocompletesearchparam', fieldName + '/' + - (elem.getAttribute('singleField')=='true' ? '1' : '0') + - '-' + (itemID ? itemID : '')); + // Add auto-complete for certain fields + switch (field) + { + case 'creator': + case 'publisher': + case 'place': + case 'publicationTitle': + case 'journalAbbreviation': + case 'seriesTitle': + case 'seriesText': + // DEBUG: should have type and medium, but they need to be + // broken out first into multiple fields (artworkType, + // interviewMedium, etc.) + t.setAttribute('type', 'autocomplete'); + t.setAttribute('autocompletesearch', 'zotero'); + var suffix = itemID ? itemID : ''; + if (field=='creator') + { + suffix = (elem.getAttribute('singleField')=='true' + ? '1' : '0') + '-' + suffix; + } + t.setAttribute('autocompletesearchparam', + fieldName + '/' + suffix); + break; + } } var box = elem.parentNode; box.replaceChild(t,elem);