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

Delta Between Two Patch Sets: firstRun.js

Issue 8689042: adblockpluschrome: Handle invalid share popup sites (Closed)
Left Patch Set: Created Oct. 25, 2012, 3:15 p.m.
Right Patch Set: Created Oct. 25, 2012, 3:38 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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; 10 var popupMessageReceived = false;
11 var popupVisible = false;
12 11
13 var popupMessageListener = function(event) 12 var popupMessageListener = function(event)
14 { 13 {
15 if (event.origin !== url) 14 if (event.origin !== url)
16 return; 15 return;
17 16
18 iframe.width = event.data.width; 17 iframe.width = event.data.width;
19 iframe.height = event.data.height; 18 iframe.height = event.data.height;
20 popupMessageReceived = true; 19 popupMessageReceived = true;
21 window.removeEventListener("message", popupMessageListener); 20 window.removeEventListener("message", popupMessageListener);
22 }; 21 };
23 window.addEventListener("message", popupMessageListener, false); 22 window.addEventListener("message", popupMessageListener, false);
24 23
25 var popupLoadListener = function() 24 var popupLoadListener = function()
26 { 25 {
27 if (popupMessageReceived) 26 if (popupMessageReceived)
28 { 27 {
29 iframe.className = "visible"; 28 iframe.className = "visible";
30 popupVisible = true;
31 29
32 var popupCloseListener = function() 30 var popupCloseListener = function()
33 { 31 {
34 iframe.className = glassPane.className = ""; 32 iframe.className = glassPane.className = "";
35 document.removeEventListener("click", popupCloseListener); 33 document.removeEventListener("click", popupCloseListener);
36 }; 34 };
37 document.addEventListener("click", popupCloseListener, false); 35 document.addEventListener("click", popupCloseListener, false);
38 } 36 }
37 else
38 glassPane.className = "";
Wladimir Palant 2012/10/25 15:54:15 Also remove message listener here?
Felix Dahlke 2012/10/25 15:57:11 Done.
39
39 iframe.removeEventListener("load", popupLoadListener); 40 iframe.removeEventListener("load", popupLoadListener);
40 }; 41 };
41 iframe.addEventListener("load", popupLoadListener, false); 42 iframe.addEventListener("load", popupLoadListener, false);
42 43
43 iframe.src = url; 44 iframe.src = url;
44 glassPane.className = "visible"; 45 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
51 } 46 }
52 47
53 function initSocialLinks(variant) 48 function initSocialLinks(variant)
54 { 49 {
55 var networks = ["twitter", "facebook"]; 50 var networks = ["twitter", "facebook"];
56 networks.forEach(function(network) 51 networks.forEach(function(network)
57 { 52 {
58 var links = document.getElementsByClassName("share-" + network); 53 var links = document.getElementsByClassName("share-" + network);
59 for (var i = 0; i < links.length; i++) 54 for (var i = 0; i < links.length; i++)
60 { 55 {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 } 111 }
117 } 112 }
118 } 113 }
119 114
120 function getDocLink(page, anchor) 115 function getDocLink(page, anchor)
121 { 116 {
122 return Prefs.documentation_link 117 return Prefs.documentation_link
123 .replace(/%LINK%/g, page) 118 .replace(/%LINK%/g, page)
124 .replace(/%LANG%/g, Utils.appLocale) + (anchor ? "#" + anchor : "" ); 119 .replace(/%LANG%/g, Utils.appLocale) + (anchor ? "#" + anchor : "" );
125 } 120 }
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld