- If snapshot pref is off or toggled off, save web page item for open PDF via Create New Item from Current Page rather than standalone PDF attachment

- When saving open PDF via CNIfCP, select in items list (after a currently unavoidable one-second delay)
This commit is contained in:
Dan Stillman 2009-11-23 10:40:24 +00:00
parent 6059bf0e1b
commit 31943dfba7
2 changed files with 19 additions and 4 deletions

View file

@ -2564,6 +2564,9 @@ var ZoteroPane = new function()
progressWin.show();
progressWin.startCloseTimer();
// Save snapshot if explicitly enabled or automatically pref is set and not explicitly disabled
saveSnapshot = saveSnapshot || (saveSnapshot !== false && Zotero.Prefs.get('automaticSnapshots'));
// TODO: this, needless to say, is a temporary hack
if (itemType == 'temporaryPDFHack') {
itemType = null;
@ -2586,7 +2589,7 @@ var ZoteroPane = new function()
}
}
if (isPDF) {
if (isPDF && saveSnapshot) {
//
// Duplicate newItem() checks here
//
@ -2629,7 +2632,16 @@ var ZoteroPane = new function()
var collectionID = false;
}
Zotero.Attachments.importFromDocument(doc, false, false, collectionID, null, libraryID);
var itemID = Zotero.Attachments.importFromDocument(doc, false, false, collectionID, null, libraryID);
// importFromDocument() doesn't trigger the notifier for a second
//
// The one-second delay is weird but better than nothing
var self = this;
setTimeout(function () {
self.selectItem(itemID);
}, 1001);
return;
}
}
@ -2654,8 +2666,7 @@ var ZoteroPane = new function()
filesEditable = true;
}
// Save snapshot if explicitly enabled or automatically pref is set and not explicitly disabled
if (saveSnapshot || (saveSnapshot !== false && Zotero.Prefs.get('automaticSnapshots'))) {
if (saveSnapshot) {
var link = false;
if (link) {

View file

@ -644,6 +644,10 @@ Zotero.Attachments = new function(){
timer.initWithCallback({notify: f}, 1000,
Components.interfaces.nsITimer.TYPE_ONE_SHOT);
}
// Caution: Take care using this itemID. The notifier may not yet have been called,
// so the attachment may not be available in, for example, the items list
return itemID;
}
catch (e) {
Zotero.DB.rollbackTransaction();