Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/View/Helper/SentenceButtonsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ public function audioButton($sentenceId, $sentenceLang, $sentenceAudios)
$total = count($sentenceAudios);
if ($total) {
$startIn = rand(0, $total-1);
$audioCount = 1;
$audioLinks = "";
foreach ($sentenceAudios as $audio) {
$author = $this->_View->safeForAngular($audio->author);
if (empty($author)) {
Expand All @@ -193,8 +195,12 @@ public function audioButton($sentenceId, $sentenceLang, $sentenceAudios)
$class = 'audioButton audioAvailable';
if ($startIn == 0) {
$class .= ' nextAudioToPlay';

// Only display audio counts for sentences with more than 1 audio
$countContent = $total > 1 ? $total : "";
$audioCount = $this->Html->div("audioButtonCount", $countContent);
}
echo $this->Html->Link(
$audioLink = $this->Html->Link(
null,
$this->Url->build([
'controller' => 'audio',
Expand All @@ -207,8 +213,12 @@ public function audioButton($sentenceId, $sentenceLang, $sentenceAudios)
'onclick' => 'return false',
)
);

$audioLinks .= $audioLink;
$startIn--;
}

echo $this->Html->div("audioButtonWrapper", $audioLinks . $audioCount);
} else {
echo $this->Html->Link(
null,
Expand Down
12 changes: 6 additions & 6 deletions src/View/Helper/SentencesHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -531,18 +531,18 @@ public function displayGenericSentence(
);
}

// Copy
echo '<div class="copy column">';
$this->SentenceButtons->displayCopyButton($sentence->text);
echo '</div>';

// Sentence
$hasAudio = isset($sentence->audios) && count($sentence->audios);
$canEdit = $isEditable && !$hasAudio;
$this->displaySentenceContent($sentence, $canEdit);
echo '</div>';

// audio
// Copy
echo '<div class="copy column">';
$this->SentenceButtons->displayCopyButton($sentence->text);
echo '</div>';

// Audio
if ($withAudio && isset($sentence->audios)) {
echo '<div class="audio column">';
$this->SentenceButtons->audioButton(
Expand Down
31 changes: 19 additions & 12 deletions webroot/css/layouts/elements.css
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,8 @@ html[dir="rtl"] .comment-sentence .text {
}

.sentence {
display: flex;
align-items: center;
padding: 4px 0px;
background: #fff;
}
Expand All @@ -767,8 +769,8 @@ html[dir="rtl"] .comment-sentence .text {
}

.sentence .column {
display: inline-block;
vertical-align: text-top;
display: flex;
align-items: center;
margin: 0 4px;
}

Expand Down Expand Up @@ -796,10 +798,6 @@ html[dir="rtl"] .comment-sentence .text {
width: 515px;
}


.sentence .audio.column {
}

.sentence .link.button {
float: left;
margin: 4px 7px 0 5px;
Expand All @@ -814,8 +812,6 @@ html[dir="rtl"] .comment-sentence .text {
width: 16px;
height: 16px;
cursor: pointer;
margin-top: 5px;
margin-left: 5px;
}

.sentence .copy-btn.copied {
Expand All @@ -828,10 +824,6 @@ html[dir="rtl"] .comment-sentence .text {
border-left: 1px solid #FFF;
}

.sentence .audioButton {
margin-top: 3px;
}

.sentence .favorite-page.column{
list-style-type: none;
}
Expand Down Expand Up @@ -1200,6 +1192,21 @@ input.sentenceId {
opacity: 0.3;
}

.audioButtonWrapper {
position: relative;
display: flex;
flex-wrap: nowrap;
align-items: center;
gap: 2px;
margin-right: 1.5rem;
}

.audioButtonCount {
position: absolute;
font-size: 0.8rem;
left: calc(100% + 0.25rem);
}

/*
* Sentence correctness
*/
Expand Down
2 changes: 1 addition & 1 deletion webroot/js/sentences.play_audio.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ $(document).ready(function () {
$('.audioAvailable').off();
$('.audioAvailable').click(function () {
$(this).removeClass('nextAudioToPlay');
var next = $(this).next();
var next = $(this).next(".audioButton");
if (!next.length) {
next = $(this).parent().children().first();
}
Expand Down