Closes #494, Remember "Rename associated file" setting
Also: - Clicking OK on rename dialog with "Rename associated file" checked but without changing the filename would delete the original file. - Add "Show File" button for snapshots
This commit is contained in:
parent
9c666cef3a
commit
28a6b5f7cb
|
@ -481,7 +481,7 @@ var ZoteroPane = new function()
|
|||
.getService(Components.interfaces.nsIPromptService);
|
||||
|
||||
var newTitle = { value: val };
|
||||
var checkState = { value: false };
|
||||
var checkState = { value: Zotero.Prefs.get('lastRenameAssociatedFile') };
|
||||
|
||||
while (true) {
|
||||
var result = nsIPS.prompt(window,
|
||||
|
@ -490,10 +490,14 @@ var ZoteroPane = new function()
|
|||
Zotero.getString('pane.item.attachments.rename.renameAssociatedFile'),
|
||||
checkState);
|
||||
|
||||
// If they hit cancel or left it blank
|
||||
if (!result || !newTitle.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
Zotero.Prefs.set('lastRenameAssociatedFile', checkState.value);
|
||||
|
||||
// Rename associated file
|
||||
if (checkState.value) {
|
||||
var renamed = item.ref.renameAttachmentFile(newTitle.value);
|
||||
if (renamed == -1) {
|
||||
|
@ -502,6 +506,8 @@ var ZoteroPane = new function()
|
|||
item.ref.renameAttachmentFile(newTitle.value, true);
|
||||
break;
|
||||
}
|
||||
// If they said not to overwrite existing file,
|
||||
// start again
|
||||
continue;
|
||||
}
|
||||
else if (renamed == -2 || !renamed) {
|
||||
|
@ -520,12 +526,14 @@ var ZoteroPane = new function()
|
|||
}
|
||||
|
||||
|
||||
var isImportedURL = item.ref.getAttachmentLinkMode() == Zotero.Attachments.LINK_MODE_IMPORTED_URL;
|
||||
|
||||
// Metadata for URL's
|
||||
if (item.ref.getAttachmentLinkMode() == Zotero.Attachments.LINK_MODE_LINKED_URL
|
||||
|| item.ref.getAttachmentLinkMode() == Zotero.Attachments.LINK_MODE_IMPORTED_URL)
|
||||
|| isImportedURL)
|
||||
{
|
||||
// "View Page"/"View Snapshot" label
|
||||
if (item.ref.getAttachmentLinkMode() == Zotero.Attachments.LINK_MODE_IMPORTED_URL)
|
||||
if (isImportedURL)
|
||||
{
|
||||
var str = Zotero.getString('pane.item.attachments.view.snapshot');
|
||||
}
|
||||
|
@ -534,7 +542,7 @@ var ZoteroPane = new function()
|
|||
var str = Zotero.getString('pane.item.attachments.view.link');
|
||||
}
|
||||
|
||||
document.getElementById('zotero-attachment-show').setAttribute('hidden', true);
|
||||
document.getElementById('zotero-attachment-show').setAttribute('hidden', !isImportedURL);
|
||||
|
||||
// URL
|
||||
document.getElementById('zotero-attachment-url').setAttribute('value', item.getField('url'));
|
||||
|
|
|
@ -1426,17 +1426,21 @@ Zotero.Item.prototype.getFile = function(row){
|
|||
* -2 Error renaming
|
||||
* false Attachment file not found or other error
|
||||
*/
|
||||
Zotero.Item.prototype.renameAttachmentFile = function(newName, force) {
|
||||
Zotero.Item.prototype.renameAttachmentFile = function(newName, overwrite) {
|
||||
var file = this.getFile();
|
||||
if (!file) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
if (file.leafName == newName) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var dest = file.parent;
|
||||
dest.append(newName);
|
||||
|
||||
if (force) {
|
||||
if (overwrite) {
|
||||
dest.remove(null);
|
||||
}
|
||||
else if (dest.exists()) {
|
||||
|
|
|
@ -14,7 +14,9 @@ pref("extensions.zotero.automaticSnapshots",true);
|
|||
pref("extensions.zotero.downloadAssociatedFiles",false);
|
||||
pref("extensions.zotero.reportTranslationFailure",true);
|
||||
pref("extensions.zotero.enableMacClipboard",false);
|
||||
|
||||
pref("extensions.zotero.lastCreatorFieldMode",0);
|
||||
pref("extensions.zotero.lastRenameAssociatedFile", false);
|
||||
|
||||
// Keyboard shortcuts
|
||||
pref("extensions.zotero.keys.overrideGlobal", true);
|
||||
|
|
Loading…
Reference in New Issue
Block a user