From da5e74a06a70fb21adde8d193e455cc168ab83e7 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Mon, 25 Sep 2006 06:38:47 +0000 Subject: [PATCH] Autocomplete for creators in item pane Differentiates between single and double fields for the search, but there's a problem in the current implementation in that only one field is editable at once, so displaying two-field names in a drop-down is a little problematic. While I could display the full names, comma-delimited, and get the discrete parts (which is what Scholar.Utilities.AutoComplete.getResultComment(), included in this commit, is for--the creatorID for the row would be hidden in the autocomplete drop-down comment field), it's a bit unclear what should happen when a user selects a comma-separated name from the drop-down of one of the fields. One option would be to have a row for the last name (in case that's all they want to complete) and other rows for "last, first" matches, and selecting one of the two-part names would replace whatever's in the opposite name field with the appropriate text (and save it to the DB, I'm afraid, unless I change how the creator fields work), keeping the focus in the current textbox for easy tabbing. Not great, but it might work. Other ideas? --- .../chromeFiles/content/scholar/itemPane.js | 6 +-- .../content/scholar/xpcom/utilities.js | 21 ++++++++++ components/chnmIZoteroAutoComplete.js | 41 +++++++++++++++++-- 3 files changed, 61 insertions(+), 7 deletions(-) diff --git a/chrome/chromeFiles/content/scholar/itemPane.js b/chrome/chromeFiles/content/scholar/itemPane.js index 7754ef4fae..51429c1760 100644 --- a/chrome/chromeFiles/content/scholar/itemPane.js +++ b/chrome/chromeFiles/content/scholar/itemPane.js @@ -707,9 +707,10 @@ var ScholarItemPane = new function() { t.setAttribute('type', 'autocomplete'); t.setAttribute('autocompletesearch', 'zotero'); - t.setAttribute('autocompletesearchparam', fieldName + (itemID ? '/' + itemID : '')); + t.setAttribute('autocompletesearchparam', fieldName + '/' + + (elem.getAttribute('singleField')=='true' ? '1' : '0') + + '-' + (itemID ? itemID : '')); } - var box = elem.parentNode; box.replaceChild(t,elem); @@ -722,7 +723,6 @@ var ScholarItemPane = new function() _lastTabIndex = tabindex; } - function handleKeyPress(event){ var target = document.commandDispatcher.focusedElement; switch (event.keyCode) diff --git a/chrome/chromeFiles/content/scholar/xpcom/utilities.js b/chrome/chromeFiles/content/scholar/xpcom/utilities.js index 550dd7b56a..8cad0faaf7 100644 --- a/chrome/chromeFiles/content/scholar/xpcom/utilities.js +++ b/chrome/chromeFiles/content/scholar/xpcom/utilities.js @@ -595,4 +595,25 @@ Scholar.Utilities.HTTP.processDocuments = function(firstDoc, urls, processor, do } init(); +} + + +/* + * This would probably be better as a separate XPCOM service + */ +Scholar.Utilities.AutoComplete = new function(){ + this.getResultComment = getResultComment; + + function getResultComment(textbox){ + var controller = textbox.controller; + + for (var i=0; i