Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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 Loading... | |
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(); |
saroyanm
2015/10/01 16:31:40
you already has the dialog element, I think you ca
Thomas Greiner
2015/10/02 10:27:28
Done.
| |
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 |
saroyanm
2015/10/01 16:31:40
what about naming this defaultFocus or initialFocu
Thomas Greiner
2015/10/02 10:27:29
Done.
| |
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"); |
saroyanm
2015/10/01 16:31:40
I think here you also can use dialog element "dial
Thomas Greiner
2015/10/02 10:27:29
Done.
| |
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 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
792 filter: ["added", "loaded", "removed"] | 792 filter: ["added", "loaded", "removed"] |
793 }); | 793 }); |
794 ext.backgroundPage.sendMessage( | 794 ext.backgroundPage.sendMessage( |
795 { | 795 { |
796 type: "subscriptions.listen", | 796 type: "subscriptions.listen", |
797 filter: ["added", "disabled", "homepage", "removed", "title"] | 797 filter: ["added", "disabled", "homepage", "removed", "title"] |
798 }); | 798 }); |
799 | 799 |
800 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); | 800 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); |
801 })(); | 801 })(); |
LEFT | RIGHT |