Left: | ||
Right: |
OLD | NEW |
---|---|
1 /* | 1 /* |
2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
3 * Copyright (C) 2006-2014 Eyeo GmbH | 3 * Copyright (C) 2006-2014 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
67 } | 67 } |
68 | 68 |
69 iframe.removeEventListener("load", popupLoadListener); | 69 iframe.removeEventListener("load", popupLoadListener); |
70 }; | 70 }; |
71 iframe.addEventListener("load", popupLoadListener); | 71 iframe.addEventListener("load", popupLoadListener); |
72 | 72 |
73 iframe.src = url; | 73 iframe.src = url; |
74 glassPane.className = "visible"; | 74 glassPane.className = "visible"; |
75 } | 75 } |
76 | 76 |
77 function initSocialLinks(variant) | 77 function initSocialLinks() |
78 { | 78 { |
79 // Share popup doesn't work in <IE9 so don't show it | 79 // Share popup doesn't work in <IE9 so don't show it |
80 if (/MSIE [6-8]/.test(navigator.appVersion)) | 80 if (/MSIE [6-8]/.test(navigator.appVersion)) |
81 return; | 81 return; |
82 | 82 |
83 var networks = ["twitter", "facebook", "gplus"]; | 83 var networks = ["twitter", "facebook", "gplus"]; |
84 networks.forEach(function(network) | 84 networks.forEach(function(network) |
85 { | 85 { |
86 var link = document.getElementById("share-" + network + "-" + variant); | 86 var link = document.getElementById("share-" + network); |
87 link.addEventListener("click", function(e) | 87 link.addEventListener("click", function(e) |
88 { | 88 { |
89 e.preventDefault(); | 89 e.preventDefault(); |
90 openSharePopup(getDocLink("share-" + network) + "&variant=" + variant); | 90 openSharePopup(getDocLink("share-" + network)); |
91 }); | 91 }); |
92 }); | 92 }); |
93 } | 93 } |
94 | 94 |
95 function getDocLink(page) | 95 function getDocLink(page) |
96 { | 96 { |
97 return Prefs.documentation_link | 97 return Prefs.documentation_link |
98 .replace(/%LINK%/g, page) | 98 .replace(/%LINK%/g, page) |
99 .replace(/%LANG%/g, Utils.appLocale); | 99 .replace(/%LANG%/g, Utils.appLocale); |
100 } | 100 } |
101 | 101 |
102 function initTranslations() | 102 function initTranslations() |
103 { | 103 { |
104 // Map message ID to HTML element ID | 104 // Map message ID to HTML element ID |
105 var mapping = { | 105 var mapping = { |
106 "aa-title": "first-run-aa-title", | 106 "aa-title": "first-run-aa-title", |
107 "aa-text": "first-run-aa-text", | 107 "aa-text": "first-run-aa-text", |
108 "title-main": AdblockPlus.isUpdate() ? "first-run-title-update" : "first-run -title-install", | 108 "title-main": AdblockPlus.isUpdate() ? "first-run-title-update" : "first-run -title-install", |
109 "share-text1": "first-run-share1", | |
110 "share-text2": "first-run-share2", | |
111 "share-donate": "first-run-share2-donate", | 109 "share-donate": "first-run-share2-donate", |
112 "share2-connection": "first-run-share2-or" | 110 "share-text": "first-run-share2", |
111 "share-connection": "first-run-share2-or", | |
Thomas Greiner
2014/11/03 17:14:12
Did you check whether IE8 can deal with trailing c
Oleksandr
2014/11/04 11:18:24
It worked fine in IE8. Removed it anyway.
Thomas Greiner
2014/11/04 11:27:46
Great, thanks.
| |
113 }; | 112 }; |
114 | 113 |
115 document.title = AdblockPlus.getMessage("first-run", mapping['title-main']); | 114 document.title = AdblockPlus.getMessage("first-run", mapping['title-main']); |
116 for (var i in mapping) | 115 for (var i in mapping) |
117 { | 116 { |
118 var element = document.getElementById(i); | 117 var element = document.getElementById(i); |
119 setElementText(element, AdblockPlus.getMessage("first-run", mapping[i])); | 118 setElementText(element, AdblockPlus.getMessage("first-run", mapping[i])); |
120 } | 119 } |
121 } | 120 } |
122 | 121 |
123 function init() | 122 function init() |
124 { | 123 { |
125 // Choose a share text variant randomly | |
126 var variant = Math.floor(Math.random() * 2) + 1; | |
127 var classList = document.documentElement.className.split(" "); | |
128 classList.push("share-variant-" + variant); | |
129 document.documentElement.className = classList.join(" "); | |
130 | |
131 initTranslations(); | 124 initTranslations(); |
132 initSocialLinks(variant); | 125 initSocialLinks(); |
133 setLinks("aa-text", getDocLink("acceptable_ads_criteria"), "index.html"); | 126 setLinks("aa-text", getDocLink("acceptable_ads_criteria"), "index.html"); |
134 | 127 |
135 var donateLink = document.getElementById("share-donate"); | 128 var donateLink = document.getElementById("share-donate"); |
136 donateLink.href = getDocLink("donate") + "&variant=" + variant; | 129 donateLink.href = getDocLink("donate"); |
137 } | 130 } |
138 | 131 |
139 // Inserts i18n strings into matching elements. Any inner HTML already in the | 132 // Inserts i18n strings into matching elements. Any inner HTML already in the |
140 // element is parsed as JSON and used as parameters to substitute into | 133 // element is parsed as JSON and used as parameters to substitute into |
141 // placeholders in the i18n message. | 134 // placeholders in the i18n message. |
142 setElementText = function(element, elementHtml) | 135 setElementText = function(element, elementHtml) |
143 { | 136 { |
144 function processString(str, element) | 137 function processString(str, element) |
145 { | 138 { |
146 var match = /^(.*?)<(a|strong)>(.*?)<\/\2>(.*)$/.exec(str); | 139 var match = /^(.*?)<(a|strong)>(.*?)<\/\2>(.*)$/.exec(str); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
182 links[i].href = curArg; | 175 links[i].href = curArg; |
183 links[i].setAttribute("target", "_blank"); | 176 links[i].setAttribute("target", "_blank"); |
184 } | 177 } |
185 else if (typeof curArg == "function") | 178 else if (typeof curArg == "function") |
186 { | 179 { |
187 links[i].href = "javascript:void(0);"; | 180 links[i].href = "javascript:void(0);"; |
188 links[i].addEventListener("click", curArg, false); | 181 links[i].addEventListener("click", curArg, false); |
189 } | 182 } |
190 } | 183 } |
191 } | 184 } |
OLD | NEW |