Left: | ||
Right: |
OLD | NEW |
---|---|
1 var backgroundPage = chrome.extension.getBackgroundPage(); | 1 var backgroundPage = chrome.extension.getBackgroundPage(); |
2 var require = backgroundPage.require; | 2 var require = backgroundPage.require; |
3 var Prefs = require("prefs").Prefs; | 3 var Prefs = require("prefs").Prefs; |
4 var Utils = require("utils").Utils; | 4 var Utils = require("utils").Utils; |
5 | 5 |
6 function openSharePopup(url) | 6 function openSharePopup(url) |
7 { | 7 { |
8 var iframe = document.getElementById("share-popup"); | 8 var iframe = document.getElementById("share-popup"); |
9 var glassPane = document.getElementById("glass-pane"); | 9 var glassPane = document.getElementById("glass-pane"); |
10 var popupMessageReceived = false; | |
11 var popupVisible = false; | |
10 | 12 |
11 var popupMessageListener = function(event) | 13 var popupMessageListener = function(event) |
12 { | 14 { |
13 if (event.origin !== url) | 15 if (event.origin !== url) |
14 return; | 16 return; |
15 | 17 |
16 iframe.width = event.data.width; | 18 iframe.width = event.data.width; |
17 iframe.height = event.data.height; | 19 iframe.height = event.data.height; |
20 popupMessageReceived = true; | |
18 window.removeEventListener("message", popupMessageListener); | 21 window.removeEventListener("message", popupMessageListener); |
19 }; | 22 }; |
20 window.addEventListener("message", popupMessageListener, false); | 23 window.addEventListener("message", popupMessageListener, false); |
21 | 24 |
22 var popupLoadListener = function() | 25 var popupLoadListener = function() |
23 { | 26 { |
24 iframe.className = "visible"; | 27 if (popupMessageReceived) |
28 { | |
29 iframe.className = "visible"; | |
30 popupVisible = true; | |
25 | 31 |
26 var popupCloseListener = function() | 32 var popupCloseListener = function() |
27 { | 33 { |
28 iframe.className = glassPane.className = ""; | 34 iframe.className = glassPane.className = ""; |
29 document.removeEventListener("click", popupCloseListener); | 35 document.removeEventListener("click", popupCloseListener); |
30 }; | 36 }; |
31 document.addEventListener("click", popupCloseListener, false); | 37 document.addEventListener("click", popupCloseListener, false); |
38 } | |
32 iframe.removeEventListener("load", popupLoadListener); | 39 iframe.removeEventListener("load", popupLoadListener); |
33 }; | 40 }; |
34 iframe.addEventListener("load", popupLoadListener, false); | 41 iframe.addEventListener("load", popupLoadListener, false); |
35 | 42 |
36 iframe.src = url; | 43 iframe.src = url; |
37 glassPane.className = "visible"; | 44 glassPane.className = "visible"; |
45 | |
46 setTimeout(function() | |
47 { | |
48 if (!popupVisible) | |
49 glassPane.className = ""; | |
50 }, 2000); | |
Wladimir Palant
2012/10/25 15:32:51
This timeout should be 20 seconds at least, otherw
Felix Dahlke
2012/10/25 15:39:27
You're right, the load event will even arrive even
| |
38 } | 51 } |
39 | 52 |
40 function initSocialLinks(variant) | 53 function initSocialLinks(variant) |
41 { | 54 { |
42 var networks = ["twitter", "facebook"]; | 55 var networks = ["twitter", "facebook"]; |
43 networks.forEach(function(network) | 56 networks.forEach(function(network) |
44 { | 57 { |
45 var links = document.getElementsByClassName("share-" + network); | 58 var links = document.getElementsByClassName("share-" + network); |
46 for (var i = 0; i < links.length; i++) | 59 for (var i = 0; i < links.length; i++) |
47 { | 60 { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
103 } | 116 } |
104 } | 117 } |
105 } | 118 } |
106 | 119 |
107 function getDocLink(page, anchor) | 120 function getDocLink(page, anchor) |
108 { | 121 { |
109 return Prefs.documentation_link | 122 return Prefs.documentation_link |
110 .replace(/%LINK%/g, page) | 123 .replace(/%LINK%/g, page) |
111 .replace(/%LANG%/g, Utils.appLocale) + (anchor ? "#" + anchor : "" ); | 124 .replace(/%LANG%/g, Utils.appLocale) + (anchor ? "#" + anchor : "" ); |
112 } | 125 } |
OLD | NEW |