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

Unified Diff: firstRun.js

Issue 8615139: adblockpluschrome: Open share page in lightbox (Closed)
Patch Set: Created Oct. 25, 2012, 9:57 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « firstRun.html ('k') | skin/firstRun.css » ('j') | skin/firstRun.css » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: firstRun.js
===================================================================
--- a/firstRun.js
+++ b/firstRun.js
@@ -3,6 +3,45 @@
var Prefs = require("prefs").Prefs;
var Utils = require("utils").Utils;
+function openSharePopup(url)
+{
+ var iframe = document.getElementById("share-popup");
+ var glassPane = document.getElementById("glass-pane");
+
+ var popupLoadListener = function()
+ {
+ iframe.className = "visible";
+
+ var popupCloseListener = function()
+ {
+ iframe.className = glassPane.className = "";
+ document.removeEventListener("click", popupCloseListener);
+ }
Wladimir Palant 2012/10/25 10:45:03 Missing semicolon?
Felix Dahlke 2012/10/25 12:00:51 Yes, ouch.
+ document.addEventListener("click", popupCloseListener, false);
+ iframe.removeEventListener("load", popupLoadListener);
+ };
+
+ iframe.addEventListener("load", popupLoadListener, false);
+ iframe.src = url;
+ glassPane.className = "visible";
Wladimir Palant 2012/10/25 10:45:03 Does it still work if you close the popup and then
Felix Dahlke 2012/10/25 12:00:51 Sure.
+}
+
+function initSocialLinks(variant)
+{
+ var networks = ["twitter", "facebook"];
+ networks.forEach(function(network)
+ {
+ var links = document.getElementsByClassName("share-" + network);
+ for (var i = 0; i < links.length; i++)
Wladimir Palant 2012/10/25 10:45:03 I consider it acceptable to omit brackets if the f
Felix Dahlke 2012/10/25 12:00:51 OK, seems appropriate.
+ links[i].addEventListener("click", function(e)
+ {
+ e.preventDefault();
+// openSharePopup(getDocLink(network) + "&variant=" + variant);
+ openSharePopup("http://localhost:8000");
Wladimir Palant 2012/10/25 10:45:03 Debug code apparently.
Felix Dahlke 2012/10/25 12:00:51 Double ouch.
+ }, false);
+ });
+}
+
function init()
{
// Choose a share text variant randomly
@@ -24,13 +63,7 @@
setLinks("acceptableAdsExplanation", getDocLink("acceptable_ads", "criteria"),
backgroundPage.openOptions);
- var facebookLinks = document.getElementsByClassName("share-facebook");
- for (var i = 0; i < facebookLinks.length; i++)
- facebookLinks[i].href = getDocLink("facebook") + "&variant=" + variant;
-
- var twitterLinks = document.getElementsByClassName("share-twitter");
- for (var i = 0; i < twitterLinks.length; i++)
- twitterLinks[i].href = getDocLink("twitter") + "&variant=" + variant;
+ initSocialLinks(variant);
var donateLink = document.getElementById("share-donate");
donateLink.href = getDocLink("donate") + "&variant=" + variant;
« no previous file with comments | « firstRun.html ('k') | skin/firstRun.css » ('j') | skin/firstRun.css » ('J')

Powered by Google App Engine
This is Rietveld