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: Rebased to 4a68f2a456d6 and set strict mode in common.js Created Sept. 23, 2015, 1:54 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 645 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 } 656 }
657 updateShareLink(); 657 updateShareLink();
658 }); 658 });
659 break; 659 break;
660 case "title": 660 case "title":
661 // TODO: NYI 661 // TODO: NYI
662 break; 662 break;
663 } 663 }
664 } 664 }
665 665
666 function onShareLinkClick(e)
667 {
668 e.preventDefault();
669
670 getDocLink("share-general", function(link)
671 {
672 openSharePopup(link);
673 });
674 }
675
666 function updateShareLink() 676 function updateShareLink()
667 { 677 {
668 ext.backgroundPage.sendMessage( 678 var shareResources = [
679 "https://facebook.com/plugins/like.php?",
680 "https://platform.twitter.com/widgets/",
681 "https://apis.google.com/se/0/_/+1/fastbutton?"
682 ];
683 var isAnyBlocked = false;
684 var checksRemaining = shareResources.length;
685
686 function onResult(isBlocked)
669 { 687 {
670 type: "filters.blocked", 688 isAnyBlocked |= isBlocked;
671 url: "https://platform.twitter.com/widgets/", 689 if (!--checksRemaining)
672 requestType: "SCRIPT", 690 {
673 docDomain: "adblockplus.org", 691 // Hide the share tab if a script on the share page would be blocked
674 thirdParty: true 692 var tab = E("tab-share");
675 }, 693 if (isAnyBlocked)
676 function(blocked) 694 {
677 { 695 tab.hidden = true;
678 // TODO: modify "share" link accordingly 696 tab.removeEventListener("click", onShareLinkClick, false);
679 }); 697 }
680 } 698 else
699 tab.addEventListener("click", onShareLinkClick, false);
700 }
701 }
681 702
682 function E(id) 703 for (var i = 0; i < shareResources.length; i++)
683 { 704 checkShareResource(shareResources[i], onResult);
684 return document.getElementById(id);
685 }
686
687 function getDocLink(link, callback)
688 {
689 ext.backgroundPage.sendMessage(
690 {
691 type: "app.get",
692 what: "doclink",
693 link: link
694 }, callback);
695 } 705 }
696 706
697 ext.onMessage.addListener(function(message) 707 ext.onMessage.addListener(function(message)
698 { 708 {
699 switch (message.type) 709 switch (message.type)
700 { 710 {
701 case "app.listen": 711 case "app.listen":
702 if (message.action == "addSubscription") 712 if (message.action == "addSubscription")
703 { 713 {
704 var subscription = message.args[0]; 714 var subscription = message.args[0];
(...skipping 27 matching lines...) Expand all
732 filter: ["added", "loaded", "removed"] 742 filter: ["added", "loaded", "removed"]
733 }); 743 });
734 ext.backgroundPage.sendMessage( 744 ext.backgroundPage.sendMessage(
735 { 745 {
736 type: "subscriptions.listen", 746 type: "subscriptions.listen",
737 filter: ["added", "disabled", "homepage", "removed", "title"] 747 filter: ["added", "disabled", "homepage", "removed", "title"]
738 }); 748 });
739 749
740 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); 750 window.addEventListener("DOMContentLoaded", onDOMLoaded, false);
741 })(); 751 })();
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