- Fix placeholder text switching in quicksearch box

- Open popup on Alt-Up/Down, as in Firefox search bar
- Don't re-run search when switching modes if search is empty
This commit is contained in:
Dan Stillman 2011-04-26 19:39:18 +00:00
parent f60f3aa930
commit 9de109db1d

View File

@ -1569,6 +1569,7 @@ var Zotero = new function(){
'oncommand', 'oncommand',
'var mode = event.target.id.substr(22); ' 'var mode = event.target.id.substr(22); '
+ 'Zotero.Prefs.set("search.quicksearch-mode", mode);' + 'Zotero.Prefs.set("search.quicksearch-mode", mode);'
+ 'if (document.getElementById("zotero-tb-search").value == "") { event.stopPropagation(); }'
); );
button.appendChild(menupopup); button.appendChild(menupopup);
@ -1580,6 +1581,16 @@ var Zotero = new function(){
else { else {
searchBox.placeholder = modes[mode].label; searchBox.placeholder = modes[mode].label;
} }
// If Alt-Up/Down, show popup
searchBox.setAttribute(
'onkeypress',
searchBox.getAttribute('onkeypress') + "\n"
+ "if (event.altKey && (event.keyCode == event.DOM_VK_UP || event.keyCode == event.DOM_VK_DOWN)) {"
+ "document.getElementById('zotero-tb-search-menu-button').open = true;"
+ "event.stopPropagation();"
+ "}"
);
} }
@ -1809,7 +1820,7 @@ Zotero.Prefs = new function(){
while (enumerator.hasMoreElements()) { while (enumerator.hasMoreElements()) {
var win = enumerator.getNext(); var win = enumerator.getNext();
if (!win.ZoteroPane) continue; if (!win.ZoteroPane) continue;
win.ZoteroPane.updateQuickSearchBox(); Zotero.updateQuickSearchBox(win.ZoteroPane.document);
} }
break; break;
} }