commit 5c324134c636a3a3e0432f1d2f277a6bc2717c2a
parent 62b3ee14ea22475d14f4c5430cc7e0c4aaa78eaf
Author: Simon Kornblith <simon@simonster.com>
Date: Tue, 10 Jan 2012 10:18:23 -0500
Always run detect on all frames, even if a translator has already been found, in order to ensure that we get the translator with the highest priority
Diffstat:
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/chrome/content/zotero/browser.js b/chrome/content/zotero/browser.js
@@ -634,14 +634,7 @@ Zotero_Browser.Tab.prototype.clear = function() {
/*
* detects translators for this browser object
*/
-Zotero_Browser.Tab.prototype.detectTranslators = function(rootDoc, doc) {
- // if there's already a scrapable page in the browser window, and it's
- // still there, ensure it is actually part of the page, then return
- if(this.page.translators && this.page.translators.length && this.page.document.location) {
- if(this._searchFrames(rootDoc, this.page.document)) return;
- this.clear();
- }
-
+Zotero_Browser.Tab.prototype.detectTranslators = function(rootDoc, doc) {
if(doc instanceof HTMLDocument && doc.documentURI.substr(0, 6) != "about:") {
// get translators
var me = this;
@@ -791,6 +784,17 @@ Zotero_Browser.Tab.prototype._selectItems = function(obj, itemList, callback) {
*/
Zotero_Browser.Tab.prototype._translatorsAvailable = function(translate, translators) {
if(translators && translators.length) {
+ // if there's already a scrapable page in the browser window, and it's
+ // still there, ensure it is actually part of the page, then return
+ if(this.page.translators && this.page.translators.length && this.page.document.location) {
+ if(this.page.document.defaultView && !this.page.document.defaultView.closed) {
+ // if it is still there, switch translation to take place on
+ if(!translators.length || this.page.translators[0].priority <= translators[0].priority) return;
+ } else {
+ this.clear();
+ }
+ }
+
this.page.translate = translate;
this.page.translators = translators;
this.page.document = translate.document;