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

Unified Diff: safari/ext/popup.js

Issue 6499942772244480: Reload popover on Safari every time it is shown (Closed)
Patch Set: Addressed comment Created Jan. 23, 2014, 1:59 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
@@ -1,30 +1,10 @@
(function()
{
- // 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
- // 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 valid = backgroundPage.document.readyState == "complete";
- var activeTab = safari.application.activeBrowserWindow.activeTab;
- var mayResize = true;
-
- safari.self.addEventListener("popover", function()
- {
- if (!valid || activeTab != safari.application.activeBrowserWindow.activeTab)
- {
- mayResize = false;
- document.documentElement.style.display = "none";
- document.location.reload();
- }
- });
-
-
// Safari doesn't adjust the size of the popover automatically to the size
// of its content, like when the ad counter is expanded/collapsed. So we add
// event listeners to do so.
+ var mayResize = true;
+
var updateSize = function()
{
if (mayResize)
@@ -51,6 +31,18 @@
});
+ // 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
+ // make the popover show the right state and details, we have to emulate the
+ // same behavior as on Chrome, by reloading the popover every time it is shown.
+ safari.self.addEventListener("popover", function()
+ {
+ mayResize = false;
+ document.documentElement.style.display = "none";
+ document.location.reload();
+ });
+
+
// Safari doesn't hide popovers automatically, when we change the active tab
// programmatically, like when the options link is clicked. So we add an event
// listener to do so.
@@ -63,12 +55,13 @@
// 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;
+
window.ext = {
__proto__: backgroundPage.ext,
closePopup: function()
{
safari.self.hide();
- valid = false;
}
};
window.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