Better progress window handling for feed item scraping

This commit is contained in:
Adomas Venčkauskas 2016-10-14 15:46:23 +03:00
parent 32ea7cfbb5
commit 0d2794531a
2 changed files with 8 additions and 11 deletions

View file

@ -100,8 +100,6 @@ var Zotero_Browser = new function() {
function init() { function init() {
// No gBrowser - running in standalone // No gBrowser - running in standalone
if (!window.hasOwnProperty("gBrowser")) { if (!window.hasOwnProperty("gBrowser")) {
// We can still have a progress window in this though
reload();
return; return;
} }

View file

@ -217,20 +217,19 @@ Zotero.FeedItem.prototype.translate = Zotero.Promise.coroutine(function* (librar
let deferred = Zotero.Promise.defer(); let deferred = Zotero.Promise.defer();
let error = function(e) { Zotero.debug(e, 1); deferred.reject(e); }; let error = function(e) { Zotero.debug(e, 1); deferred.reject(e); };
let translate = new Zotero.Translate.Web(); let translate = new Zotero.Translate.Web();
let progressWindow = new Zotero.ProgressWindow();
if (libraryID) { if (libraryID) {
// Show progress notifications when scraping to a library. Shown under the most recent // Show progress notifications when scraping to a library.
// window (Zotero Pane). Browser window not available in standalone.
var win = Services.wm.getMostRecentWindow(null);
translate.clearHandlers("done"); translate.clearHandlers("done");
translate.clearHandlers("itemDone"); translate.clearHandlers("itemDone");
translate.setHandler("done", win.Zotero_Browser.progress.Translation.doneHandler); translate.setHandler("done", progressWindow.Translation.doneHandler);
translate.setHandler("itemDone", win.Zotero_Browser.progress.Translation.itemDoneHandler()); translate.setHandler("itemDone", progressWindow.Translation.itemDoneHandler());
if (collectionID) { if (collectionID) {
var collection = yield Zotero.Collections.getAsync(collectionID); var collection = yield Zotero.Collections.getAsync(collectionID);
} }
win.Zotero_Browser.progress.show(); progressWindow.show();
win.Zotero_Browser.progress.Translation.scrapingTo(libraryID, collection); progressWindow.Translation.scrapingTo(libraryID, collection);
} }
// Load document // Load document
@ -269,8 +268,8 @@ Zotero.FeedItem.prototype.translate = Zotero.Promise.coroutine(function* (librar
}); });
} }
win.Zotero_Browser.progress.Translation.itemDoneHandler()(null, null, item); progressWindow.Translation.itemDoneHandler()(null, null, item);
win.Zotero_Browser.progress.Translation.doneHandler(null, true); progressWindow.Translation.doneHandler(null, true);
return; return;
} }
translate.setTranslator(translators[0]); translate.setTranslator(translators[0]);