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 a40c644fc2aa Created July 29, 2015, 12:27 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
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()
saroyanm 2015/09/08 17:33:49 Shouldn't this implementation also be shared betwe
Thomas Greiner 2015/09/23 14:03:05 No, the difference is that on the first-run page w
{
- 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)

Powered by Google App Engine
This is Rietveld