diff --git a/chrome/content/zotero/overlay.js b/chrome/content/zotero/overlay.js index 412ef810a..55d6b6147 100644 --- a/chrome/content/zotero/overlay.js +++ b/chrome/content/zotero/overlay.js @@ -895,8 +895,7 @@ var ZoteroPane = new function() } var [mode, format] = Zotero.Prefs.get("export.quickCopy.setting").split('='); - Zotero.debug(mode); - Zotero.debug(format); + if (mode == 'bibliography') { Zotero_File_Interface.copyItemsToClipboard(items, format); } diff --git a/chrome/content/zotero/preferences.js b/chrome/content/zotero/preferences.js index ace67b0c8..ab0079662 100644 --- a/chrome/content/zotero/preferences.js +++ b/chrome/content/zotero/preferences.js @@ -134,14 +134,31 @@ function populateOpenURLResolvers() { function populateQuickCopyList() { + // Initialize default format drop-down var formatMenu = document.getElementById("quickCopy-menu"); - var listbox = formatMenu.firstChild; var format = Zotero.Prefs.get("export.quickCopy.setting"); + buildQuickCopyFormatDropDown(formatMenu, format); + formatMenu.setAttribute('preference', "pref-quickCopy-setting"); + + refreshQuickCopySiteList(); +} + + +function buildQuickCopyFormatDropDown(menulist, currentFormat) { + // Prevent Cmd-w from setting "Wikipedia" + menulist.onkeydown = function (event) { + if ((Zotero.isMac && event.metaKey) || event.ctrlKey) { + event.preventDefault(); + } + } + + var popup = document.createElement('menupopup'); + menulist.appendChild(popup); var itemNode = document.createElement("menuitem"); itemNode.setAttribute("label", Zotero.getString('zotero.preferences.export.quickCopy.bibStyles')); itemNode.setAttribute("disabled", true); - listbox.appendChild(itemNode); + popup.appendChild(itemNode); // add styles to list var styles = Zotero.Cite.getStyles(); @@ -150,23 +167,23 @@ function populateQuickCopyList() { var itemNode = document.createElement("menuitem"); itemNode.setAttribute("value", val); itemNode.setAttribute("label", styles[i]); - listbox.appendChild(itemNode); + popup.appendChild(itemNode); - if (val == format) { - formatMenu.selectedItem = itemNode; + if (val == currentFormat) { + menulist.selectedItem = itemNode; } } var itemNode = document.createElement("menuitem"); itemNode.setAttribute("label", Zotero.getString('zotero.preferences.export.quickCopy.exportFormats')); itemNode.setAttribute("disabled", true); - listbox.appendChild(itemNode); + popup.appendChild(itemNode); // add export formats to list var translation = new Zotero.Translate("export"); var translators = translation.getTranslators(); - for (var i in translators) { + for (var i=0; i -1 && index < treechildren.childNodes.length) { + var treerow = treechildren.childNodes[index].firstChild; + var domain = treerow.childNodes[0].getAttribute('label') + var format = treerow.childNodes[1].getAttribute('label') + } + + var format = Zotero.QuickCopy.getSettingFromFormattedName(format); + + var io = {domain: domain, format: format, ok: false}; + window.openDialog('chrome://zotero/content/quickCopySiteEditor.xul', "zotero-preferences-quickCopySiteEditor", "chrome, modal", io); + + if (!io.ok) { + return; + } + + if (domain && domain != io.domain) { + Zotero.DB.query("DELETE FROM settings WHERE setting='quickCopySite' AND key=?", [domain]); + } + + Zotero.DB.query("REPLACE INTO settings VALUES ('quickCopySite', ?, ?)", [io.domain, io.format]); + + refreshQuickCopySiteList(); +} + +function refreshQuickCopySiteList() { + var treechildren = document.getElementById('quickCopy-siteSettings-rows'); + while (treechildren.hasChildNodes()) { + treechildren.removeChild(treechildren.firstChild); + } + + var sql = "SELECT key AS domainPath, value AS format FROM settings " + + "WHERE setting='quickCopySite' ORDER BY domainPath COLLATE NOCASE"; + var siteData = Zotero.DB.query(sql); + + if (!siteData) { + return; + } + + for (var i=0; i -