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

Unified Diff: firstRun.js

Issue 29321336: Issue 2381 - Added share overlay to options page (Closed)
Patch Set: Rebased to 4a68f2a456d6 and set strict mode in common.js Created Sept. 23, 2015, 1:54 p.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') | options.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: firstRun.js
===================================================================
--- a/firstRun.js
+++ b/firstRun.js
@@ -19,11 +19,6 @@
(function()
{
- function E(id)
- {
- return document.getElementById(id);
- }
-
// Load subscriptions for features
var featureSubscriptions = [
{
@@ -46,15 +41,6 @@
}
];
- function getDocLink(link, callback)
- {
- ext.backgroundPage.sendMessage({
- type: "app.get",
- what: "doclink",
- link: link
- }, callback);
- }
-
function onDOMLoaded()
{
// Set up logo image
@@ -150,106 +136,16 @@
}, false);
}
- function openSharePopup(url)
- {
- var iframe = E("share-popup");
- var glassPane = E("glass-pane");
- var popupMessageReceived = false;
-
- // Firefox 38+ no longer allows messaging using postMessage so we need
- // to have a fake top level frame to avoid problems with scripts that try to
- // communicate with the first-run page
- var isGecko = ("Components" in window);
- if (isGecko)
- {
- try
- {
- var Ci = Components.interfaces;
- iframe.contentWindow
- .QueryInterface(Ci.nsIInterfaceRequestor)
- .getInterface(Ci.nsIDocShell)
- .setIsBrowserInsideApp(Ci.nsIScriptSecurityManager.UNKNOWN_APP_ID);
- }
- catch(ex)
- {
- console.error(ex);
- }
- }
-
- function resizePopup(width, height)
- {
- iframe.width = width;
- iframe.height = height;
- iframe.style.marginTop = -height / 2 + "px";
- iframe.style.marginLeft = -width / 2 + "px";
- popupMessageReceived = true;
- window.removeEventListener("message", popupMessageListener);
- }
-
- var popupMessageListener = function(event)
- {
- if (!/[.\/]adblockplus\.org$/.test(event.origin))
- return;
-
- resizePopup(event.data.width, event.data.height);
- };
- // Firefox requires last parameter to be true to be triggered by
- // unprivileged pages
- window.addEventListener("message", popupMessageListener, false, true);
-
- var popupLoadListener = function()
- {
- if (!popupMessageReceived && isGecko)
- {
- var rootElement = iframe.contentDocument.documentElement;
- var width = rootElement.dataset.width;
- var height = rootElement.dataset.height;
- if (width && height)
- resizePopup(width, height);
- }
-
- if (popupMessageReceived)
- {
- iframe.className = "visible";
-
- var popupCloseListener = function()
- {
- iframe.className = glassPane.className = "";
- document.removeEventListener("click", popupCloseListener);
- };
- document.addEventListener("click", popupCloseListener, false);
- }
- else
- {
- glassPane.className = "";
- window.removeEventListener("message", popupMessageListener);
- }
-
- iframe.removeEventListener("load", popupLoadListener);
- };
- iframe.addEventListener("load", popupLoadListener, false);
-
- iframe.src = url;
- glassPane.className = "visible";
- }
-
function updateSocialLinks()
{
var networks = ["twitter", "facebook", "gplus"];
networks.forEach(function(network)
{
var link = E("share-" + network);
- var message = {
- type: "filters.blocked",
- url: link.getAttribute("data-script"),
- requestType: "SCRIPT",
- docDomain: "adblockplus.org",
- thirdParty: true
- };
- ext.backgroundPage.sendMessage(message, function(blocked)
+ checkShareResource(link.getAttribute("data-script"), function(isBlocked)
{
// Don't open the share page if the sharing script would be blocked
- if (blocked)
+ if (isBlocked)
link.removeEventListener("click", onSocialLinkClick, false);
else
link.addEventListener("click", onSocialLinkClick, false);
« no previous file with comments | « firstRun.html ('k') | options.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld