2021-09-08 12:17:02 -05:00
|
|
|
<template>
|
2023-06-13 17:15:28 -05:00
|
|
|
<modals-modal v-model="show" :width="400" height="100%">
|
2021-09-21 18:32:59 -05:00
|
|
|
<template #outer>
|
2023-06-13 17:15:28 -05:00
|
|
|
<div v-if="currentChapter" class="absolute top-10 left-4 z-40 pt-1" style="max-width: 80%">
|
2023-12-03 17:37:01 -06:00
|
|
|
<p class="text-white text-lg truncate">{{ chapters.length }} {{ $strings.LabelChapters }}</p>
|
2021-09-21 18:32:59 -05:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2021-09-08 12:17:02 -05:00
|
|
|
<div class="w-full h-full overflow-hidden absolute top-0 left-0 flex items-center justify-center" @click="show = false">
|
2023-06-01 17:36:52 -05:00
|
|
|
<div ref="container" class="w-full overflow-x-hidden overflow-y-auto bg-secondary rounded-lg border border-white border-opacity-20" style="max-height: 75%" @click.stop>
|
2021-09-08 12:17:02 -05:00
|
|
|
<ul class="h-full w-full" role="listbox" aria-labelledby="listbox-label">
|
2023-01-05 23:07:11 +01:00
|
|
|
<template v-for="(chapter, index) in chapters">
|
2023-06-01 17:36:52 -05:00
|
|
|
<li :key="chapter.id" :id="`chapter-row-${chapter.id}`" class="text-gray-50 select-none relative py-4 cursor-pointer" :class="currentChapterId === chapter.id ? 'bg-primary bg-opacity-80' : ''" role="option" @click="clickedOption(chapter)">
|
2022-12-10 14:55:33 -06:00
|
|
|
<div class="relative flex items-center pl-3 pr-20">
|
2023-01-05 23:07:11 +01:00
|
|
|
<p class="font-normal block truncate text-sm text-white text-opacity-80">{{ index + 1 }} - {{ chapter.title }}</p>
|
2021-12-11 13:20:20 -06:00
|
|
|
<div class="absolute top-0 right-3 -mt-0.5">
|
2023-06-01 17:36:52 -05:00
|
|
|
<span class="font-mono text-white text-opacity-90 leading-3 text-sm" style="letter-spacing: -0.5px">{{ $secondsToTimestamp(chapter.start / _playbackRate) }}</span>
|
2021-11-02 19:44:42 -05:00
|
|
|
</div>
|
2021-09-08 12:17:02 -05:00
|
|
|
</div>
|
2021-10-31 14:35:34 -05:00
|
|
|
|
|
|
|
<div v-show="chapter.id === currentChapterId" class="w-0.5 h-full absolute top-0 left-0 bg-yellow-400" />
|
2021-09-08 12:17:02 -05:00
|
|
|
</li>
|
|
|
|
</template>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</modals-modal>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
value: Boolean,
|
|
|
|
chapters: {
|
|
|
|
type: Array,
|
|
|
|
default: () => []
|
2021-09-21 18:32:59 -05:00
|
|
|
},
|
|
|
|
currentChapter: {
|
|
|
|
type: Object,
|
|
|
|
default: () => null
|
2023-06-01 17:36:52 -05:00
|
|
|
},
|
|
|
|
playbackRate: Number
|
2021-09-08 12:17:02 -05:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {}
|
|
|
|
},
|
2021-10-31 14:35:34 -05:00
|
|
|
watch: {
|
|
|
|
value(newVal) {
|
2023-06-13 17:15:28 -05:00
|
|
|
if (newVal) {
|
|
|
|
this.$nextTick(this.scrollToChapter)
|
|
|
|
}
|
2021-10-31 14:35:34 -05:00
|
|
|
}
|
|
|
|
},
|
2021-09-08 12:17:02 -05:00
|
|
|
computed: {
|
|
|
|
show: {
|
|
|
|
get() {
|
|
|
|
return this.value
|
|
|
|
},
|
|
|
|
set(val) {
|
|
|
|
this.$emit('input', val)
|
|
|
|
}
|
2021-09-21 18:32:59 -05:00
|
|
|
},
|
2023-06-01 17:36:52 -05:00
|
|
|
_playbackRate() {
|
|
|
|
if (!this.playbackRate || isNaN(this.playbackRate)) return 1
|
|
|
|
return this.playbackRate
|
|
|
|
},
|
2021-09-21 18:32:59 -05:00
|
|
|
currentChapterId() {
|
2023-06-13 17:15:28 -05:00
|
|
|
return this.currentChapter?.id
|
2021-09-21 18:32:59 -05:00
|
|
|
},
|
|
|
|
currentChapterTitle() {
|
2023-06-01 17:36:52 -05:00
|
|
|
return this.currentChapter?.title || null
|
2021-09-08 12:17:02 -05:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
clickedOption(chapter) {
|
|
|
|
this.$emit('select', chapter)
|
2021-10-31 14:35:34 -05:00
|
|
|
},
|
|
|
|
scrollToChapter() {
|
|
|
|
if (!this.currentChapterId) return
|
|
|
|
|
2023-06-13 17:15:28 -05:00
|
|
|
const container = this.$refs.container
|
2021-10-31 14:35:34 -05:00
|
|
|
if (container) {
|
2023-06-13 17:15:28 -05:00
|
|
|
const currChapterEl = document.getElementById(`chapter-row-${this.currentChapterId}`)
|
2021-10-31 14:35:34 -05:00
|
|
|
if (currChapterEl) {
|
2023-06-13 17:15:28 -05:00
|
|
|
const offsetTop = currChapterEl.offsetTop
|
|
|
|
const containerHeight = container.clientHeight
|
2021-10-31 14:35:34 -05:00
|
|
|
container.scrollTo({ top: offsetTop - containerHeight / 2 })
|
|
|
|
}
|
|
|
|
}
|
2021-09-08 12:17:02 -05:00
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {}
|
|
|
|
}
|
|
|
|
</script>
|