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

Delta Between Two Patch Sets: options.js

Issue 29323156: Issue 2410 - Improved accessibility of dialogs in options page (Closed)
Left Patch Set: Created July 31, 2015, 3:02 p.m.
Right Patch Set: Created Oct. 2, 2015, 2:11 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « options.html ('k') | skin/options.css » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 { 490 {
491 case "Escape": 491 case "Escape":
492 closeDialog(); 492 closeDialog();
493 break; 493 break;
494 case "Tab": 494 case "Tab":
495 if (e.shiftKey) 495 if (e.shiftKey)
496 { 496 {
497 if (e.target.classList.contains("focus-first")) 497 if (e.target.classList.contains("focus-first"))
498 { 498 {
499 e.preventDefault(); 499 e.preventDefault();
500 document.querySelector("#dialog .focus-last").focus(); 500 this.querySelector(".focus-last").focus();
501 } 501 }
502 } 502 }
503 else if (e.target.classList.contains("focus-last")) 503 else if (e.target.classList.contains("focus-last"))
504 { 504 {
505 e.preventDefault(); 505 e.preventDefault();
506 document.querySelector("#dialog .focus-first").focus(); 506 this.querySelector(".focus-first").focus();
507 } 507 }
508 break; 508 break;
509 } 509 }
510 }, false); 510 }, false);
511 } 511 }
512 512
513 var focusedBeforeDialog = null; 513 var focusedBeforeDialog = null;
514 function openDialog(name) 514 function openDialog(name)
515 { 515 {
516 var dialog = E("dialog"); 516 var dialog = E("dialog");
517 dialog.setAttribute("aria-hidden", false); 517 dialog.setAttribute("aria-hidden", false);
518 dialog.setAttribute("aria-labelledby", "dialog-title-" + name); 518 dialog.setAttribute("aria-labelledby", "dialog-title-" + name);
519 document.body.setAttribute("data-dialog", name); 519 document.body.setAttribute("data-dialog", name);
520 520
521 var defaultAction = document.querySelector("#dialog-content-" + name 521 var defaultFocus = document.querySelector("#dialog-content-" + name
522 + " .default-action"); 522 + " .default-focus");
523 if (!defaultAction) 523 if (!defaultFocus)
524 defaultAction = document.querySelector("#dialog .focus-first"); 524 defaultFocus = dialog.querySelector(".focus-first");
525 focusedBeforeDialog = document.activeElement; 525 focusedBeforeDialog = document.activeElement;
526 defaultAction.focus(); 526 defaultFocus.focus();
527 } 527 }
528 528
529 function closeDialog() 529 function closeDialog()
530 { 530 {
531 var dialog = E("dialog"); 531 var dialog = E("dialog");
532 dialog.setAttribute("aria-hidden", true); 532 dialog.setAttribute("aria-hidden", true);
533 dialog.removeAttribute("aria-labelledby"); 533 dialog.removeAttribute("aria-labelledby");
534 document.body.removeAttribute("data-dialog"); 534 document.body.removeAttribute("data-dialog");
535 focusedBeforeDialog.focus(); 535 focusedBeforeDialog.focus();
536 } 536 }
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 } 706 }
707 updateShareLink(); 707 updateShareLink();
708 }); 708 });
709 break; 709 break;
710 case "title": 710 case "title":
711 // TODO: NYI 711 // TODO: NYI
712 break; 712 break;
713 } 713 }
714 } 714 }
715 715
716 function onShareLinkClick(e)
717 {
718 e.preventDefault();
719
720 getDocLink("share-general", function(link)
721 {
722 openSharePopup(link);
723 });
724 }
725
716 function updateShareLink() 726 function updateShareLink()
717 { 727 {
718 ext.backgroundPage.sendMessage( 728 var shareResources = [
719 { 729 "https://facebook.com/plugins/like.php?",
720 type: "filters.blocked", 730 "https://platform.twitter.com/widgets/",
721 url: "https://platform.twitter.com/widgets/", 731 "https://apis.google.com/se/0/_/+1/fastbutton?"
722 requestType: "SCRIPT", 732 ];
723 docDomain: "adblockplus.org", 733 var isAnyBlocked = false;
724 thirdParty: true 734 var checksRemaining = shareResources.length;
725 }, 735
726 function(blocked) 736 function onResult(isBlocked)
727 { 737 {
728 // TODO: modify "share" link accordingly 738 isAnyBlocked |= isBlocked;
729 }); 739 if (!--checksRemaining)
730 } 740 {
731 741 // Hide the share tab if a script on the share page would be blocked
732 function E(id) 742 var tab = E("tab-share");
733 { 743 if (isAnyBlocked)
734 return document.getElementById(id); 744 {
735 } 745 tab.hidden = true;
736 746 tab.removeEventListener("click", onShareLinkClick, false);
737 function getDocLink(link, callback) 747 }
738 { 748 else
739 ext.backgroundPage.sendMessage( 749 tab.addEventListener("click", onShareLinkClick, false);
740 { 750 }
741 type: "app.get", 751 }
742 what: "doclink", 752
743 link: link 753 for (var i = 0; i < shareResources.length; i++)
744 }, callback); 754 checkShareResource(shareResources[i], onResult);
745 } 755 }
746 756
747 ext.onMessage.addListener(function(message) 757 ext.onMessage.addListener(function(message)
748 { 758 {
749 switch (message.type) 759 switch (message.type)
750 { 760 {
751 case "app.listen": 761 case "app.listen":
752 if (message.action == "addSubscription") 762 if (message.action == "addSubscription")
753 { 763 {
754 var subscription = message.args[0]; 764 var subscription = message.args[0];
(...skipping 27 matching lines...) Expand all
782 filter: ["added", "loaded", "removed"] 792 filter: ["added", "loaded", "removed"]
783 }); 793 });
784 ext.backgroundPage.sendMessage( 794 ext.backgroundPage.sendMessage(
785 { 795 {
786 type: "subscriptions.listen", 796 type: "subscriptions.listen",
787 filter: ["added", "disabled", "homepage", "removed", "title"] 797 filter: ["added", "disabled", "homepage", "removed", "title"]
788 }); 798 });
789 799
790 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); 800 window.addEventListener("DOMContentLoaded", onDOMLoaded, false);
791 })(); 801 })();
LEFTRIGHT

Powered by Google App Engine
This is Rietveld