- Show search menu in select items dialog
- Update search menu in non-ZoteroPane dialogs - Don't send oncommand handler as string
This commit is contained in:
parent
90dd0f34e0
commit
54147844ab
3 changed files with 27 additions and 15 deletions
|
@ -33,6 +33,7 @@
|
||||||
|
|
||||||
<dialog
|
<dialog
|
||||||
id="zotero-add-citation-dialog"
|
id="zotero-add-citation-dialog"
|
||||||
|
windowtype="zotero:item-selector"
|
||||||
orient="vertical"
|
orient="vertical"
|
||||||
title="&zotero.integration.addEditCitation.title;"
|
title="&zotero.integration.addEditCitation.title;"
|
||||||
width="600" height="450"
|
width="600" height="450"
|
||||||
|
|
|
@ -26,10 +26,12 @@
|
||||||
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
|
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
|
||||||
<?xml-stylesheet href="chrome://zotero/skin/zotero.css" type="text/css"?>
|
<?xml-stylesheet href="chrome://zotero/skin/zotero.css" type="text/css"?>
|
||||||
<?xml-stylesheet href="chrome://zotero/skin/overlay.css" type="text/css"?>
|
<?xml-stylesheet href="chrome://zotero/skin/overlay.css" type="text/css"?>
|
||||||
|
<?xml-stylesheet href="chrome://zotero-platform/content/overlay.css" type="text/css"?>
|
||||||
<!DOCTYPE window SYSTEM "chrome://zotero/locale/zotero.dtd">
|
<!DOCTYPE window SYSTEM "chrome://zotero/locale/zotero.dtd">
|
||||||
|
|
||||||
<dialog
|
<dialog
|
||||||
id="zotero-select-items-dialog"
|
id="zotero-select-items-dialog"
|
||||||
|
windowtype="zotero:item-selector"
|
||||||
title="&zotero.selectitems.title;"
|
title="&zotero.selectitems.title;"
|
||||||
orient="vertical"
|
orient="vertical"
|
||||||
width="600" height="450"
|
width="600" height="450"
|
||||||
|
|
|
@ -1714,6 +1714,9 @@ const ZOTERO_CONFIG = {
|
||||||
|
|
||||||
|
|
||||||
this.updateQuickSearchBox = function (document) {
|
this.updateQuickSearchBox = function (document) {
|
||||||
|
var searchBox = document.getElementById('zotero-tb-search');
|
||||||
|
if(!searchBox) return;
|
||||||
|
|
||||||
var mode = Zotero.Prefs.get("search.quicksearch-mode");
|
var mode = Zotero.Prefs.get("search.quicksearch-mode");
|
||||||
var prefix = 'zotero-tb-search-mode-';
|
var prefix = 'zotero-tb-search-mode-';
|
||||||
var prefixLen = prefix.length;
|
var prefixLen = prefix.length;
|
||||||
|
@ -1737,13 +1740,13 @@ const ZOTERO_CONFIG = {
|
||||||
mode = 'fields';
|
mode = 'fields';
|
||||||
}
|
}
|
||||||
|
|
||||||
var searchBox = document.getElementById('zotero-tb-search')
|
|
||||||
var hbox = document.getAnonymousNodes(searchBox)[0];
|
var hbox = document.getAnonymousNodes(searchBox)[0];
|
||||||
var input = hbox.getElementsByAttribute('class', 'textbox-input')[0];
|
var input = hbox.getElementsByAttribute('class', 'textbox-input')[0];
|
||||||
|
|
||||||
// Already initialized, so just update selection
|
// Already initialized, so just update selection
|
||||||
var button = hbox.getElementsByAttribute('id', 'zotero-tb-search-menu-button');
|
var button = hbox.getElementsByAttribute('id', 'zotero-tb-search-menu-button');
|
||||||
if (button.length) {
|
if (button.length) {
|
||||||
|
Zotero.debug("already initialized search menu");
|
||||||
button = button[0];
|
button = button[0];
|
||||||
var menupopup = button.firstChild;
|
var menupopup = button.firstChild;
|
||||||
for each(var menuitem in menupopup.childNodes) {
|
for each(var menuitem in menupopup.childNodes) {
|
||||||
|
@ -1784,12 +1787,13 @@ const ZOTERO_CONFIG = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
menupopup.setAttribute(
|
menupopup.addEventListener("command", function(event) {
|
||||||
'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 == "") {
|
||||||
+ 'if (document.getElementById("zotero-tb-search").value == "") { event.stopPropagation(); }'
|
event.stopPropagation();
|
||||||
);
|
}
|
||||||
|
}, false);
|
||||||
|
|
||||||
button.appendChild(menupopup);
|
button.appendChild(menupopup);
|
||||||
hbox.insertBefore(button, input);
|
hbox.insertBefore(button, input);
|
||||||
|
@ -1802,14 +1806,12 @@ const ZOTERO_CONFIG = {
|
||||||
}
|
}
|
||||||
|
|
||||||
// If Alt-Up/Down, show popup
|
// If Alt-Up/Down, show popup
|
||||||
searchBox.setAttribute(
|
searchBox.addEventListener("keypress", function(event) {
|
||||||
'onkeypress',
|
if (event.altKey && (event.keyCode == event.DOM_VK_UP || event.keyCode == event.DOM_VK_DOWN)) {
|
||||||
searchBox.getAttribute('onkeypress') + "\n"
|
document.getElementById('zotero-tb-search-menu-button').open = true;
|
||||||
+ "if (event.altKey && (event.keyCode == event.DOM_VK_UP || event.keyCode == event.DOM_VK_DOWN)) {"
|
event.stopPropagation();
|
||||||
+ "document.getElementById('zotero-tb-search-menu-button').open = true;"
|
}
|
||||||
+ "event.stopPropagation();"
|
}, false);
|
||||||
+ "}"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2053,6 +2055,13 @@ Zotero.Prefs = new function(){
|
||||||
if (!win.ZoteroPane) continue;
|
if (!win.ZoteroPane) continue;
|
||||||
Zotero.updateQuickSearchBox(win.ZoteroPane.document);
|
Zotero.updateQuickSearchBox(win.ZoteroPane.document);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var enumerator = wm.getEnumerator("zotero:item-selector");
|
||||||
|
while (enumerator.hasMoreElements()) {
|
||||||
|
var win = enumerator.getNext();
|
||||||
|
if (!win.Zotero) continue;
|
||||||
|
Zotero.updateQuickSearchBox(win.document);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue