Index: safari/ext/popup.js |
=================================================================== |
--- a/safari/ext/popup.js |
+++ b/safari/ext/popup.js |
@@ -2,13 +2,22 @@ |
{ |
// Safari will load the popover once, and then show it everytime the icon is |
// clicked. While Chrome loads it everytime you click the icon. So in order to |
- // force the same behavior in Safari, we are going to reload the page of the |
- // bubble everytime it is shown. |
- safari.application.addEventListener("popover", function() |
+ // make the popover show the right state and details we have to reload it |
+ // everytime it is shown for a different tab. Also we have to reload the |
+ // popover when the background page wasn't ready yet, since we have to access |
+ // the background page in the popover. |
+ var backgroundPage = safari.extension.globalPage.contentWindow; |
+ var readyState = backgroundPage.document.readyState; |
+ var activeTab = safari.application.activeBrowserWindow.activeTab; |
+ |
+ safari.self.addEventListener("popover", function() |
{ |
- document.documentElement.style.display = "none"; |
- document.location.reload(); |
- }, true); |
+ if (activeTab != safari.application.activeBrowserWindow.activeTab || readyState != "complete") |
+ { |
+ document.documentElement.style.display = "none"; |
+ document.location.reload(); |
+ } |
+ }); |
// Safari doesn't adjust the size of the popover automatically to the size |
@@ -46,7 +55,6 @@ |
// import ext into the javascript context of the popover. This code might fail, |
// when the background page isn't ready yet. So it is important to put it below |
// the reloading code above. |
- var backgroundPage = safari.extension.globalPage.contentWindow; |
ext = backgroundPage.ext; |
TabMap = backgroundPage.TabMap; |
})(); |