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

Side by Side 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.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 (function() 1 (function()
2 { 2 {
3 // Safari will load the popover once, and then show it everytime the icon is 3 // Safari will load the popover once, and then show it everytime the icon is
4 // clicked. While Chrome loads it everytime you click the icon. So in order to 4 // clicked. While Chrome loads it everytime you click the icon. So in order to
5 // force the same behavior in Safari, we are going to reload the page of the 5 // make the popover show the right state and details we have to reload it
6 // bubble everytime it is shown. 6 // everytime it is shown for a different tab. Also we have to reload the
7 safari.application.addEventListener("popover", function() 7 // popover when the background page wasn't ready yet, since we have to access
8 // the background page in the popover.
9 var backgroundPage = safari.extension.globalPage.contentWindow;
10 var readyState = backgroundPage.document.readyState;
11 var activeTab = safari.application.activeBrowserWindow.activeTab;
12
13 safari.self.addEventListener("popover", function()
8 { 14 {
9 document.documentElement.style.display = "none"; 15 if (activeTab != safari.application.activeBrowserWindow.activeTab || readySt ate != "complete")
10 document.location.reload(); 16 {
11 }, true); 17 document.documentElement.style.display = "none";
18 document.location.reload();
19 }
20 });
12 21
13 22
14 // Safari doesn't adjust the size of the popover automatically to the size 23 // Safari doesn't adjust the size of the popover automatically to the size
15 // of its content, like when the ad counter is expanded/collapsed. So we add 24 // of its content, like when the ad counter is expanded/collapsed. So we add
16 // event listeners to do so. 25 // event listeners to do so.
17 var updateSize = function() 26 var updateSize = function()
18 { 27 {
19 safari.self.width = document.body.offsetWidth; 28 safari.self.width = document.body.offsetWidth;
20 safari.self.height = document.body.offsetHeight; 29 safari.self.height = document.body.offsetHeight;
21 }; 30 };
(...skipping 17 matching lines...) Expand all
39 // listener to do so. 48 // listener to do so.
40 safari.application.addEventListener("activate", function() 49 safari.application.addEventListener("activate", function()
41 { 50 {
42 safari.self.hide(); 51 safari.self.hide();
43 }, true); 52 }, true);
44 53
45 54
46 // import ext into the javascript context of the popover. This code might fail , 55 // import ext into the javascript context of the popover. This code might fail ,
47 // when the background page isn't ready yet. So it is important to put it belo w 56 // when the background page isn't ready yet. So it is important to put it belo w
48 // the reloading code above. 57 // the reloading code above.
49 var backgroundPage = safari.extension.globalPage.contentWindow;
50 ext = backgroundPage.ext; 58 ext = backgroundPage.ext;
51 TabMap = backgroundPage.TabMap; 59 TabMap = backgroundPage.TabMap;
52 })(); 60 })();
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld