Allow attachmentLinkMode to be specified as a string ('linked_url')

This commit is contained in:
Dan Stillman 2015-05-05 14:07:48 -04:00
parent 93a6a4ffdb
commit b0f52a0f07

View File

@ -2699,13 +2699,21 @@ Zotero.defineProperty(Zotero.Item.prototype, 'attachmentLinkMode', {
throw (".attachmentLinkMode can only be set for attachment items");
}
// Allow 'imported_url', etc.
if (typeof val == 'string') {
let code = Zotero.Attachments["LINK_MODE_" + val.toUpperCase()];
if (code !== undefined) {
val = code;
}
}
switch (val) {
case Zotero.Attachments.LINK_MODE_IMPORTED_FILE:
case Zotero.Attachments.LINK_MODE_IMPORTED_URL:
case Zotero.Attachments.LINK_MODE_LINKED_FILE:
case Zotero.Attachments.LINK_MODE_LINKED_URL:
break;
default:
throw ("Invalid attachment link mode '" + val
+ "' in Zotero.Item.attachmentLinkMode setter");