commit 54147844abd0f3a8a703f8fc791a9a45ec55dd2d
parent 90dd0f34e038f739cd2b4971eb1bea7fbbc1c70e
Author: Simon Kornblith <simon@simonster.com>
Date: Mon, 3 Oct 2011 02:27:42 +0000
- Show search menu in select items dialog
- Update search menu in non-ZoteroPane dialogs
- Don't send oncommand handler as string
Diffstat:
3 files changed, 27 insertions(+), 15 deletions(-)
diff --git a/chrome/content/zotero/integration/addCitationDialog.xul b/chrome/content/zotero/integration/addCitationDialog.xul
@@ -33,6 +33,7 @@
<dialog
id="zotero-add-citation-dialog"
+ windowtype="zotero:item-selector"
orient="vertical"
title="&zotero.integration.addEditCitation.title;"
width="600" height="450"
diff --git a/chrome/content/zotero/selectItemsDialog.xul b/chrome/content/zotero/selectItemsDialog.xul
@@ -26,10 +26,12 @@
<?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/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">
<dialog
id="zotero-select-items-dialog"
+ windowtype="zotero:item-selector"
title="&zotero.selectitems.title;"
orient="vertical"
width="600" height="450"
diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js
@@ -1714,6 +1714,9 @@ const ZOTERO_CONFIG = {
this.updateQuickSearchBox = function (document) {
+ var searchBox = document.getElementById('zotero-tb-search');
+ if(!searchBox) return;
+
var mode = Zotero.Prefs.get("search.quicksearch-mode");
var prefix = 'zotero-tb-search-mode-';
var prefixLen = prefix.length;
@@ -1737,13 +1740,13 @@ const ZOTERO_CONFIG = {
mode = 'fields';
}
- var searchBox = document.getElementById('zotero-tb-search')
var hbox = document.getAnonymousNodes(searchBox)[0];
var input = hbox.getElementsByAttribute('class', 'textbox-input')[0];
// Already initialized, so just update selection
var button = hbox.getElementsByAttribute('id', 'zotero-tb-search-menu-button');
if (button.length) {
+ Zotero.debug("already initialized search menu");
button = button[0];
var menupopup = button.firstChild;
for each(var menuitem in menupopup.childNodes) {
@@ -1784,12 +1787,13 @@ const ZOTERO_CONFIG = {
}
}
- menupopup.setAttribute(
- 'oncommand',
- 'var mode = event.target.id.substr(22); '
- + 'Zotero.Prefs.set("search.quicksearch-mode", mode);'
- + 'if (document.getElementById("zotero-tb-search").value == "") { event.stopPropagation(); }'
- );
+ menupopup.addEventListener("command", function(event) {
+ var mode = event.target.id.substr(22);
+ Zotero.Prefs.set("search.quicksearch-mode", mode);
+ if (document.getElementById("zotero-tb-search").value == "") {
+ event.stopPropagation();
+ }
+ }, false);
button.appendChild(menupopup);
hbox.insertBefore(button, input);
@@ -1802,14 +1806,12 @@ const ZOTERO_CONFIG = {
}
// 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();"
- + "}"
- );
+ searchBox.addEventListener("keypress", function(event) {
+ 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();
+ }
+ }, false);
}
@@ -2053,6 +2055,13 @@ Zotero.Prefs = new function(){
if (!win.ZoteroPane) continue;
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;
}
}