Index: firstRun.js |
=================================================================== |
--- a/firstRun.js |
+++ b/firstRun.js |
@@ -3,6 +3,31 @@ |
var Prefs = require("prefs").Prefs; |
var Utils = require("utils").Utils; |
+function openSharePopup(network) |
+{ |
+ $.fancybox.open([{ |
+ href: getDocLink(network), |
Wladimir Palant
2012/10/24 09:02:26
We need to pass the variant parameter as well, oth
Felix Dahlke
2012/10/24 14:55:01
Done.
|
+ type: "iframe", |
+ width: 546, |
+ height: 546, |
+ padding: 0, |
+ iframe: { |
+ scrolling: "no" |
+ } |
+ }]); |
+} |
+ |
+function initSocialLinks() |
+{ |
+ var networks = ["twitter", "facebook"]; |
+ networks.forEach(function(network) |
+ { |
+ var links = document.getElementsByClassName("share-" + network); |
+ for (var i = 0; i < links.length; i++) |
+ links[i].onclick = openSharePopup.bind(undefined, network); |
Wladimir Palant
2012/10/24 09:02:26
Did I mention already that I don't like onfoo? ;)
Felix Dahlke
2012/10/24 14:55:01
You're right, my bad.
|
+ }); |
+} |
+ |
function init() |
{ |
// Choose a share text variant randomly |
@@ -24,13 +49,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(); |
var donateLink = document.getElementById("share-donate"); |
donateLink.href = getDocLink("donate") + "&variant=" + variant; |