commit 87199f6011830f1cd68cd685ef81ff94a26728e2
parent 75999bcc666dbf444d9c2a77c0c181a193ac7247
Author: Simon Kornblith <simon@simonster.com>
Date: Wed, 19 Dec 2012 16:50:37 -0800
Merge pull request #191 from aurimasv/preselect
Allow translators to pre-select items in the "multiple" select item dialog.
Diffstat:
2 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/chrome/content/zotero/ingester/selectitems.js b/chrome/content/zotero/ingester/selectitems.js
@@ -47,11 +47,21 @@ Zotero_Ingester_Interface_SelectItems.init = function() {
var listbox = document.getElementById("zotero-selectitems-links");
for(var i in this.io.dataIn) { // we could use a tree for this if we wanted to
+ var item = this.io.dataIn[i];
+
+ var title, checked = false;
+ if(item && typeof(item) == "object" && item.title !== undefined) {
+ title = item.title;
+ checked = !!item.checked;
+ } else {
+ title = item;
+ }
+
var itemNode = document.createElement("listitem");
itemNode.setAttribute("type", "checkbox");
itemNode.setAttribute("value", i);
- itemNode.setAttribute("label", this.io.dataIn[i]);
- itemNode.setAttribute("checked", false);
+ itemNode.setAttribute("label", title);
+ itemNode.setAttribute("checked", checked);
listbox.appendChild(itemNode);
}
}
diff --git a/chrome/content/zotero/tools/testTranslators/translatorTester.js b/chrome/content/zotero/tools/testTranslators/translatorTester.js
@@ -422,7 +422,11 @@ Zotero_TranslatorTester.prototype.runTest = function(test, doc, testDoneCallback
var newItems = {};
var haveItems = false;
for(var i in items) {
- newItems[i] = items[i];
+ if(items[i] && typeof(items[i]) == "object" && items[i].title !== undefined) {
+ newItems[i] = items[i].title;
+ } else {
+ newItems[i] = items[i];
+ }
haveItems = true;
// only save one item if "items":"multiple" (as opposed to an array of items)
@@ -546,7 +550,11 @@ Zotero_TranslatorTester.prototype.newTest = function(doc, testReadyCallback) {
var newItems = {};
for(var i in items) {
- newItems[i] = items[i];
+ if(items[i] && typeof(items[i]) == "object" && items[i].title !== undefined) {
+ newItems[i] = items[i].title;
+ } else {
+ newItems[i] = items[i];
+ }
break;
}