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

Side by Side Diff: safari/ext/popup.js

Issue 5083364310646784: Got rid of strange animation when the bubble is resized while reloading on Safari (Closed)
Patch Set: Addressed comment Created Jan. 17, 2014, noon
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 // make the popover show the right state and details we have to reload it 5 // make the popover show the right state and details we have to reload it
6 // everytime it is shown for a different tab. Also we have to reload the 6 // everytime it is shown for a different tab. Also we have to reload the
7 // popover when the background page wasn't ready yet, since we have to access 7 // popover when the background page wasn't ready yet, since we have to access
8 // the background page in the popover. 8 // the background page in the popover.
9 var backgroundPage = safari.extension.globalPage.contentWindow; 9 var backgroundPage = safari.extension.globalPage.contentWindow;
10 var readyState = backgroundPage.document.readyState; 10 var readyState = backgroundPage.document.readyState;
11 var activeTab = safari.application.activeBrowserWindow.activeTab; 11 var activeTab = safari.application.activeBrowserWindow.activeTab;
12 var mayResize = true;
12 13
13 safari.self.addEventListener("popover", function() 14 safari.self.addEventListener("popover", function()
14 { 15 {
15 if (activeTab != safari.application.activeBrowserWindow.activeTab || readySt ate != "complete") 16 if (activeTab != safari.application.activeBrowserWindow.activeTab || readySt ate != "complete")
16 { 17 {
18 mayResize = false;
17 document.documentElement.style.display = "none"; 19 document.documentElement.style.display = "none";
18 document.location.reload(); 20 document.location.reload();
19 } 21 }
20 }); 22 });
21 23
22 24
23 // Safari doesn't adjust the size of the popover automatically to the size 25 // Safari doesn't adjust the size of the popover automatically to the size
24 // of its content, like when the ad counter is expanded/collapsed. So we add 26 // of its content, like when the ad counter is expanded/collapsed. So we add
25 // event listeners to do so. 27 // event listeners to do so.
26 var updateSize = function() 28 var updateSize = function()
27 { 29 {
28 safari.self.width = document.body.offsetWidth; 30 if (mayResize)
29 safari.self.height = document.body.offsetHeight; 31 {
32 safari.self.width = document.body.offsetWidth;
33 safari.self.height = document.body.offsetHeight;
34 ]
30 }; 35 };
31 36
32 window.addEventListener("load", function() 37 window.addEventListener("load", function()
33 { 38 {
34 updateSize(); 39 updateSize();
35 40
36 var MutationObserver = window.MutationObserver || window.WebKitMutationObser ver; 41 var MutationObserver = window.MutationObserver || window.WebKitMutationObser ver;
37 if (MutationObserver) 42 if (MutationObserver)
38 { 43 {
39 new MutationObserver(updateSize).observe(document, { 44 new MutationObserver(updateSize).observe(document, {
(...skipping 20 matching lines...) Expand all
60 // the reloading code above. 65 // the reloading code above.
61 window.ext = { 66 window.ext = {
62 __proto__: backgroundPage.ext, 67 __proto__: backgroundPage.ext,
63 closePopup: function() 68 closePopup: function()
64 { 69 {
65 safari.self.hide(); 70 safari.self.hide();
66 } 71 }
67 }; 72 };
68 window.TabMap = backgroundPage.TabMap; 73 window.TabMap = backgroundPage.TabMap;
69 })(); 74 })();
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