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(network) | |
7 { | |
8 $.fancybox.open([{ | |
9 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.
| |
10 type: "iframe", | |
11 width: 546, | |
12 height: 546, | |
13 padding: 0, | |
14 iframe: { | |
15 scrolling: "no" | |
16 } | |
17 }]); | |
18 } | |
19 | |
20 function initSocialLinks() | |
21 { | |
22 var networks = ["twitter", "facebook"]; | |
23 networks.forEach(function(network) | |
24 { | |
25 var links = document.getElementsByClassName("share-" + network); | |
26 for (var i = 0; i < links.length; i++) | |
27 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.
| |
28 }); | |
29 } | |
30 | |
6 function init() | 31 function init() |
7 { | 32 { |
8 // Choose a share text variant randomly | 33 // Choose a share text variant randomly |
9 var variant = Math.floor(Math.random() * 2) + 1; | 34 var variant = Math.floor(Math.random() * 2) + 1; |
10 document.documentElement.setAttribute("share-variant", variant); | 35 document.documentElement.setAttribute("share-variant", variant); |
11 | 36 |
12 // Set up page title | 37 // Set up page title |
13 var titleId = (backgroundPage.isFirstRun ? "firstRun_title_install" : "firstRu n_title_update"); | 38 var titleId = (backgroundPage.isFirstRun ? "firstRun_title_install" : "firstRu n_title_update"); |
14 var pageTitle = i18n.getMessage(titleId); | 39 var pageTitle = i18n.getMessage(titleId); |
15 document.title = document.getElementById("title-main").textContent = pageTitle ; | 40 document.title = document.getElementById("title-main").textContent = pageTitle ; |
16 | 41 |
17 // Only show changelog link on the update page | 42 // Only show changelog link on the update page |
18 if (backgroundPage.isFirstRun) | 43 if (backgroundPage.isFirstRun) |
19 document.getElementById("title-changelog").style.display = "none"; | 44 document.getElementById("title-changelog").style.display = "none"; |
20 | 45 |
21 // Set up URLs | 46 // Set up URLs |
22 var versionId = chrome.app.getDetails().version.split(".").slice(0, 2).join("" ); | 47 var versionId = chrome.app.getDetails().version.split(".").slice(0, 2).join("" ); |
23 setLinks("title-changelog", "https://adblockplus.org/releases/adblock-plus-" + versionId + "-for-google-chrome-released"); | 48 setLinks("title-changelog", "https://adblockplus.org/releases/adblock-plus-" + versionId + "-for-google-chrome-released"); |
24 setLinks("acceptableAdsExplanation", getDocLink("acceptable_ads", "criteria"), | 49 setLinks("acceptableAdsExplanation", getDocLink("acceptable_ads", "criteria"), |
25 backgroundPage.openOptions); | 50 backgroundPage.openOptions); |
26 | 51 |
27 var facebookLinks = document.getElementsByClassName("share-facebook"); | 52 initSocialLinks(); |
28 for (var i = 0; i < facebookLinks.length; i++) | |
29 facebookLinks[i].href = getDocLink("facebook") + "&variant=" + variant; | |
30 | |
31 var twitterLinks = document.getElementsByClassName("share-twitter"); | |
32 for (var i = 0; i < twitterLinks.length; i++) | |
33 twitterLinks[i].href = getDocLink("twitter") + "&variant=" + variant; | |
34 | 53 |
35 var donateLink = document.getElementById("share-donate"); | 54 var donateLink = document.getElementById("share-donate"); |
36 donateLink.href = getDocLink("donate") + "&variant=" + variant; | 55 donateLink.href = getDocLink("donate") + "&variant=" + variant; |
37 } | 56 } |
38 window.addEventListener("load", init, false); | 57 window.addEventListener("load", init, false); |
39 | 58 |
40 function setLinks(id) | 59 function setLinks(id) |
41 { | 60 { |
42 var element = document.getElementById(id); | 61 var element = document.getElementById(id); |
43 if (!element) | 62 if (!element) |
(...skipping 14 matching lines...) Expand all Loading... | |
58 } | 77 } |
59 } | 78 } |
60 } | 79 } |
61 | 80 |
62 function getDocLink(page, anchor) | 81 function getDocLink(page, anchor) |
63 { | 82 { |
64 return Prefs.documentation_link | 83 return Prefs.documentation_link |
65 .replace(/%LINK%/g, page) | 84 .replace(/%LINK%/g, page) |
66 .replace(/%LANG%/g, Utils.appLocale) + (anchor ? "#" + anchor : "" ); | 85 .replace(/%LANG%/g, Utils.appLocale) + (anchor ? "#" + anchor : "" ); |
67 } | 86 } |
OLD | NEW |