Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: safari/ext/popup.js

Issue 5037474598354944: Only reload the popover in Safari, when itself is shown for a different tab (Closed)
Patch Set: Reload the bubble only when it is shown for a different tab Created Jan. 15, 2014, 5:53 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
})();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld