LEFT | RIGHT |
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 | 10 |
11 var popupMessageListener = function(event) | 11 var popupMessageListener = function(event) |
12 { | 12 { |
13 if (event.origin !== url) | 13 if (event.origin !== url) |
14 return; | 14 return; |
15 | 15 |
16 console.log(event); | 16 console.log(event); |
17 iframe.width = event.data.width; | 17 iframe.width = event.data.width; |
18 iframe.height = event.data.height; | 18 iframe.height = event.data.height; |
19 window.removeEventListener("message", popupMessageListener); | 19 window.removeEventListener("message", popupMessageListener); |
20 }; | 20 }; |
21 window.addEventListener("message", popupMessageListener, false); | 21 window.addEventListener("message", popupMessageListener, false); |
22 | 22 |
23 var popupLoadListener = function() | 23 var popupLoadListener = function() |
24 { | 24 { |
25 iframe.className = "visible"; | 25 iframe.className = "visible"; |
26 | 26 |
(...skipping 15 matching lines...) Expand all Loading... |
42 { | 42 { |
43 var networks = ["twitter", "facebook"]; | 43 var networks = ["twitter", "facebook"]; |
44 networks.forEach(function(network) | 44 networks.forEach(function(network) |
45 { | 45 { |
46 var links = document.getElementsByClassName("share-" + network); | 46 var links = document.getElementsByClassName("share-" + network); |
47 for (var i = 0; i < links.length; i++) | 47 for (var i = 0; i < links.length; i++) |
48 { | 48 { |
49 links[i].addEventListener("click", function(e) | 49 links[i].addEventListener("click", function(e) |
50 { | 50 { |
51 e.preventDefault(); | 51 e.preventDefault(); |
52 openSharePopup(getDocLink(network) + "&variant=" + variant); | 52 openSharePopup(getDocLink("share-" + network) + "&variant=" + variant); |
53 }, false); | 53 }, false); |
54 } | 54 } |
55 }); | 55 }); |
56 } | 56 } |
57 | 57 |
58 function init() | 58 function init() |
59 { | 59 { |
60 // Choose a share text variant randomly | 60 // Choose a share text variant randomly |
61 var variant = Math.floor(Math.random() * 2) + 1; | 61 var variant = Math.floor(Math.random() * 2) + 1; |
62 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 Loading... |
104 } | 104 } |
105 } | 105 } |
106 } | 106 } |
107 | 107 |
108 function getDocLink(page, anchor) | 108 function getDocLink(page, anchor) |
109 { | 109 { |
110 return Prefs.documentation_link | 110 return Prefs.documentation_link |
111 .replace(/%LINK%/g, page) | 111 .replace(/%LINK%/g, page) |
112 .replace(/%LANG%/g, Utils.appLocale) + (anchor ? "#" + anchor : ""
); | 112 .replace(/%LANG%/g, Utils.appLocale) + (anchor ? "#" + anchor : ""
); |
113 } | 113 } |
LEFT | RIGHT |