Left: | ||
Right: |
OLD | NEW |
---|---|
1 with (safari.extension.globalPage.contentWindow) | 1 with (safari.extension.globalPage.contentWindow) |
2 { | 2 { |
3 this.ext = ext; | 3 this.ext = ext; |
4 this.TabMap = TabMap; | 4 this.TabMap = TabMap; |
5 } | 5 } |
6 | 6 |
7 // Safari will load the popover once, and then show it everytime the icon is | 7 // Safari will load the popover once, and then show it everytime the icon is |
8 // clicked. While Chrome loads it everytime you click the icon. So in order to | 8 // clicked. While Chrome loads it everytime you click the icon. So in order to |
9 // force the same behavior in Safari, we are going to reload the page of the | 9 // force the same behavior in Safari, we are going to reload the page of the |
10 // bubble everytime it is shown. | 10 // bubble everytime it is shown. |
11 safari.application.addEventListener("popover", function() | 11 safari.application.addEventListener("popover", function() |
12 { | 12 { |
13 document.documentElement.style.display = "none"; | 13 document.documentElement.style.display = "none"; |
14 document.location.reload(); | 14 document.location.reload(); |
15 }, true); | 15 }, true); |
16 | 16 |
17 // Safari doesn't hide popovers automatically, when we change the active tab | 17 // Safari doesn't hide popovers automatically, when we change the active tab |
18 // programmatically, like when the options link is clicked. So we add an event | 18 // programmatically, like when the options link is clicked. So we add an event |
19 // listener to do so. | 19 // listener to do so. |
20 safari.application.addEventListener("activate", function() | 20 safari.application.addEventListener("activate", function() |
21 { | 21 { |
22 safari.self.hide(); | 22 safari.self.hide(); |
23 }, true); | 23 }, true); |
24 | |
25 // Safari doesn't adjust the size of the popover automatically to the size of | |
26 // its content, like when the ad counter is expanded/collapsed. So we add an | |
27 // event listener to do so. | |
28 document.addEventListener("DOMSubtreeModified", function() | |
29 { | |
30 safari.self.width = document.body.offsetWidth; | |
31 safari.self.height = document.body.offsetHeight; | |
Wladimir Palant
2014/01/15 15:47:13
What about document.documentElement.offsetWidth/He
Sebastian Noack
2014/01/15 17:21:52
No, it doesn't has the right value (sometimes?). D
| |
32 }); | |
OLD | NEW |