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

Delta Between Two Patch Sets: firstRun.js

Issue 8615139: adblockpluschrome: Open share page in lightbox (Closed)
Left Patch Set: Created Oct. 25, 2012, 11:49 a.m.
Right Patch Set: Created Oct. 25, 2012, 1:29 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 | « firstRun.html ('k') | skin/firstRun.css » ('j') | 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
11 var popupMessageListener = function(event)
12 {
13 if (event.origin !== url)
14 return;
15
16 console.log(event);
Wladimir Palant 2012/10/25 13:31:04 Debug code?
17 iframe.width = event.data.width;
18 iframe.height = event.data.height;
19 window.removeEventListener("message", popupMessageListener);
20 };
21 window.addEventListener("message", popupMessageListener, false);
10 22
11 var popupLoadListener = function() 23 var popupLoadListener = function()
12 { 24 {
13 iframe.className = "visible"; 25 iframe.className = "visible";
14 26
15 var popupCloseListener = function() 27 var popupCloseListener = function()
16 { 28 {
17 iframe.className = glassPane.className = ""; 29 iframe.className = glassPane.className = "";
18 document.removeEventListener("click", popupCloseListener); 30 document.removeEventListener("click", popupCloseListener);
19 }; 31 };
20 document.addEventListener("click", popupCloseListener, false); 32 document.addEventListener("click", popupCloseListener, false);
21 iframe.removeEventListener("load", popupLoadListener); 33 iframe.removeEventListener("load", popupLoadListener);
22 }; 34 };
35 iframe.addEventListener("load", popupLoadListener, false);
23 36
24 iframe.addEventListener("load", popupLoadListener, false);
25 iframe.src = url; 37 iframe.src = url;
26 glassPane.className = "visible"; 38 glassPane.className = "visible";
27 } 39 }
28 40
29 function initSocialLinks(variant) 41 function initSocialLinks(variant)
30 { 42 {
31 var networks = ["twitter", "facebook"]; 43 var networks = ["twitter", "facebook"];
32 networks.forEach(function(network) 44 networks.forEach(function(network)
33 { 45 {
34 var links = document.getElementsByClassName("share-" + network); 46 var links = document.getElementsByClassName("share-" + network);
35 for (var i = 0; i < links.length; i++) 47 for (var i = 0; i < links.length; i++)
36 { 48 {
37 links[i].addEventListener("click", function(e) 49 links[i].addEventListener("click", function(e)
38 { 50 {
39 e.preventDefault(); 51 e.preventDefault();
40 openSharePopup(getDocLink(network) + "&variant=" + variant); 52 openSharePopup(getDocLink("share-" + network) + "&variant=" + variant);
41 }, false); 53 }, false);
42 } 54 }
43 }); 55 });
44 } 56 }
45 57
46 function init() 58 function init()
47 { 59 {
48 // Choose a share text variant randomly 60 // Choose a share text variant randomly
49 var variant = Math.floor(Math.random() * 2) + 1; 61 var variant = Math.floor(Math.random() * 2) + 1;
50 document.documentElement.setAttribute("share-variant", variant); 62 document.documentElement.setAttribute("share-variant", variant);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 } 104 }
93 } 105 }
94 } 106 }
95 107
96 function getDocLink(page, anchor) 108 function getDocLink(page, anchor)
97 { 109 {
98 return Prefs.documentation_link 110 return Prefs.documentation_link
99 .replace(/%LINK%/g, page) 111 .replace(/%LINK%/g, page)
100 .replace(/%LANG%/g, Utils.appLocale) + (anchor ? "#" + anchor : "" ); 112 .replace(/%LANG%/g, Utils.appLocale) + (anchor ? "#" + anchor : "" );
101 } 113 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld