- Make "Save Link As Zotero Snapshot" save attachment to selected collection
- Fix hourglass cursor on importFromURL (happened with "Save Link As Z Snapshot")
This commit is contained in:
parent
61dba96bf8
commit
b8fba0335d
|
@ -55,10 +55,10 @@
|
||||||
oncommand="var itemID = ZoteroPane.addItemFromPage(); ZoteroPane.newNote(false, itemID, window.content.getSelection().toString())"/>
|
oncommand="var itemID = ZoteroPane.addItemFromPage(); ZoteroPane.newNote(false, itemID, window.content.getSelection().toString())"/>
|
||||||
<menuitem id="zotero-context-save-link-as-snapshot" class="menu-iconic"
|
<menuitem id="zotero-context-save-link-as-snapshot" class="menu-iconic"
|
||||||
label="&zotero.contextMenu.saveLinkAsSnapshot;"
|
label="&zotero.contextMenu.saveLinkAsSnapshot;"
|
||||||
oncommand="Zotero.Attachments.importFromURL(window.gContextMenu.linkURL)"/>
|
oncommand="Zotero.Attachments.importFromURL(window.gContextMenu.linkURL, false, false, ZoteroPane.getSelectedCollection(true))"/>
|
||||||
<menuitem id="zotero-context-save-image-as-snapshot" class="menu-iconic"
|
<menuitem id="zotero-context-save-image-as-snapshot" class="menu-iconic"
|
||||||
label="&zotero.contextMenu.saveImageAsSnapshot;"
|
label="&zotero.contextMenu.saveImageAsSnapshot;"
|
||||||
oncommand="Zotero.Attachments.importFromURL(window.gContextMenu.onImage ? window.gContextMenu.imageURL : window.gContextMenu.bgImageURL)"/>
|
oncommand="Zotero.Attachments.importFromURL(window.gContextMenu.onImage ? window.gContextMenu.imageURL : window.gContextMenu.bgImageURL, false, false, ZoteroPane.getSelectedCollection(true))"/>
|
||||||
</popup>
|
</popup>
|
||||||
|
|
||||||
<vbox id="appcontent">
|
<vbox id="appcontent">
|
||||||
|
|
|
@ -168,7 +168,7 @@ Zotero.Attachments = new function(){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function importFromURL(url, sourceItemID, forceTitle){
|
function importFromURL(url, sourceItemID, forceTitle, parentCollectionIDs){
|
||||||
Zotero.debug('Importing attachment from URL');
|
Zotero.debug('Importing attachment from URL');
|
||||||
|
|
||||||
Zotero.Utilities.HTTP.doHead(url, function(obj){
|
Zotero.Utilities.HTTP.doHead(url, function(obj){
|
||||||
|
@ -191,9 +191,13 @@ Zotero.Attachments = new function(){
|
||||||
if (Zotero.MIME.hasNativeHandler(mimeType, ext)){
|
if (Zotero.MIME.hasNativeHandler(mimeType, ext)){
|
||||||
var browser = Zotero.Browser.createHiddenBrowser();
|
var browser = Zotero.Browser.createHiddenBrowser();
|
||||||
browser.addEventListener("pageshow", function(){
|
browser.addEventListener("pageshow", function(){
|
||||||
Zotero.Attachments.importFromDocument(browser.contentDocument, sourceItemID, forceTitle);
|
var callback = function () {
|
||||||
browser.removeEventListener("pageshow", arguments.callee, true);
|
browser.removeEventListener("pageshow", arguments.callee, true);
|
||||||
Zotero.Browser.deleteHiddenBrowser(browser);
|
Zotero.Browser.deleteHiddenBrowser(browser);
|
||||||
|
};
|
||||||
|
|
||||||
|
Zotero.Attachments.importFromDocument(browser.contentDocument,
|
||||||
|
sourceItemID, forceTitle, parentCollectionIDs, callback);
|
||||||
}, true);
|
}, true);
|
||||||
browser.loadURI(url);
|
browser.loadURI(url);
|
||||||
}
|
}
|
||||||
|
@ -221,6 +225,15 @@ Zotero.Attachments = new function(){
|
||||||
attachmentItem.save();
|
attachmentItem.save();
|
||||||
var itemID = attachmentItem.getID();
|
var itemID = attachmentItem.getID();
|
||||||
|
|
||||||
|
// Add to collections
|
||||||
|
if (parentCollectionIDs){
|
||||||
|
var ids = Zotero.flattenArguments(parentCollectionIDs);
|
||||||
|
for each(var id in ids){
|
||||||
|
var col = Zotero.Collections.get(id);
|
||||||
|
col.addItem(itemID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Create a new folder for this item in the storage directory
|
// Create a new folder for this item in the storage directory
|
||||||
var destDir = Zotero.getStorageDirectory();
|
var destDir = Zotero.getStorageDirectory();
|
||||||
destDir.append(itemID);
|
destDir.append(itemID);
|
||||||
|
@ -351,7 +364,7 @@ Zotero.Attachments = new function(){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function importFromDocument(document, sourceItemID, forceTitle, parentCollectionIDs){
|
function importFromDocument(document, sourceItemID, forceTitle, parentCollectionIDs, callback){
|
||||||
Zotero.debug('Importing attachment from document');
|
Zotero.debug('Importing attachment from document');
|
||||||
|
|
||||||
var url = document.location.href;
|
var url = document.location.href;
|
||||||
|
@ -444,6 +457,10 @@ Zotero.Attachments = new function(){
|
||||||
}
|
}
|
||||||
|
|
||||||
Zotero.Fulltext.indexDocument(document, itemID);
|
Zotero.Fulltext.indexDocument(document, itemID);
|
||||||
|
|
||||||
|
if (callback) {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// The attachment is still incomplete here, but we can't risk
|
// The attachment is still incomplete here, but we can't risk
|
||||||
|
@ -635,6 +652,8 @@ Zotero.Attachments = new function(){
|
||||||
// Chain fulltext indexer inside the charset callback,
|
// Chain fulltext indexer inside the charset callback,
|
||||||
// since it's asynchronous and a prerequisite
|
// since it's asynchronous and a prerequisite
|
||||||
Zotero.Fulltext.indexDocument(browser.contentDocument, itemID);
|
Zotero.Fulltext.indexDocument(browser.contentDocument, itemID);
|
||||||
|
|
||||||
|
Zotero.Browser.deleteHiddenBrowser(browser);
|
||||||
}
|
}
|
||||||
}, itemID);
|
}, itemID);
|
||||||
|
|
||||||
|
|
|
@ -155,8 +155,6 @@ Zotero.File = new function(){
|
||||||
prefService.setCharPref('intl.charset.detector', oldPref);
|
prefService.setCharPref('intl.charset.detector', oldPref);
|
||||||
|
|
||||||
callback(charset, args);
|
callback(charset, args);
|
||||||
|
|
||||||
Zotero.Browser.deleteHiddenBrowser(browser);
|
|
||||||
}, false);
|
}, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user