From 91def29078874eae2f63a203ec1ed5a93a9a20f0 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Tue, 12 Sep 2006 08:47:24 +0000 Subject: [PATCH] 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. --- .../chromeFiles/content/scholar/itemPane.js | 48 ++++++++++++++++--- .../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 index d5ab7c250..046f11056 100644 --- 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 + // 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 index 851638785..619a6abb0 100644 --- a/chrome/chromeFiles/skin/default/scholar/overlay.css +++ b/chrome/chromeFiles/skin/default/scholar/overlay.css @@ -183,28 +183,24 @@ list-style-image: url('chrome://scholar/skin/toolbar-openurl.png'); } +#scholar-view-item > vbox +{ + overflow: auto; + margin-left: 5px; +} + /* creator switch button */ #editpane-dynamic-fields row hbox toolbarbutton { margin-right:5px; } -#scholar-view-item vbox -{ - overflow: auto; -} - #editpane-dynamic-fields row > label:first-child { text-align: right; font-weight: bold; } -#scholar-view-item -{ - margin-left: 5px; -} - #scholar-splitter { border-top: none;