www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit a972a035c7633670e06b1408e06c635c31552950
parent 66729ed1e20f297ea500390bfc75c5a74c60bbd6
Author: Dan Stillman <dstillman@zotero.org>
Date:   Sun,  1 Oct 2006 08:09:53 +0000

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



Diffstat:
Mchrome/chromeFiles/content/scholar/bindings/searchtextbox.xml | 35++++++++++++++++++++++++++++++++++-
Mchrome/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 @@ -14,7 +14,7 @@ <implementation> <property name="value" onget="return document.getAnonymousNodes(this)[0].value" - onset="document.getAnonymousNodes(this)[0].value = val; return val"/> + onset="document.getAnonymousNodes(this)[0].setAttribute('value', val); return val"/> <property name="mode"> <getter> <![CDATA[ @@ -95,6 +95,39 @@ default: this.setAttribute('hasOptions', false); + + // Set textbox to autocomplete mode + switch (condition) + { + // Skip autocomplete for these fields + case 'note': + case 'extra': + break; + + default: + + var textbox = document.getAnonymousNodes(this)[0]; + textbox.setAttribute('type', 'autocomplete'); + textbox.setAttribute('autocompletesearch', 'zotero'); + + if (condition=='creator') + { + // 2 searches both single- and double-field creators + var autocompleteCondition = condition + '/2' + } + else + { + var autocompleteCondition = condition; + } + + textbox.setAttribute('autocompletesearchparam', autocompleteCondition); + } + } + + if (!autocompleteCondition) + { + var textbox = document.getAnonymousNodes(this)[0]; + textbox.removeAttribute('type'); } ]]> </body> diff --git 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);