aboutsummaryrefslogtreecommitdiff
path: root/ext/js/display
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2021-05-30 13:29:55 -0400
committerGitHub <noreply@github.com>2021-05-30 13:29:55 -0400
commit5bf82a5b81ef172d544da9c5c25492577270e8aa (patch)
tree825b2ac1d109e8dee194caf00dcf9add3a4a7994 /ext/js/display
parentcca01e85a35576225661699a7be63550e9500642 (diff)
Primary audio fixes (#1719)
* Fix case when subIndex is not assigned * Fix incorrect assignment of primary card audio * Improve opacity style * Improve styles for :focus-visible
Diffstat (limited to 'ext/js/display')
-rw-r--r--ext/js/display/display-audio.js12
1 files changed, 7 insertions, 5 deletions
diff --git a/ext/js/display/display-audio.js b/ext/js/display/display-audio.js
index 6d2504e4..e5c1b135 100644
--- a/ext/js/display/display-audio.js
+++ b/ext/js/display/display-audio.js
@@ -352,6 +352,7 @@ class DisplayAudio {
const headword = this._getHeadword(dictionaryEntryIndex, headwordIndex);
if (headword === null) { return; }
+ const {index} = source;
const {term, reading} = headword;
const cacheEntry = this._getCacheItem(term, reading, true);
@@ -359,9 +360,9 @@ class DisplayAudio {
primaryCardAudio = (
!canToggleOff ||
primaryCardAudio === null ||
- primaryCardAudio.source !== source ||
- primaryCardAudio.index !== subIndex
- ) ? {index: source.index, subIndex} : null;
+ primaryCardAudio.index !== index ||
+ primaryCardAudio.subIndex !== subIndex
+ ) ? {index: index, subIndex} : null;
cacheEntry.primaryCardAudio = primaryCardAudio;
if (menu !== null) {
@@ -698,8 +699,9 @@ class DisplayAudio {
const primaryCardAudioSubIndex = (primaryCardAudio !== null ? primaryCardAudio.subIndex : null);
const itemGroups = menuBodyNode.querySelectorAll('.popup-menu-item-group');
for (const node of itemGroups) {
- const index = Number.parseInt(node.dataset.index, 10);
- const subIndex = Number.parseInt(node.dataset.subIndex, 10);
+ let {index, subIndex} = node.dataset;
+ index = Number.parseInt(index, 10);
+ subIndex = typeof subIndex === 'string' ? Number.parseInt(subIndex, 10) : null;
const isPrimaryCardAudio = (index === primaryCardAudioIndex && subIndex === primaryCardAudioSubIndex);
node.dataset.isPrimaryCardAudio = `${isPrimaryCardAudio}`;
}