diff --git a/chrome/content/zotero/integration/addCitationDialog.xul b/chrome/content/zotero/integration/addCitationDialog.xul index be04cb8049..a420702329 100644 --- a/chrome/content/zotero/integration/addCitationDialog.xul +++ b/chrome/content/zotero/integration/addCitationDialog.xul @@ -27,6 +27,7 @@ + @@ -55,8 +56,8 @@ - + + diff --git a/chrome/content/zotero/selectItemsDialog.js b/chrome/content/zotero/selectItemsDialog.js index febbdfdd8a..a9561ff586 100644 --- a/chrome/content/zotero/selectItemsDialog.js +++ b/chrome/content/zotero/selectItemsDialog.js @@ -48,6 +48,8 @@ function doLoad() collectionsView.showCommons = false; document.getElementById('zotero-collections-tree').view = collectionsView; if(io.select) itemsView.selectItem(io.select); + + Zotero.updateQuickSearchBox(document); } function doUnload() diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js index 559f9cdf7a..f72c445c00 100644 --- a/chrome/content/zotero/xpcom/zotero.js +++ b/chrome/content/zotero/xpcom/zotero.js @@ -1495,6 +1495,94 @@ var Zotero = new function(){ } + this.updateQuickSearchBox = function (document) { + var mode = Zotero.Prefs.get("search.quicksearch-mode"); + var prefix = 'zotero-tb-search-mode-'; + var prefixLen = prefix.length; + + var modes = { + titlesAndCreators: { + label: "Titles & Creators" + }, + + fields: { + label: "All Fields" + }, + + everything: { + label: "Everything" + } + }; + + if (!modes[mode]) { + 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) { + button = button[0]; + var menupopup = button.firstChild; + for each(var menuitem in menupopup.childNodes) { + if (menuitem.id.substr(prefixLen) == mode) { + menuitem.setAttribute('checked', true); + if (Zotero.isFx36) { + searchBox.emptytext = modes[mode].label; + } + else { + searchBox.placeholder = modes[mode].label; + } + return; + } + } + return; + } + + // Otherwise, build menu + button = document.createElement('button'); + button.id = 'zotero-tb-search-menu-button'; + button.setAttribute('type', 'menu'); + + var menupopup = document.createElement('menupopup'); + + for (var i in modes) { + var menuitem = document.createElement('menuitem'); + menuitem.setAttribute('id', prefix + i); + menuitem.setAttribute('label', modes[i].label); + menuitem.setAttribute('name', 'searchMode'); + menuitem.setAttribute('type', 'radio'); + //menuitem.setAttribute("tooltiptext", ""); + + menupopup.appendChild(menuitem); + + if (mode == i) { + menuitem.setAttribute('checked', true); + menupopup.selectedItem = menuitem; + } + } + + menupopup.setAttribute( + 'oncommand', + 'var mode = event.target.id.substr(22); ' + + 'Zotero.Prefs.set("search.quicksearch-mode", mode);' + ); + + button.appendChild(menupopup); + hbox.insertBefore(button, input); + + if (Zotero.isFx36) { + searchBox.emptytext = modes[mode].label; + } + else { + searchBox.placeholder = modes[mode].label; + } + } + + /* * Clear entries that no longer exist from various tables */ diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js index d234295119..2c469ffca2 100644 --- a/chrome/content/zotero/zoteroPane.js +++ b/chrome/content/zotero/zoteroPane.js @@ -119,7 +119,7 @@ var ZoteroPane = new function() window.addEventListener("resize", this.updateToolbarPosition, false); window.setTimeout(this.updateToolbarPosition, 0); - this.updateQuickSearchBox(); + Zotero.updateQuickSearchBox(document); if (Zotero.isMac) { //document.getElementById('zotero-tb-actions-zeroconf-update').setAttribute('hidden', false); @@ -3612,95 +3612,6 @@ var ZoteroPane = new function() toolbar.style.width = computedStyle.getPropertyValue("width"); } } - - - this.updateQuickSearchBox = function () { - var mode = Zotero.Prefs.get("search.quicksearch-mode"); - var prefix = 'zotero-tb-search-mode-'; - var prefixLen = prefix.length; - - var modes = { - titlesAndCreators: { - label: "Titles & Creators" - }, - - fields: { - label: "All Fields" - }, - - everything: { - label: "Everything" - } - }; - - if (!modes[mode]) { - 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) { - button = button[0]; - var menupopup = button.firstChild; - for each(var menuitem in menupopup.childNodes) { - if (menuitem.id.substr(prefixLen) == mode) { - menuitem.setAttribute('checked', true); - if (Zotero.isFx36) { - searchBox.emptytext = modes[mode].label; - } - else { - searchBox.placeholder = modes[mode].label; - } - return; - } - } - return; - } - - // Otherwise, build menu - button = document.createElement('button'); - button.id = 'zotero-tb-search-menu-button'; - button.setAttribute('type', 'menu'); - - var menupopup = document.createElement('menupopup'); - - for (var i in modes) { - var menuitem = document.createElement('menuitem'); - menuitem.setAttribute('id', prefix + i); - menuitem.setAttribute('label', modes[i].label); - menuitem.setAttribute('name', 'searchMode'); - menuitem.setAttribute('type', 'radio'); - //menuitem.setAttribute("tooltiptext", ""); - - menupopup.appendChild(menuitem); - - if (mode == i) { - menuitem.setAttribute('checked', true); - menupopup.selectedItem = menuitem; - } - } - - menupopup.setAttribute( - 'oncommand', - 'var mode = event.target.id.substr(22); ' - + 'Zotero.Prefs.set("search.quicksearch-mode", mode);' - ); - - button.appendChild(menupopup); - hbox.insertBefore(button, input); - - if (Zotero.isFx36) { - searchBox.emptytext = modes[mode].label; - } - else { - searchBox.placeholder = modes[mode].label; - } - } } /** diff --git a/chrome/content/zotero/zoteroPane.xul b/chrome/content/zotero/zoteroPane.xul index cc90a320e7..acc30630b6 100644 --- a/chrome/content/zotero/zoteroPane.xul +++ b/chrome/content/zotero/zoteroPane.xul @@ -144,7 +144,7 @@ -