From 9abfd7acde5c917f70db9f2d9e04148862102f57 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Thu, 16 Jan 2020 21:33:58 -0500 Subject: Always show actions when there is only a single term result --- ext/mixed/css/display.css | 16 ++++++++-------- ext/mixed/js/display-generator.js | 10 ++++++---- 2 files changed, 14 insertions(+), 12 deletions(-) (limited to 'ext/mixed') diff --git a/ext/mixed/css/display.css b/ext/mixed/css/display.css index 325cc8e7..808306ca 100644 --- a/ext/mixed/css/display.css +++ b/ext/mixed/css/display.css @@ -233,7 +233,7 @@ button.action-button { border-top-style: solid; } -.entry[data-type=term][data-multi-expression=true] .actions>.action-play-audio { +.entry[data-type=term][data-expression-multi=true]:not([data-expression-count="1"]) .actions>.action-play-audio { display: none; } @@ -280,11 +280,11 @@ button.action-button { content: "\3001"; } -.term-expression-list[data-multi=true] .term-expression-details { +.term-expression-list[data-multi=true]:not([data-count="1"]) .term-expression-details { visibility: hidden; } -.term-expression-list[data-multi=true] .term-expression-details { +.term-expression-list[data-multi=true]:not([data-count="1"]) .term-expression-details { display: inline-block; position: relative; width: 0; @@ -292,21 +292,21 @@ button.action-button { visibility: hidden; } -.term-expression-list[data-multi=true] .term-expression:hover .term-expression-details { +.term-expression-list[data-multi=true]:not([data-count="1"]) .term-expression:hover .term-expression-details { visibility: visible; } -.term-expression-list[data-multi=true] .term-expression-details>.action-play-audio { +.term-expression-list[data-multi=true]:not([data-count="1"]) .term-expression-details>.action-play-audio { position: absolute; left: 0; bottom: 0.5em; } -.term-expression-list[data-multi=true] .term-expression-details>.action-play-audio { +.term-expression-list[data-multi=true]:not([data-count="1"]) .term-expression-details>.action-play-audio { display: block; } -.term-expression-list[data-multi=true] .term-expression-details>.tags { +.term-expression-list[data-multi=true]:not([data-count="1"]) .term-expression-details>.tags { display: block; position: absolute; left: 0; @@ -314,7 +314,7 @@ button.action-button { white-space: nowrap; } -.term-expression-list[data-multi=true] .term-expression-details>.frequencies { +.term-expression-list[data-multi=true]:not([data-count="1"]) .term-expression-details>.frequencies { display: block; position: absolute; left: 0; diff --git a/ext/mixed/js/display-generator.js b/ext/mixed/js/display-generator.js index 8eb699e0..63e7a8b5 100644 --- a/ext/mixed/js/display-generator.js +++ b/ext/mixed/js/display-generator.js @@ -63,11 +63,13 @@ class DisplayGenerator { const definitionsContainer = node.querySelector('.term-definition-list'); const debugInfoContainer = node.querySelector('.debug-info'); - const multiExpression = Array.isArray(details.expressions); - const multiDefinition = Array.isArray(details.definitions); + const expressionMulti = Array.isArray(details.expressions); + const definitionMulti = Array.isArray(details.definitions); - node.dataset.multiExpression = `${multiExpression}`; - node.dataset.multiDefinition = `${multiDefinition}`; + node.dataset.expressionMulti = `${expressionMulti}`; + node.dataset.definitionMulti = `${definitionMulti}`; + node.dataset.expressionCount = `${expressionMulti ? details.expressions.length : 1}`; + node.dataset.definitionCount = `${definitionMulti ? details.definitions.length : 1}`; DisplayGenerator._appendMultiple(expressionsContainer, this.createTermExpression.bind(this), details.expressions, [details]); DisplayGenerator._appendMultiple(reasonsContainer, this.createTermReason.bind(this), details.reasons); -- cgit v1.2.3