From 352158b48ca28233a56ed564ea7e5dc3b4fee690 Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Sun, 7 Nov 2010 03:13:58 +0000 Subject: [PATCH] - add ZU.deepCopy() - fix attachment export/import - make Translator return a copy of displayOptions or configOptions objects - adjust file export functions for above change --- chrome/content/zotero/exportOptions.js | 5 +- chrome/content/zotero/fileInterface.js | 6 +- .../zotero/xpcom/translation/item_local.js | 63 ++++++++++--------- .../zotero/xpcom/translation/translate.js | 4 +- .../zotero/xpcom/translation/translator.js | 11 +++- chrome/content/zotero/xpcom/utilities.js | 17 +++++ 6 files changed, 67 insertions(+), 39 deletions(-) diff --git a/chrome/content/zotero/exportOptions.js b/chrome/content/zotero/exportOptions.js index 3a72b1aa2..75e8cbdaf 100644 --- a/chrome/content/zotero/exportOptions.js +++ b/chrome/content/zotero/exportOptions.js @@ -194,16 +194,17 @@ var Zotero_File_Interface_Export = new function() { // set options on selected translator and generate optionString var optionString = ""; var optionsAvailable = window.arguments[0].selectedTranslator.displayOptions; + var displayOptions = window.arguments[0].displayOptions = {}; for(var option in optionsAvailable) { var defValue = optionsAvailable[option]; var element = document.getElementById(OPTION_PREFIX+option); if(option == "exportCharset") { if(_charsets) { - optionsAvailable[option] = element.selectedItem.value; + displayOptions[option] = element.selectedItem.value; } } else if(typeof(defValue) == "boolean") { - optionsAvailable[option] = !!element.checked; + displayOptions[option] = !!element.checked; } } diff --git a/chrome/content/zotero/fileInterface.js b/chrome/content/zotero/fileInterface.js index 87f51cb36..a8831c3db 100644 --- a/chrome/content/zotero/fileInterface.js +++ b/chrome/content/zotero/fileInterface.js @@ -58,7 +58,7 @@ Zotero_File_Exporter.prototype.save = function() { fp.init(window, Zotero.getString("fileInterface.export"), nsIFilePicker.modeSave); // set file name and extension - if(io.selectedTranslator.displayOptions.exportFileData) { + if(io.displayOptions.exportFileData) { // if the result will be a folder, don't append any extension or use // filters fp.defaultString = this.name; @@ -80,6 +80,7 @@ Zotero_File_Exporter.prototype.save = function() { translation.setLocation(fp.file); translation.setTranslator(io.selectedTranslator); + translation.setDisplayOptions(io.displayOptions); translation.setHandler("done", this._exportDone); Zotero.UnresponsiveScriptIndicator.disable(); Zotero_File_Interface.Progress.show( @@ -259,7 +260,8 @@ var Zotero_File_Interface = new function() { function _importTranslatorsAvailable(translation, translators) { if(translators.length) { if(translation.location instanceof Components.interfaces.nsIFile) { - var collectionName = translation.location.leafName.substr(0, translation.location.leafName.lastIndexOf(".")); + var collectionName = (translation.location.isDirectory() ? translation.location.leafName + : translation.location.leafName.substr(0, translation.location.leafName.lastIndexOf("."))); var allCollections = Zotero.getCollections(); for(var i=0; i