From 5a6a403cc96ab97b7e682063bea6015ca25511cd Mon Sep 17 00:00:00 2001 From: tophf Date: Thu, 29 Mar 2018 06:27:37 +0300 Subject: [PATCH] use wrapper for the toggle icon in options --- options.html | 16 ++++++++++------ options/options.js | 13 ++++++------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/options.html b/options.html index 6dbb2173..63dbecf1 100644 --- a/options.html +++ b/options.html @@ -125,12 +125,16 @@
diff --git a/options/options.js b/options/options.js index b563c34b..ca50688b 100644 --- a/options/options.js +++ b/options/options.js @@ -8,15 +8,14 @@ setTimeout(splitLongTooltips); if (!FIREFOX && !OPERA) { const block = $('#advanced'); - const toggleAdvanced = event => { - if (block.classList.contains('collapsed') || event.target.closest('h1')) { - block.classList.toggle('collapsed'); - } + $('h1', block).onclick = event => { + event.preventDefault(); + block.classList.toggle('collapsed'); + const isCollapsed = block.classList.contains('collapsed'); + const visibleToggle = $(isCollapsed ? '.is-collapsed' : '.is-expanded', block); + visibleToggle.focus(); }; block.classList.add('collapsible', 'collapsed'); - block.onclick = toggleAdvanced; - block.onkeydown = event => event.which === 13 && toggleAdvanced(event); - $('h1', block).tabIndex = 0; } // actions