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-2017 eyeo GmbH | 3 * Copyright (C) 2006-2017 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 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 else | 467 else |
468 location.href = link; | 468 location.href = link; |
469 }); | 469 }); |
470 } | 470 } |
471 | 471 |
472 function switchTab(id) | 472 function switchTab(id) |
473 { | 473 { |
474 location.hash = id; | 474 location.hash = id; |
475 } | 475 } |
476 | 476 |
477 function execAction(action, key, element) | 477 function execAction(action, element) |
478 { | 478 { |
479 switch (action) | 479 switch (action) |
480 { | 480 { |
481 case "add-domain-exception": | 481 case "add-domain-exception": |
482 addWhitelistedDomain(); | 482 addWhitelistedDomain(); |
483 break; | 483 break; |
484 case "add-language-subscription": | 484 case "add-language-subscription": |
485 addEnableSubscription(findParentData(element, "access", false)); | 485 addEnableSubscription(findParentData(element, "access", false)); |
486 break; | 486 break; |
487 case "add-predefined-subscription": { | 487 case "add-predefined-subscription": { |
(...skipping 24 matching lines...) Expand all Loading... |
512 E("whitelisting-textbox").focus(); | 512 E("whitelisting-textbox").focus(); |
513 break; | 513 break; |
514 case "import-subscription": { | 514 case "import-subscription": { |
515 let url = E("blockingList-textbox").value; | 515 let url = E("blockingList-textbox").value; |
516 addEnableSubscription(url); | 516 addEnableSubscription(url); |
517 closeDialog(); | 517 closeDialog(); |
518 break; | 518 break; |
519 } | 519 } |
520 case "open-context-menu": { | 520 case "open-context-menu": { |
521 let listItem = findParentData(element, "access", true); | 521 let listItem = findParentData(element, "access", true); |
522 if (listItem != context) | 522 if (listItem && !listItem.classList.contains("show-context-menu")) |
523 listItem.classList.add("show-context-menu"); | 523 listItem.classList.add("show-context-menu"); |
524 break; | 524 break; |
525 } | 525 } |
526 case "open-dialog": { | 526 case "open-dialog": { |
527 let dialog = findParentData(element, "dialog", false); | 527 let dialog = findParentData(element, "dialog", false); |
528 openDialog(dialog); | 528 openDialog(dialog); |
529 break; | 529 break; |
530 } | 530 } |
531 case "open-doclink": { | 531 case "open-doclink": { |
532 let doclink = findParentData(element, "doclink", false); | 532 let doclink = findParentData(element, "doclink", false); |
(...skipping 17 matching lines...) Expand all Loading... |
550 type: "filters.importRaw", | 550 type: "filters.importRaw", |
551 text: E("custom-filters-raw").value, | 551 text: E("custom-filters-raw").value, |
552 removeExisting: true | 552 removeExisting: true |
553 }, | 553 }, |
554 () => | 554 () => |
555 { | 555 { |
556 E("custom-filters").classList.remove("mode-edit"); | 556 E("custom-filters").classList.remove("mode-edit"); |
557 }); | 557 }); |
558 break; | 558 break; |
559 case "switch-tab": | 559 case "switch-tab": |
560 if (key == "Enter") | 560 let tabId = findParentData(element, "tab", false); |
561 { | 561 switchTab(tabId); |
562 let tabId = findParentData(element, "tab", false); | |
563 switchTab(tabId); | |
564 } | |
565 else if (element.hasAttribute("aria-selected")) | |
566 { | |
567 if (key == "ArrowLeft" || key == "ArrowUp") | |
568 { | |
569 element = element.previousElementSibling || | |
570 container.lastElementChild; | |
571 } | |
572 else if (key == "ArrowRight" || key == "ArrowDown") | |
573 { | |
574 element = element.nextElementSibling || | |
575 container.firstElementChild; | |
576 } | |
577 let tabId = findParentData(element, "tab", false); | |
578 switchTab(tabId); | |
579 } | |
580 break; | 562 break; |
581 case "toggle-disable-subscription": | 563 case "toggle-disable-subscription": |
582 ext.backgroundPage.sendMessage({ | 564 ext.backgroundPage.sendMessage({ |
583 type: "subscriptions.toggle", | 565 type: "subscriptions.toggle", |
584 keepInstalled: true, | 566 keepInstalled: true, |
585 url: findParentData(element, "access", false) | 567 url: findParentData(element, "access", false) |
586 }); | 568 }); |
587 break; | 569 break; |
588 case "toggle-pref": | 570 case "toggle-pref": |
589 ext.backgroundPage.sendMessage({ | 571 ext.backgroundPage.sendMessage({ |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
623 if (context) | 605 if (context) |
624 context.classList.remove("show-context-menu"); | 606 context.classList.remove("show-context-menu"); |
625 | 607 |
626 let actions = findParentData(e.target, "action", false); | 608 let actions = findParentData(e.target, "action", false); |
627 if (!actions) | 609 if (!actions) |
628 return; | 610 return; |
629 | 611 |
630 actions = actions.split(","); | 612 actions = actions.split(","); |
631 for (let action of actions) | 613 for (let action of actions) |
632 { | 614 { |
633 execAction(action, "Enter", e.target); | 615 execAction(action, e.target); |
634 } | 616 } |
635 } | 617 } |
636 | 618 |
637 function getKey(e) | 619 function getKey(e) |
638 { | 620 { |
639 // e.keyCode has been deprecated so we attempt to use e.key | 621 // e.keyCode has been deprecated so we attempt to use e.key |
640 if ("key" in e) | 622 if ("key" in e) |
641 return e.key; | 623 return e.key; |
642 return getKey.keys[e.keyCode]; | 624 return getKey.keys[e.keyCode]; |
643 } | 625 } |
(...skipping 15 matching lines...) Expand all Loading... |
659 return; | 641 return; |
660 | 642 |
661 let container = findParentData(element, "action", true); | 643 let container = findParentData(element, "action", true); |
662 if (!container || !container.hasAttribute("data-keys")) | 644 if (!container || !container.hasAttribute("data-keys")) |
663 return; | 645 return; |
664 | 646 |
665 let keys = container.getAttribute("data-keys").split(" "); | 647 let keys = container.getAttribute("data-keys").split(" "); |
666 if (keys.indexOf(key) < 0) | 648 if (keys.indexOf(key) < 0) |
667 return; | 649 return; |
668 | 650 |
| 651 if (element.getAttribute("role") == "tab") |
| 652 { |
| 653 if (key == "ArrowLeft" || key == "ArrowUp") |
| 654 element = element.previousElementSibling || container.lastElementChild; |
| 655 else if (key == "ArrowRight" || key == "ArrowDown") |
| 656 element = element.nextElementSibling || container.firstElementChild; |
| 657 } |
| 658 |
669 let actions = container.getAttribute("data-action").split(","); | 659 let actions = container.getAttribute("data-action").split(","); |
670 for (let action of actions) | 660 for (let action of actions) |
671 { | 661 { |
672 execAction(action, key, element); | 662 execAction(action, element); |
673 } | 663 } |
674 } | 664 } |
675 | 665 |
676 function selectTabItem(tabId, container, focus) | 666 function selectTabItem(tabId, container, focus) |
677 { | 667 { |
678 // Show tab content | 668 // Show tab content |
679 document.body.setAttribute("data-tab", tabId); | 669 document.body.setAttribute("data-tab", tabId); |
680 | 670 |
681 // Select tab | 671 // Select tab |
682 let tabList = container.querySelector("[role='tablist']"); | 672 let tabList = container.querySelector("[role='tablist']"); |
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1299 }); | 1289 }); |
1300 ext.backgroundPage.sendMessage({ | 1290 ext.backgroundPage.sendMessage({ |
1301 type: "subscriptions.listen", | 1291 type: "subscriptions.listen", |
1302 filter: ["added", "disabled", "homepage", "lastDownload", "removed", | 1292 filter: ["added", "disabled", "homepage", "lastDownload", "removed", |
1303 "title", "downloadStatus", "downloading"] | 1293 "title", "downloadStatus", "downloading"] |
1304 }); | 1294 }); |
1305 | 1295 |
1306 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); | 1296 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); |
1307 window.addEventListener("hashchange", onHashChange, false); | 1297 window.addEventListener("hashchange", onHashChange, false); |
1308 } | 1298 } |
LEFT | RIGHT |