www

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

commit 91def29078874eae2f63a203ec1ed5a93a9a20f0
parent b84181766df6edc436f4bb6e9e8a16d3107a3da2
Author: Dan Stillman <dstillman@zotero.org>
Date:   Tue, 12 Sep 2006 08:47:24 +0000

Closes #189, "extra" field should allow multiple lines

Using Shift-Enter as the save keystroke within the Extra textbox so that people can use Enter to create multiple lines of text. Shift-Enter would normally be the newline command, but that's probably a convention that non-technical users of Zotero wouldn't know... Tab (and other triggers for blur()) also saves, and since Extra is the last field, tabbing away functions the same as hitting Enter does for other fields, so it's probably not that big of a deal.


Diffstat:
Mchrome/chromeFiles/content/scholar/itemPane.js | 48++++++++++++++++++++++++++++++++++++++++++------
Mchrome/chromeFiles/skin/default/scholar/overlay.css | 16++++++----------
2 files changed, 48 insertions(+), 16 deletions(-)

diff --git a/chrome/chromeFiles/content/scholar/itemPane.js b/chrome/chromeFiles/content/scholar/itemPane.js @@ -564,7 +564,15 @@ var ScholarItemPane = new function() function createValueElement(valueText, fieldName, tabindex) { - var valueElement = document.createElement("label"); + if (fieldName=='extra') + { + var valueElement = document.createElement("vbox"); + } + else + { + var valueElement = document.createElement("label"); + } + if(fieldName) { valueElement.setAttribute('fieldname',fieldName); @@ -576,8 +584,20 @@ var ScholarItemPane = new function() var firstSpace; if(typeof valueText == 'string') firstSpace = valueText.indexOf(" "); - - if((firstSpace == -1 && valueText.length > 29 ) || firstSpace > 29) + + // To support newlines in 'extra' fields, we use multiple + // <description> elements inside a vbox + if (fieldName=='extra') + { + var lines = valueText.split("\n"); + for (var i = 0; i < lines.length; i++) { + var descriptionNode = document.createElement("description"); + var linetext = document.createTextNode(lines[i]); + descriptionNode.appendChild(linetext); + valueElement.appendChild(descriptionNode); + } + } + else if ((firstSpace == -1 && valueText.length > 29 ) || firstSpace > 29) { valueElement.setAttribute('crop', 'end'); valueElement.setAttribute('value',valueText); @@ -634,18 +654,28 @@ var ScholarItemPane = new function() } var t = document.createElement("textbox"); - t.setAttribute('type', 'autocomplete'); - t.setAttribute('autocompletesearch', 'zotero'); - t.setAttribute('autocompletesearchparam', fieldName + (itemID ? '/' + itemID : '')); t.setAttribute('value',value); t.setAttribute('fieldname', fieldName); t.setAttribute('tabindex', tabindex); t.setAttribute('flex','1'); + if (creatorField=='lastName') { t.setAttribute('singleField', elem.getAttribute('singleField')); } + if (fieldName=='extra') + { + t.setAttribute('multiline', true); + t.setAttribute('rows', 8); + } + else + { + t.setAttribute('type', 'autocomplete'); + t.setAttribute('autocompletesearch', 'zotero'); + t.setAttribute('autocompletesearchparam', fieldName + (itemID ? '/' + itemID : '')); + } + var box = elem.parentNode; box.replaceChild(t,elem); @@ -663,6 +693,12 @@ var ScholarItemPane = new function() switch (event.keyCode) { case event.DOM_VK_RETURN: + // Use shift-enter as the save action for the 'extra' field + if (document.commandDispatcher.focusedElement.parentNode. + parentNode.getAttribute('fieldname')=='extra' && !event.shiftKey) + { + break; + } document.commandDispatcher.focusedElement.blur(); break; diff --git a/chrome/chromeFiles/skin/default/scholar/overlay.css b/chrome/chromeFiles/skin/default/scholar/overlay.css @@ -183,15 +183,16 @@ list-style-image: url('chrome://scholar/skin/toolbar-openurl.png'); } -/* creator switch button */ -#editpane-dynamic-fields row hbox toolbarbutton +#scholar-view-item > vbox { - margin-right:5px; + overflow: auto; + margin-left: 5px; } -#scholar-view-item vbox +/* creator switch button */ +#editpane-dynamic-fields row hbox toolbarbutton { - overflow: auto; + margin-right:5px; } #editpane-dynamic-fields row > label:first-child @@ -200,11 +201,6 @@ font-weight: bold; } -#scholar-view-item -{ - margin-left: 5px; -} - #scholar-splitter { border-top: none;