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

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

Issue 5635941347622912: Resize popover on Safari only when the size of its content doesn't change anymore (Closed)
Patch Set: Created Feb. 26, 2014, 6:57 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 doesn't adjust the size of the popover automatically to the size 3 // Safari doesn't adjust the size of the popover automatically to the size
4 // of its content, like when the ad counter is expanded/collapsed. So we add 4 // of its content, like when the ad counter is expanded/collapsed. So we add
5 // event listeners to do so. 5 // event listeners to do so.
6 var mayResize = true; 6 var mayResize = true;
7 var resizingScheduled = false;
7 8
8 var updateSize = function() 9 var updateSize = function()
9 { 10 {
10 if (mayResize) 11 if (mayResize && !resizingScheduled)
11 { 12 {
12 safari.self.width = document.body.offsetWidth; 13 setTimeout(function()
13 safari.self.height = document.body.offsetHeight; 14 {
15 safari.self.width = document.body.offsetWidth;
16 safari.self.height = document.body.offsetHeight;
17
18 resizingScheduled = false;
19 }, 0);
20
21 resizingScheduled = true;
14 } 22 }
15 }; 23 };
16 24
17 window.addEventListener("load", function() 25 window.addEventListener("load", function()
18 { 26 {
19 updateSize(); 27 updateSize();
20 28
21 var MutationObserver = window.MutationObserver || window.WebKitMutationObser ver; 29 var MutationObserver = window.MutationObserver || window.WebKitMutationObser ver;
22 if (MutationObserver) 30 if (MutationObserver)
23 { 31 {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 67
60 window.ext = { 68 window.ext = {
61 __proto__: backgroundPage.ext, 69 __proto__: backgroundPage.ext,
62 closePopup: function() 70 closePopup: function()
63 { 71 {
64 safari.self.hide(); 72 safari.self.hide();
65 } 73 }
66 }; 74 };
67 window.TabMap = backgroundPage.TabMap; 75 window.TabMap = backgroundPage.TabMap;
68 })(); 76 })();
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