LEFT | RIGHT |
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 // the reloading code above. | 65 // the reloading code above. |
58 window.ext = { | 66 window.ext = { |
59 __proto__: safari.extension.globalPage.contentWindow.ext, | 67 __proto__: safari.extension.globalPage.contentWindow.ext, |
60 | 68 |
61 closePopup: function() | 69 closePopup: function() |
62 { | 70 { |
63 safari.self.hide(); | 71 safari.self.hide(); |
64 } | 72 } |
65 }; | 73 }; |
66 })(); | 74 })(); |
LEFT | RIGHT |