commit ebd8dfeb65f091458b62908fcf14021776751e29
parent b2a7050deae425738fa35fb9217c6e9bf50b9ef9
Author: Simon Kornblith <simon@simonster.com>
Date: Sun, 3 Mar 2013 18:59:29 -0500
Don't show "undefined" in attachment progress window
Diffstat:
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/chrome/content/zotero/xpcom/translation/translate_item.js b/chrome/content/zotero/xpcom/translation/translate_item.js
@@ -351,6 +351,12 @@ Zotero.Translate.ItemSaver.prototype = {
if(attachment.document) {
attachment.document = Zotero.Translate.DOMWrapper.unwrap(attachment.document);
+ if(!attachment.title) attachment.title = attachment.document.title;
+ }
+ var title = attachment.title || null;
+ if(!title) {
+ // If no title provided, use "Attachment" as title for progress UI (but not for item)
+ attachment.title = Zotero.getString("itemTypes.attachment");
}
if(attachment.snapshot === false || !this._saveFiles) {
@@ -360,7 +366,7 @@ Zotero.Translate.ItemSaver.prototype = {
try {
Zotero.Attachments.linkFromURL(attachment.document.location.href, parentID,
(attachment.mimeType ? attachment.mimeType : attachment.document.contentType),
- (attachment.title ? attachment.title : attachment.document.title));
+ title);
attachmentCallback(attachment, 100);
} catch(e) {
Zotero.debug("Translate: Error adding attachment "+attachment.url, 2);
@@ -368,14 +374,14 @@ Zotero.Translate.ItemSaver.prototype = {
}
return true;
} else {
- if(!attachment.mimeType || !attachment.title) {
+ if(!attachment.mimeType || !title) {
Zotero.debug("Translate: Either mimeType or title is missing; attaching file will be slower", 3);
}
try {
Zotero.Attachments.linkFromURL(attachment.url, parentID,
(attachment.mimeType ? attachment.mimeType : undefined),
- (attachment.title ? attachment.title : undefined));
+ title);
attachmentCallback(attachment, 100);
} catch(e) {
Zotero.debug("Translate: Error adding attachment "+attachment.url, 2);
@@ -389,7 +395,7 @@ Zotero.Translate.ItemSaver.prototype = {
try {
attachment.linkMode = "imported_url";
Zotero.Attachments.importFromDocument(attachment.document,
- parentID, attachment.title, null, function(status, err) {
+ parentID, title, null, function(status, err) {
if(status) {
attachmentCallback(attachment, 100);
} else {
@@ -420,8 +426,6 @@ Zotero.Translate.ItemSaver.prototype = {
return;
}
var mimeType = (attachment.mimeType ? attachment.mimeType : null);
- var title = (attachment.title ? attachment.title : null);
-
var fileBaseName = Zotero.Attachments.getFileBaseNameFromItem(parentID);
try {
Zotero.debug('Translate: Importing attachment from URL', 4);