| OLD | NEW |
| 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 var resizingScheduled = false; |
| 8 | 8 |
| 9 var updateSize = function() | 9 var updateSize = function() |
| 10 { | 10 { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 // listener to do so. | 66 // listener to do so. |
| 67 safari.application.addEventListener("activate", function() | 67 safari.application.addEventListener("activate", function() |
| 68 { | 68 { |
| 69 safari.self.hide(); | 69 safari.self.hide(); |
| 70 }, true); | 70 }, true); |
| 71 | 71 |
| 72 | 72 |
| 73 // import ext into the javascript context of the popover. This code might fail
, | 73 // import ext into the javascript context of the popover. This code might fail
, |
| 74 // when the background page isn't ready yet. So it is important to put it belo
w | 74 // when the background page isn't ready yet. So it is important to put it belo
w |
| 75 // the reloading code above. | 75 // the reloading code above. |
| 76 window.ext = Object.create(safari.extension.globalPage.contentWindow.ext); | 76 var backgroundPage = safari.extension.globalPage.contentWindow; |
| 77 window.ext = Object.create(backgroundPage.ext); |
| 77 | 78 |
| 78 ext.closePopup = function() | 79 ext.closePopup = function() |
| 79 { | 80 { |
| 80 safari.self.hide(); | 81 safari.self.hide(); |
| 81 }; | 82 }; |
| 83 |
| 84 ext.backgroundPage = { |
| 85 getWindow: function() |
| 86 { |
| 87 return backgroundPage; |
| 88 }, |
| 89 |
| 90 // On Safari, you can't send messages from the popup to the |
| 91 // background page. So we call the message listeners directly. |
| 92 sendMessage: function(message, responseCallback) |
| 93 { |
| 94 if (!responseCallback) |
| 95 responseCallback = function () {}; |
| 96 |
| 97 backgroundPage.ext.onMessage._dispatch(message, {}, responseCallback); |
| 98 } |
| 99 }; |
| 100 |
| 82 })(); | 101 })(); |
| OLD | NEW |