diff --git a/chrome/content/zotero/fileInterface.js b/chrome/content/zotero/fileInterface.js
index 82615d3eb..ca6007c45 100644
--- a/chrome/content/zotero/fileInterface.js
+++ b/chrome/content/zotero/fileInterface.js
@@ -312,7 +312,7 @@ var Zotero_File_Interface = new function() {
*
* Does not check that items are actual references (and not notes or attachments)
*/
- function copyItemsToClipboard(items, style) {
+ function copyItemsToClipboard(items, style, asHTML) {
// copy to clipboard
var transferable = Components.classes["@mozilla.org/widget/transferable;1"].
createInstance(Components.interfaces.nsITransferable);
@@ -329,8 +329,8 @@ var Zotero_File_Interface = new function() {
transferable.addDataFlavor("text/html");
transferable.setTransferData("text/html", str, bibliography.length*2);
- // add text
- var bibliography = csl.formatBibliography(itemSet, "Text");
+ // add text (or HTML source)
+ var bibliography = csl.formatBibliography(itemSet, asHTML ? 'HTML' : 'Text');
var str = Components.classes["@mozilla.org/supports-string;1"].
createInstance(Components.interfaces.nsISupportsString);
str.data = bibliography;
@@ -345,8 +345,10 @@ var Zotero_File_Interface = new function() {
* Copies HTML and text citations for passed items in given style
*
* Does not check that items are actual references (and not notes or attachments)
+ *
+ * if |asHTML| is true, copy HTML source as text
*/
- function copyCitationToClipboard(items, style) {
+ function copyCitationToClipboard(items, style, asHTML) {
// copy to clipboard
var transferable = Components.classes["@mozilla.org/widget/transferable;1"].
createInstance(Components.interfaces.nsITransferable);
@@ -369,8 +371,8 @@ var Zotero_File_Interface = new function() {
transferable.addDataFlavor("text/html");
transferable.setTransferData("text/html", str, bibliography.length*2);
- // add text
- var bibliography = csl.formatCitation(citation, "Text");
+ // add text (or HTML source)
+ var bibliography = csl.formatCitation(citation, asHTML ? 'HTML' : 'Text');
var str = Components.classes["@mozilla.org/supports-string;1"].
createInstance(Components.interfaces.nsISupportsString);
str.data = bibliography;
diff --git a/chrome/content/zotero/overlay.js b/chrome/content/zotero/overlay.js
index 98ce910a9..13cdc198f 100644
--- a/chrome/content/zotero/overlay.js
+++ b/chrome/content/zotero/overlay.js
@@ -1139,13 +1139,14 @@ var ZoteroPane = new function()
var url = window.content.location.href;
var [mode, format] = Zotero.QuickCopy.getFormatFromURL(url).split('=');
+ var [mode, contentType] = mode.split('/');
if (mode == 'bibliography') {
if (asCitations) {
- Zotero_File_Interface.copyCitationToClipboard(items, format);
+ Zotero_File_Interface.copyCitationToClipboard(items, format, contentType == 'html');
}
else {
- Zotero_File_Interface.copyItemsToClipboard(items, format);
+ Zotero_File_Interface.copyItemsToClipboard(items, format, contentType == 'html');
}
}
else if (mode == 'export') {
diff --git a/chrome/content/zotero/preferences/preferences.js b/chrome/content/zotero/preferences/preferences.js
index 42a09f8ab..eb5cb0798 100644
--- a/chrome/content/zotero/preferences/preferences.js
+++ b/chrome/content/zotero/preferences/preferences.js
@@ -134,18 +134,32 @@ function populateOpenURLResolvers() {
}
+/*
+ * Builds the main Quick Copy drop-down from the current global pref
+ */
function populateQuickCopyList() {
// Initialize default format drop-down
- var formatMenu = document.getElementById("quickCopy-menu");
var format = Zotero.Prefs.get("export.quickCopy.setting");
- buildQuickCopyFormatDropDown(formatMenu, format);
- formatMenu.setAttribute('preference', "pref-quickCopy-setting");
+ var menulist = document.getElementById("zotero-quickCopy-menu");
+ buildQuickCopyFormatDropDown(menulist, Zotero.QuickCopy.getContentType(format), format);
+ menulist.setAttribute('preference', "pref-quickCopy-setting");
+ updateQuickCopyHTMLCheckbox();
refreshQuickCopySiteList();
}
-function buildQuickCopyFormatDropDown(menulist, currentFormat) {
+/*
+ * Builds a Quick Copy drop-down
+ */
+function buildQuickCopyFormatDropDown(menulist, contentType, currentFormat) {
+ if (!currentFormat) {
+ currentFormat = menulist.value;
+ }
+ // Strip contentType from mode
+ currentFormat = Zotero.QuickCopy.stripContentType(currentFormat);
+
+
menulist.selectedItem = null;
menulist.removeAllItems();
@@ -167,13 +181,15 @@ function buildQuickCopyFormatDropDown(menulist, currentFormat) {
// add styles to list
var styles = Zotero.Cite.getStyles();
for (var i in styles) {
- var val = 'bibliography=' + i;
+ var baseVal = 'bibliography=' + i;
+ var val = 'bibliography' + (contentType == 'html' ? '/html' : '') + '=' + i;
var itemNode = document.createElement("menuitem");
itemNode.setAttribute("value", val);
itemNode.setAttribute("label", styles[i]);
+ itemNode.setAttribute("oncommand", 'updateQuickCopyHTMLCheckbox()');
popup.appendChild(itemNode);
- if (val == currentFormat) {
+ if (baseVal == currentFormat) {
menulist.selectedItem = itemNode;
}
}
@@ -198,6 +214,7 @@ function buildQuickCopyFormatDropDown(menulist, currentFormat) {
var itemNode = document.createElement("menuitem");
itemNode.setAttribute("value", val);
itemNode.setAttribute("label", translators[i].label);
+ itemNode.setAttribute("oncommand", 'updateQuickCopyHTMLCheckbox()');
popup.appendChild(itemNode);
if (val == currentFormat) {
@@ -205,19 +222,37 @@ function buildQuickCopyFormatDropDown(menulist, currentFormat) {
}
}
+ menulist.click();
+
return popup;
}
+function updateQuickCopyHTMLCheckbox() {
+ var format = document.getElementById('zotero-quickCopy-menu').value;
+ var mode, contentType;
+
+ var checkbox = document.getElementById('zotero-quickCopy-copyAsHTML');
+ [mode, format] = format.split('=');
+ [mode, contentType] = mode.split('/');
+
+ checkbox.checked = contentType == 'html';
+ checkbox.disabled = mode != 'bibliography';
+}
+
function showQuickCopySiteEditor(index) {
var treechildren = document.getElementById('quickCopy-siteSettings-rows');
if (index != undefined && index > -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 domain = treerow.childNodes[0].getAttribute('label');
+ var format = treerow.childNodes[1].getAttribute('label');
+ var asHTML = treerow.childNodes[2].getAttribute('label') != '';
}
var format = Zotero.QuickCopy.getSettingFromFormattedName(format);
+ if (asHTML) {
+ format = format.replace('bibliography=', 'bibliography/html=');
+ }
var io = {domain: domain, format: format, ok: false};
window.openDialog('chrome://zotero/content/preferences/quickCopySiteEditor.xul', "zotero-preferences-quickCopySiteEditor", "chrome, modal", io);
@@ -254,14 +289,18 @@ function refreshQuickCopySiteList() {
var treerow = document.createElement('treerow');
var domainCell = document.createElement('treecell');
var formatCell = document.createElement('treecell');
+ var HTMLCell = document.createElement('treecell');
domainCell.setAttribute('label', siteData[i].domainPath);
var formatted = Zotero.QuickCopy.getFormattedNameFromSetting(siteData[i].format);
formatCell.setAttribute('label', formatted);
+ var copyAsHTML = Zotero.QuickCopy.getContentType(siteData[i].format) == 'html';
+ HTMLCell.setAttribute('label', copyAsHTML ? ' ✓ ' : '');
treerow.appendChild(domainCell);
treerow.appendChild(formatCell);
+ treerow.appendChild(HTMLCell);
treeitem.appendChild(treerow);
treechildren.appendChild(treeitem);
}
diff --git a/chrome/content/zotero/preferences/preferences.xul b/chrome/content/zotero/preferences/preferences.xul
index eff54e0ca..ef4c81f01 100644
--- a/chrome/content/zotero/preferences/preferences.xul
+++ b/chrome/content/zotero/preferences/preferences.xul
@@ -262,30 +262,32 @@ To add a new preference:
-
-
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/chrome/content/zotero/preferences/quickCopySiteEditor.xul b/chrome/content/zotero/preferences/quickCopySiteEditor.xul
index 75488d212..fae0d66b8 100644
--- a/chrome/content/zotero/preferences/quickCopySiteEditor.xul
+++ b/chrome/content/zotero/preferences/quickCopySiteEditor.xul
@@ -20,7 +20,7 @@
function onAccept() {
var io = window.arguments[0];
io.domain = document.getElementById('zotero-quickCopy-domain').value;
- io.format = document.getElementById('zotero-quickCopy-format').value;
+ io.format = document.getElementById('zotero-quickCopy-menu').value;
io.ok = true;
}
}
@@ -28,21 +28,22 @@
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/chrome/content/zotero/xpcom/itemTreeView.js b/chrome/content/zotero/xpcom/itemTreeView.js
index b5e51719f..2d7c222fa 100644
--- a/chrome/content/zotero/xpcom/itemTreeView.js
+++ b/chrome/content/zotero/xpcom/itemTreeView.js
@@ -1432,9 +1432,6 @@ Zotero.ItemTreeCommandController.prototype.onEvent = function(evt)
*/
Zotero.ItemTreeView.prototype.onDragStart = function (evt,transferData,action)
{
- try {
-
-
transferData.data = new TransferData();
transferData.data.addDataForFlavour("zotero/item", this.saveSelection());
@@ -1472,17 +1469,13 @@ Zotero.ItemTreeView.prototype.onDragStart = function (evt,transferData,action)
if (mode == 'export') {
Zotero.QuickCopy.getContentFromItems(items, format, exportCallback);
}
- else if (mode == 'bibliography') {
+ else if (mode.indexOf('bibliography') == 0) {
var content = Zotero.QuickCopy.getContentFromItems(items, format);
transferData.data.addDataForFlavour("text/unicode", content.text);
transferData.data.addDataForFlavour("text/html", content.html);
}
-
-
-
- }
- catch (e) {
- Zotero.debug(e);
+ else {
+ Components.utils.reportError("Invalid Quick Copy mode '" + mode + "'");
}
}
diff --git a/chrome/content/zotero/xpcom/quickCopy.js b/chrome/content/zotero/xpcom/quickCopy.js
index 94f5b555e..9b659677a 100644
--- a/chrome/content/zotero/xpcom/quickCopy.js
+++ b/chrome/content/zotero/xpcom/quickCopy.js
@@ -1,6 +1,8 @@
Zotero.QuickCopy = new function() {
this.getFormattedNameFromSetting = getFormattedNameFromSetting;
this.getSettingFromFormattedName = getSettingFromFormattedName;
+ this.getContentType = getContentType;
+ this.stripContentType = stripContentType;
this.getFormatFromURL = getFormatFromURL;
this.getContentFromItems = getContentFromItems;
@@ -13,7 +15,7 @@ Zotero.QuickCopy = new function() {
_init();
}
- return _formattedNames[setting];
+ return _formattedNames[this.stripContentType(setting)];
}
function getSettingFromFormattedName(name) {
@@ -31,6 +33,23 @@ Zotero.QuickCopy = new function() {
}
+ /*
+ * Returns the setting with any contentType stripped from the mode part
+ */
+ function getContentType(setting) {
+ var matches = setting.match(/(?:bibliography|export)\/([^=]+)=.+$/, '$1');
+ return matches ? matches[1] : '';
+ }
+
+
+ /*
+ * Returns the setting with any contentType stripped from the mode part
+ */
+ function stripContentType(setting) {
+ return setting.replace(/(bibliography|export)(?:\/[^=]+)?=(.+)$/, '$1=$2');
+ }
+
+
function getFormatFromURL(url) {
if (!url) {
return Zotero.Prefs.get("export.quickCopy.setting");
@@ -51,9 +70,9 @@ Zotero.QuickCopy = new function() {
var matches = [];
var sql = "SELECT key AS domainPath, value AS format FROM settings "
- + "WHERE setting='quickCopySite' AND key LIKE ?";
+ + "WHERE setting='quickCopySite' AND (key LIKE ? OR key LIKE ?)";
var urlDomain = urlHostPort.match(/[^\.]+\.[^\.]+$/);
- var rows = Zotero.DB.query(sql, ['%' + urlDomain + '%']);
+ var rows = Zotero.DB.query(sql, ['%' + urlDomain + '%', '/%']);
for each(var row in rows) {
var [domain, path] = row.domainPath.split(/\//);
path = '/' + (path ? path : '');
@@ -113,6 +132,7 @@ Zotero.QuickCopy = new function() {
*/
function getContentFromItems(items, format, callback) {
var [mode, format] = format.split('=');
+ var [mode, contentType] = mode.split('/');
if (mode == 'export') {
var translation = new Zotero.Translate("export");
@@ -127,7 +147,7 @@ Zotero.QuickCopy = new function() {
var csl = Zotero.Cite.getStyle(format);
var itemSet = csl.createItemSet(items);
var bibliography = {
- text: csl.formatBibliography(itemSet, "Text"),
+ text: csl.formatBibliography(itemSet, contentType == "html" ? "HTML" : "Text"),
html: csl.formatBibliography(itemSet, "HTML")
};
return bibliography;
diff --git a/chrome/locale/en-US/zotero/preferences.dtd b/chrome/locale/en-US/zotero/preferences.dtd
index 4eacfc5af..6b5899c88 100644
--- a/chrome/locale/en-US/zotero/preferences.dtd
+++ b/chrome/locale/en-US/zotero/preferences.dtd
@@ -53,6 +53,7 @@
+
diff --git a/chrome/skin/default/zotero/preferences.css b/chrome/skin/default/zotero/preferences.css
index f4845bfef..d262a20b0 100644
--- a/chrome/skin/default/zotero/preferences.css
+++ b/chrome/skin/default/zotero/preferences.css
@@ -100,6 +100,14 @@ grid row hbox:first-child
font-size: .85em;
}
+#quickCopy-siteSettings-rows::-moz-tree-cell(quickCopy-copyAsHTML) {
+ /*
+ DEBUG: possible to center checkmark here instead of with spaces?
+
+ Tried text-align, -moz-box-align, and -moz-box-pack
+ */
+}
+
#zotero-quickCopy-format
{
min-height: 1.5em; /* Fix collapse on Windows */