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

Side by Side Diff: options.js

Issue 29321336: Issue 2381 - Added share overlay to options page (Closed)
Patch Set: Created July 2, 2015, 3:25 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « options.html ('k') | skin/common.css » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 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 592 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 break; 603 break;
604 } 604 }
605 } 605 }
606 606
607 function showAddSubscriptionDialog(subscription) 607 function showAddSubscriptionDialog(subscription)
608 { 608 {
609 E("blockingList-textbox").value = subscription.url; 609 E("blockingList-textbox").value = subscription.url;
610 openDialog("customlist"); 610 openDialog("customlist");
611 } 611 }
612 612
613 function onShareLinkClick(e)
614 {
615 e.preventDefault();
616
617 getDocLink("share-general", function(link)
618 {
619 openSharePopup(link);
620 });
621 }
622
613 function updateShareLink() 623 function updateShareLink()
614 { 624 {
615 ext.backgroundPage.sendMessage( 625 var shareResources = [
626 "https://facebook.com/plugins/like.php?",
627 "https://platform.twitter.com/widgets/",
628 "https://apis.google.com/se/0/_/+1/fastbutton?"
629 ];
630 var isAnyBlocked = false;
631 var checksRemaining = shareResources.length;
632
633 function onResult(isBlocked)
616 { 634 {
617 type: "filters.blocked", 635 isAnyBlocked |= isBlocked;
618 url: "https://platform.twitter.com/widgets/", 636 if (!--checksRemaining)
619 requestType: "SCRIPT", 637 {
620 docDomain: "adblockplus.org", 638 // Hide the share tab if a script on the share page would be blocked
621 thirdParty: true 639 var tab = E("tab-share");
622 }, 640 if (isAnyBlocked)
623 function(blocked) 641 {
624 { 642 tab.hidden = true;
625 // TODO: modify "share" link accordingly 643 tab.removeEventListener("click", onShareLinkClick, false);
626 }); 644 }
627 } 645 else
646 tab.addEventListener("click", onShareLinkClick, false);
647 }
648 }
628 649
629 function E(id) 650 for (var i = 0; i < shareResources.length; i++)
630 { 651 checkShareResource(shareResources[i], onResult);
631 return document.getElementById(id);
632 }
633
634 function getDocLink(link, callback)
635 {
636 ext.backgroundPage.sendMessage(
637 {
638 type: "app.get",
639 what: "doclink",
640 link: link
641 }, callback);
642 } 652 }
643 653
644 ext.onMessage.addListener(function(message) 654 ext.onMessage.addListener(function(message)
645 { 655 {
646 switch (message.type) 656 switch (message.type)
647 { 657 {
648 case "app.listen": 658 case "app.listen":
649 if (message.action == "addSubscription") 659 if (message.action == "addSubscription")
650 showAddSubscriptionDialog(message.args[0]); 660 showAddSubscriptionDialog(message.args[0]);
651 break; 661 break;
(...skipping 17 matching lines...) Expand all
669 filter: ["added", "loaded", "removed"] 679 filter: ["added", "loaded", "removed"]
670 }); 680 });
671 ext.backgroundPage.sendMessage( 681 ext.backgroundPage.sendMessage(
672 { 682 {
673 type: "subscriptions.listen", 683 type: "subscriptions.listen",
674 filter: ["added", "disabled", "homepage", "removed", "title"] 684 filter: ["added", "disabled", "homepage", "removed", "title"]
675 }); 685 });
676 686
677 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); 687 window.addEventListener("DOMContentLoaded", onDOMLoaded, false);
678 })(); 688 })();
OLDNEW
« 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