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

Unified Diff: options.js

Issue 29321336: Issue 2381 - Added share overlay to options page (Closed)
Patch Set: Rebased to 312559088567 Created July 16, 2015, 1:41 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 | « options.html ('k') | skin/common.css » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: options.js
===================================================================
--- a/options.js
+++ b/options.js
@@ -663,35 +663,45 @@
}
}
- function updateShareLink()
+ function onShareLinkClick(e)
{
- ext.backgroundPage.sendMessage(
+ e.preventDefault();
+
+ getDocLink("share-general", function(link)
{
- type: "filters.blocked",
- url: "https://platform.twitter.com/widgets/",
- requestType: "SCRIPT",
- docDomain: "adblockplus.org",
- thirdParty: true
- },
- function(blocked)
- {
- // TODO: modify "share" link accordingly
+ openSharePopup(link);
});
}
- function E(id)
+ function updateShareLink()
{
- return document.getElementById(id);
- }
+ var shareResources = [
+ "https://facebook.com/plugins/like.php?",
+ "https://platform.twitter.com/widgets/",
+ "https://apis.google.com/se/0/_/+1/fastbutton?"
+ ];
+ var isAnyBlocked = false;
+ var checksRemaining = shareResources.length;
- function getDocLink(link, callback)
- {
- ext.backgroundPage.sendMessage(
+ function onResult(isBlocked)
{
- type: "app.get",
- what: "doclink",
- link: link
- }, callback);
+ isAnyBlocked |= isBlocked;
+ if (!--checksRemaining)
+ {
+ // Hide the share tab if a script on the share page would be blocked
+ var tab = E("tab-share");
+ if (isAnyBlocked)
+ {
+ tab.hidden = true;
+ tab.removeEventListener("click", onShareLinkClick, false);
+ }
+ else
+ tab.addEventListener("click", onShareLinkClick, false);
+ }
+ }
+
+ for (var i = 0; i < shareResources.length; i++)
+ checkShareResource(shareResources[i], onResult);
}
ext.onMessage.addListener(function(message)
« no previous file with comments | « options.html ('k') | skin/common.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld