2021-10-18 01:05:43 +02:00
|
|
|
|
<template>
|
2023-06-18 19:56:32 +02:00
|
|
|
|
<div v-if="show" id="reader" :data-theme="ereaderTheme" class="group absolute top-0 left-0 w-full z-60 data-[theme=dark]:bg-primary data-[theme=dark]:text-white data-[theme=light]:bg-white data-[theme=light]:text-black" :class="{ 'reader-player-open': !!streamLibraryItem }">
|
2023-06-15 00:30:08 +02:00
|
|
|
|
<div class="absolute top-4 left-4 z-20 flex items-center">
|
|
|
|
|
<button v-if="isEpub" @click="toggleToC" type="button" aria-label="Table of contents menu" class="inline-flex opacity-80 hover:opacity-100">
|
|
|
|
|
<span class="material-icons text-2xl">menu</span>
|
|
|
|
|
</button>
|
|
|
|
|
<button v-if="hasSettings" @click="openSettings" type="button" aria-label="Ereader settings" class="mx-4 inline-flex opacity-80 hover:opacity-100">
|
|
|
|
|
<span class="material-icons text-1.5xl">settings</span>
|
|
|
|
|
</button>
|
2021-10-18 01:05:43 +02:00
|
|
|
|
</div>
|
|
|
|
|
|
2023-03-22 11:16:01 +01:00
|
|
|
|
<div class="absolute top-4 left-1/2 transform -translate-x-1/2">
|
2023-06-18 21:10:01 +02:00
|
|
|
|
<h1 :data-type="ebookType" class="text-lg sm:text-xl md:text-2xl mb-1 data-[type=comic]:hidden" style="line-height: 1.15; font-weight: 100">
|
2023-03-22 11:16:01 +01:00
|
|
|
|
<span style="font-weight: 600">{{ abTitle }}</span>
|
2023-06-18 21:10:01 +02:00
|
|
|
|
<span v-if="abAuthor" class="hidden md:inline"> – </span>
|
|
|
|
|
<span v-if="abAuthor" class="hidden md:inline">{{ abAuthor }}</span>
|
2023-03-22 11:16:01 +01:00
|
|
|
|
</h1>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="absolute top-4 right-4 z-20">
|
2023-06-15 00:30:08 +02:00
|
|
|
|
<button @click="close" type="button" aria-label="Close ereader" class="inline-flex opacity-80 hover:opacity-100">
|
|
|
|
|
<span class="material-icons text-2xl">close</span>
|
|
|
|
|
</button>
|
2021-10-18 01:05:43 +02:00
|
|
|
|
</div>
|
|
|
|
|
|
2023-06-18 21:10:01 +02:00
|
|
|
|
<component v-if="componentName" ref="readerComponent" :is="componentName" :library-item="selectedLibraryItem" :player-open="!!streamLibraryItem" :keep-progress="keepProgress" :file-id="ebookFileId" @touchstart="touchstart" @touchend="touchend" @hook:mounted="readerMounted" />
|
2023-03-22 11:16:01 +01:00
|
|
|
|
|
2023-03-24 23:57:41 +01:00
|
|
|
|
<!-- TOC side nav -->
|
2023-10-27 09:14:46 +02:00
|
|
|
|
<div v-if="tocOpen" class="w-full h-full overflow-y-scroll absolute inset-0 bg-black/20 z-20" @click.stop.prevent="toggleToC"></div>
|
2023-06-15 00:30:08 +02:00
|
|
|
|
<div v-if="isEpub" class="w-96 h-full max-h-full absolute top-0 left-0 shadow-xl transition-transform z-30 group-data-[theme=dark]:bg-primary group-data-[theme=dark]:text-white group-data-[theme=light]:bg-white group-data-[theme=light]:text-black" :class="tocOpen ? 'translate-x-0' : '-translate-x-96'" @click.stop.prevent="toggleToC">
|
2023-10-27 09:14:46 +02:00
|
|
|
|
<div class="flex flex-col p-4 h-full">
|
2023-06-15 00:30:08 +02:00
|
|
|
|
<div class="flex items-center mb-2">
|
|
|
|
|
<button @click.stop.prevent="toggleToC" type="button" aria-label="Close table of contents" class="inline-flex opacity-80 hover:opacity-100">
|
|
|
|
|
<span class="material-icons text-2xl">arrow_back</span>
|
|
|
|
|
</button>
|
|
|
|
|
|
2023-06-17 00:00:40 +02:00
|
|
|
|
<p class="text-lg font-semibold ml-2">{{ $strings.HeaderTableOfContents }}</p>
|
2023-06-15 00:30:08 +02:00
|
|
|
|
</div>
|
2023-10-27 09:14:46 +02:00
|
|
|
|
<form @submit.prevent="searchBook" @click.stop.prevent>
|
|
|
|
|
<ui-text-input clearable ref="input" @submit="searchBook" v-model="searchQuery" :placeholder="$strings.PlaceholderSearch" class="h-8 w-full text-sm flex mb-2" />
|
|
|
|
|
</form>
|
|
|
|
|
|
|
|
|
|
<div class="overflow-y-auto">
|
|
|
|
|
<div v-if="isSearching && !this.searchResults.length" class="w-full h-40 justify-center">
|
|
|
|
|
<p class="text-center text-xl py-4">{{ $strings.MessageNoResults }}</p>
|
|
|
|
|
</div>
|
|
|
|
|
|
2023-03-22 11:16:01 +01:00
|
|
|
|
<ul>
|
2023-10-27 09:14:46 +02:00
|
|
|
|
<li v-for="chapter in isSearching ? this.searchResults : chapters" :key="chapter.id" class="py-1">
|
|
|
|
|
<a :href="chapter.href" class="opacity-80 hover:opacity-100" @click.prevent="$refs.readerComponent.goToChapter(chapter.href)">{{ chapter.title }}</a>
|
|
|
|
|
<div v-for="searchResults in chapter.searchResults" :key="searchResults.cfi" class="text-sm py-1 pl-4">
|
|
|
|
|
<a :href="searchResults.cfi" class="opacity-50 hover:opacity-100" @click.prevent="$refs.readerComponent.goToChapter(searchResults.cfi)">{{ searchResults.excerpt }}</a>
|
|
|
|
|
</div>
|
|
|
|
|
|
2023-05-23 22:38:49 +02:00
|
|
|
|
<ul v-if="chapter.subitems.length">
|
|
|
|
|
<li v-for="subchapter in chapter.subitems" :key="subchapter.id" class="py-1 pl-4">
|
2023-10-27 09:14:46 +02:00
|
|
|
|
<a :href="subchapter.href" class="opacity-80 hover:opacity-100" @click.prevent="$refs.readerComponent.goToChapter(subchapter.href)">{{ subchapter.title }}</a>
|
|
|
|
|
<div v-for="subChapterSearchResults in subchapter.searchResults" :key="subChapterSearchResults.cfi" class="text-sm py-1 pl-4">
|
|
|
|
|
<a :href="subChapterSearchResults.cfi" class="opacity-50 hover:opacity-100" @click.prevent="$refs.readerComponent.goToChapter(subChapterSearchResults.cfi)">{{ subChapterSearchResults.excerpt }}</a>
|
|
|
|
|
</div>
|
2023-05-23 22:38:49 +02:00
|
|
|
|
</li>
|
|
|
|
|
</ul>
|
2023-03-22 11:16:01 +01:00
|
|
|
|
</li>
|
|
|
|
|
</ul>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2023-06-15 00:30:08 +02:00
|
|
|
|
|
2023-06-18 19:56:32 +02:00
|
|
|
|
<!-- ereader settings modal -->
|
2023-06-15 00:30:08 +02:00
|
|
|
|
<modals-modal v-model="showSettings" name="ereader-settings-modal" :width="500" :height="'unset'" :processing="false">
|
|
|
|
|
<template #outer>
|
|
|
|
|
<div class="absolute top-0 left-0 p-5 w-3/4 overflow-hidden">
|
2023-06-17 00:00:40 +02:00
|
|
|
|
<p class="text-xl md:text-3xl text-white truncate">{{ $strings.HeaderEreaderSettings }}</p>
|
2023-06-15 00:30:08 +02:00
|
|
|
|
</div>
|
|
|
|
|
</template>
|
2023-06-18 21:10:01 +02:00
|
|
|
|
<div class="px-2 py-4 md:p-8 w-full text-base rounded-lg bg-bg shadow-lg border border-black-300 relative overflow-x-hidden overflow-y-auto" style="max-height: 80vh">
|
2023-06-15 00:30:08 +02:00
|
|
|
|
<div class="flex items-center mb-4">
|
|
|
|
|
<div class="w-40">
|
2023-06-17 00:00:40 +02:00
|
|
|
|
<p class="text-lg">{{ $strings.LabelTheme }}:</p>
|
2023-06-15 00:30:08 +02:00
|
|
|
|
</div>
|
2023-10-26 11:01:40 +02:00
|
|
|
|
<ui-toggle-btns v-model="ereaderSettings.theme" :items="themeItems.theme" @input="settingsUpdated" />
|
|
|
|
|
</div>
|
|
|
|
|
<div class="flex items-center mb-4">
|
|
|
|
|
<div class="w-40">
|
|
|
|
|
<p class="text-lg">{{ $strings.LabelFontFamily }}:</p>
|
|
|
|
|
</div>
|
|
|
|
|
<ui-toggle-btns v-model="ereaderSettings.font" :items="themeItems.font" @input="settingsUpdated" />
|
2023-06-15 00:30:08 +02:00
|
|
|
|
</div>
|
|
|
|
|
<div class="flex items-center mb-4">
|
|
|
|
|
<div class="w-40">
|
2023-06-17 00:00:40 +02:00
|
|
|
|
<p class="text-lg">{{ $strings.LabelFontScale }}:</p>
|
2023-06-15 00:30:08 +02:00
|
|
|
|
</div>
|
|
|
|
|
<ui-range-input v-model="ereaderSettings.fontScale" :min="5" :max="300" :step="5" @input="settingsUpdated" />
|
|
|
|
|
</div>
|
|
|
|
|
<div class="flex items-center mb-4">
|
|
|
|
|
<div class="w-40">
|
2023-06-17 00:00:40 +02:00
|
|
|
|
<p class="text-lg">{{ $strings.LabelLineSpacing }}:</p>
|
2023-06-15 00:30:08 +02:00
|
|
|
|
</div>
|
|
|
|
|
<ui-range-input v-model="ereaderSettings.lineSpacing" :min="100" :max="300" :step="5" @input="settingsUpdated" />
|
|
|
|
|
</div>
|
|
|
|
|
<div class="flex items-center">
|
|
|
|
|
<div class="w-40">
|
2023-06-17 00:00:40 +02:00
|
|
|
|
<p class="text-lg">{{ $strings.LabelLayout }}:</p>
|
2023-06-15 00:30:08 +02:00
|
|
|
|
</div>
|
|
|
|
|
<ui-toggle-btns v-model="ereaderSettings.spread" :items="spreadItems" @input="settingsUpdated" />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</modals-modal>
|
2021-10-18 01:05:43 +02:00
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
export default {
|
|
|
|
|
data() {
|
2023-03-22 11:16:01 +01:00
|
|
|
|
return {
|
2023-06-18 21:10:01 +02:00
|
|
|
|
touchstartX: 0,
|
|
|
|
|
touchstartY: 0,
|
|
|
|
|
touchendX: 0,
|
|
|
|
|
touchendY: 0,
|
|
|
|
|
touchstartTime: 0,
|
|
|
|
|
touchIdentifier: null,
|
2023-03-22 11:16:01 +01:00
|
|
|
|
chapters: [],
|
2023-10-27 09:14:46 +02:00
|
|
|
|
isSearching: false,
|
|
|
|
|
searchResults: [],
|
|
|
|
|
searchQuery: '',
|
2023-06-15 00:30:08 +02:00
|
|
|
|
tocOpen: false,
|
|
|
|
|
showSettings: false,
|
|
|
|
|
ereaderSettings: {
|
|
|
|
|
theme: 'dark',
|
2023-10-26 11:01:40 +02:00
|
|
|
|
font: 'serif',
|
2023-06-15 00:30:08 +02:00
|
|
|
|
fontScale: 100,
|
|
|
|
|
lineSpacing: 115,
|
|
|
|
|
spread: 'auto'
|
2023-06-17 00:00:40 +02:00
|
|
|
|
}
|
2023-03-22 11:16:01 +01:00
|
|
|
|
}
|
2021-10-18 01:05:43 +02:00
|
|
|
|
},
|
|
|
|
|
watch: {
|
|
|
|
|
show(newVal) {
|
|
|
|
|
if (newVal) {
|
|
|
|
|
this.init()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
computed: {
|
|
|
|
|
show: {
|
|
|
|
|
get() {
|
|
|
|
|
return this.$store.state.showEReader
|
|
|
|
|
},
|
|
|
|
|
set(val) {
|
|
|
|
|
this.$store.commit('setShowEReader', val)
|
|
|
|
|
}
|
|
|
|
|
},
|
2023-06-18 19:56:32 +02:00
|
|
|
|
ereaderTheme() {
|
|
|
|
|
if (this.isEpub) return this.ereaderSettings.theme
|
|
|
|
|
return 'dark'
|
|
|
|
|
},
|
2023-06-17 00:00:40 +02:00
|
|
|
|
spreadItems() {
|
|
|
|
|
return [
|
|
|
|
|
{
|
|
|
|
|
text: this.$strings.LabelLayoutSinglePage,
|
|
|
|
|
value: 'none'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
text: this.$strings.LabelLayoutSplitPage,
|
|
|
|
|
value: 'auto'
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
themeItems() {
|
2023-10-26 11:01:40 +02:00
|
|
|
|
return {
|
|
|
|
|
theme: [
|
|
|
|
|
{
|
|
|
|
|
text: this.$strings.LabelThemeDark,
|
|
|
|
|
value: 'dark'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
text: this.$strings.LabelThemeLight,
|
|
|
|
|
value: 'light'
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
font: [
|
|
|
|
|
{
|
|
|
|
|
text: 'Sans',
|
|
|
|
|
value: 'sans-serif',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
text: 'Serif',
|
|
|
|
|
value: 'serif',
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
2023-06-17 00:00:40 +02:00
|
|
|
|
},
|
2021-10-18 01:05:43 +02:00
|
|
|
|
componentName() {
|
2023-03-21 13:27:21 +01:00
|
|
|
|
if (this.ebookType === 'epub') return 'readers-epub-reader'
|
2021-10-18 01:05:43 +02:00
|
|
|
|
else if (this.ebookType === 'mobi') return 'readers-mobi-reader'
|
|
|
|
|
else if (this.ebookType === 'pdf') return 'readers-pdf-reader'
|
|
|
|
|
else if (this.ebookType === 'comic') return 'readers-comic-reader'
|
|
|
|
|
return null
|
|
|
|
|
},
|
2023-05-27 18:58:01 +02:00
|
|
|
|
streamLibraryItem() {
|
|
|
|
|
return this.$store.state.streamLibraryItem
|
|
|
|
|
},
|
2023-03-22 11:16:01 +01:00
|
|
|
|
hasSettings() {
|
2023-06-15 00:30:08 +02:00
|
|
|
|
return this.isEpub
|
2023-03-22 11:16:01 +01:00
|
|
|
|
},
|
2021-10-18 01:05:43 +02:00
|
|
|
|
abTitle() {
|
2022-04-13 15:26:43 +02:00
|
|
|
|
return this.mediaMetadata.title
|
2021-10-18 01:05:43 +02:00
|
|
|
|
},
|
|
|
|
|
abAuthor() {
|
2022-04-13 15:26:43 +02:00
|
|
|
|
return this.mediaMetadata.authorName
|
2021-10-18 01:05:43 +02:00
|
|
|
|
},
|
2022-03-14 01:34:31 +01:00
|
|
|
|
selectedLibraryItem() {
|
2022-04-13 15:26:43 +02:00
|
|
|
|
return this.$store.state.selectedLibraryItem || {}
|
|
|
|
|
},
|
|
|
|
|
media() {
|
|
|
|
|
return this.selectedLibraryItem.media || {}
|
|
|
|
|
},
|
|
|
|
|
mediaMetadata() {
|
|
|
|
|
return this.media.metadata || {}
|
2021-10-18 01:05:43 +02:00
|
|
|
|
},
|
|
|
|
|
libraryId() {
|
2022-03-14 01:34:31 +01:00
|
|
|
|
return this.selectedLibraryItem.libraryId
|
2021-10-18 01:05:43 +02:00
|
|
|
|
},
|
|
|
|
|
folderId() {
|
2022-03-14 01:34:31 +01:00
|
|
|
|
return this.selectedLibraryItem.folderId
|
2021-10-18 01:05:43 +02:00
|
|
|
|
},
|
2022-04-13 15:26:43 +02:00
|
|
|
|
ebookFile() {
|
2023-06-10 19:46:57 +02:00
|
|
|
|
// ebook file id is passed when reading a supplementary ebook
|
|
|
|
|
if (this.ebookFileId) {
|
|
|
|
|
return this.selectedLibraryItem.libraryFiles.find((lf) => lf.ino === this.ebookFileId)
|
|
|
|
|
}
|
2022-04-13 15:26:43 +02:00
|
|
|
|
return this.media.ebookFile
|
|
|
|
|
},
|
|
|
|
|
ebookFormat() {
|
|
|
|
|
if (!this.ebookFile) return null
|
2023-06-10 19:46:57 +02:00
|
|
|
|
// Use file extension for supplementary ebook
|
|
|
|
|
if (!this.ebookFile.ebookFormat) {
|
|
|
|
|
return this.ebookFile.metadata.ext.toLowerCase().slice(1)
|
|
|
|
|
}
|
2022-04-13 15:26:43 +02:00
|
|
|
|
return this.ebookFile.ebookFormat
|
|
|
|
|
},
|
|
|
|
|
ebookType() {
|
|
|
|
|
if (this.isMobi) return 'mobi'
|
|
|
|
|
else if (this.isEpub) return 'epub'
|
|
|
|
|
else if (this.isPdf) return 'pdf'
|
|
|
|
|
else if (this.isComic) return 'comic'
|
|
|
|
|
return null
|
2021-10-18 01:05:43 +02:00
|
|
|
|
},
|
2022-04-13 15:26:43 +02:00
|
|
|
|
isEpub() {
|
|
|
|
|
return this.ebookFormat == 'epub'
|
2021-10-18 01:05:43 +02:00
|
|
|
|
},
|
2022-04-13 15:26:43 +02:00
|
|
|
|
isMobi() {
|
|
|
|
|
return this.ebookFormat == 'mobi' || this.ebookFormat == 'azw3'
|
2021-10-18 01:05:43 +02:00
|
|
|
|
},
|
2022-04-13 15:26:43 +02:00
|
|
|
|
isPdf() {
|
|
|
|
|
return this.ebookFormat == 'pdf'
|
2021-10-18 01:05:43 +02:00
|
|
|
|
},
|
2022-04-13 15:26:43 +02:00
|
|
|
|
isComic() {
|
|
|
|
|
return this.ebookFormat == 'cbz' || this.ebookFormat == 'cbr'
|
|
|
|
|
},
|
2021-10-18 01:05:43 +02:00
|
|
|
|
userToken() {
|
|
|
|
|
return this.$store.getters['user/getToken']
|
2023-06-10 19:46:57 +02:00
|
|
|
|
},
|
|
|
|
|
keepProgress() {
|
|
|
|
|
return this.$store.state.ereaderKeepProgress
|
|
|
|
|
},
|
|
|
|
|
ebookFileId() {
|
|
|
|
|
return this.$store.state.ereaderFileId
|
2023-06-15 00:30:08 +02:00
|
|
|
|
},
|
|
|
|
|
isDarkTheme() {
|
|
|
|
|
return this.ereaderSettings.theme === 'dark'
|
2021-10-18 01:05:43 +02:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
2023-06-15 00:30:08 +02:00
|
|
|
|
readerMounted() {
|
|
|
|
|
if (this.isEpub) {
|
|
|
|
|
this.loadEreaderSettings()
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
settingsUpdated() {
|
|
|
|
|
this.$refs.readerComponent?.updateSettings?.(this.ereaderSettings)
|
|
|
|
|
localStorage.setItem('ereaderSettings', JSON.stringify(this.ereaderSettings))
|
|
|
|
|
},
|
2023-03-22 11:16:01 +01:00
|
|
|
|
toggleToC() {
|
2023-03-24 23:57:41 +01:00
|
|
|
|
this.tocOpen = !this.tocOpen
|
|
|
|
|
this.chapters = this.$refs.readerComponent.chapters
|
2023-03-22 11:16:01 +01:00
|
|
|
|
},
|
2023-06-15 00:30:08 +02:00
|
|
|
|
openSettings() {
|
|
|
|
|
this.showSettings = true
|
|
|
|
|
},
|
2021-10-23 23:49:34 +02:00
|
|
|
|
hotkey(action) {
|
|
|
|
|
if (!this.$refs.readerComponent) return
|
|
|
|
|
|
2021-10-24 21:02:49 +02:00
|
|
|
|
if (action === this.$hotkeys.EReader.NEXT_PAGE) {
|
2023-03-26 21:44:59 +02:00
|
|
|
|
this.next()
|
2021-10-24 21:02:49 +02:00
|
|
|
|
} else if (action === this.$hotkeys.EReader.PREV_PAGE) {
|
2023-03-26 21:44:59 +02:00
|
|
|
|
this.prev()
|
2021-10-24 21:02:49 +02:00
|
|
|
|
} else if (action === this.$hotkeys.EReader.CLOSE) {
|
2021-10-23 23:49:34 +02:00
|
|
|
|
this.close()
|
2021-10-18 01:05:43 +02:00
|
|
|
|
}
|
|
|
|
|
},
|
2023-10-27 09:14:46 +02:00
|
|
|
|
async searchBook() {
|
|
|
|
|
if (this.searchQuery.length > 1) {
|
|
|
|
|
this.searchResults = await this.$refs.readerComponent.searchBook(this.searchQuery)
|
|
|
|
|
this.isSearching = true
|
|
|
|
|
} else {
|
|
|
|
|
this.isSearching = false
|
|
|
|
|
this.searchResults = []
|
|
|
|
|
}
|
|
|
|
|
},
|
2023-03-26 21:44:59 +02:00
|
|
|
|
next() {
|
|
|
|
|
if (this.$refs.readerComponent?.next) this.$refs.readerComponent.next()
|
|
|
|
|
},
|
|
|
|
|
prev() {
|
|
|
|
|
if (this.$refs.readerComponent?.prev) this.$refs.readerComponent.prev()
|
|
|
|
|
},
|
2023-06-18 21:10:01 +02:00
|
|
|
|
handleGesture() {
|
|
|
|
|
// Touch must be less than 1s. Must be > 60px drag and X distance > Y distance
|
|
|
|
|
const touchTimeMs = Date.now() - this.touchstartTime
|
|
|
|
|
if (touchTimeMs >= 1000) {
|
|
|
|
|
console.log('Touch too long', touchTimeMs)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const touchDistanceX = Math.abs(this.touchendX - this.touchstartX)
|
|
|
|
|
const touchDistanceY = Math.abs(this.touchendY - this.touchstartY)
|
|
|
|
|
const touchDistance = Math.sqrt(Math.pow(this.touchstartX - this.touchendX, 2) + Math.pow(this.touchstartY - this.touchendY, 2))
|
|
|
|
|
if (touchDistance < 60) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (touchDistanceX < 60 || touchDistanceY > touchDistanceX) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (this.touchendX < this.touchstartX) {
|
|
|
|
|
this.next()
|
|
|
|
|
}
|
|
|
|
|
if (this.touchendX > this.touchstartX) {
|
|
|
|
|
this.prev()
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
touchstart(e) {
|
|
|
|
|
// Ignore rapid touch
|
|
|
|
|
if (this.touchstartTime && Date.now() - this.touchstartTime < 250) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.touchstartX = e.touches[0].screenX
|
|
|
|
|
this.touchstartY = e.touches[0].screenY
|
|
|
|
|
this.touchstartTime = Date.now()
|
|
|
|
|
this.touchIdentifier = e.touches[0].identifier
|
|
|
|
|
},
|
|
|
|
|
touchend(e) {
|
|
|
|
|
if (this.touchIdentifier !== e.changedTouches[0].identifier) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.touchendX = e.changedTouches[0].screenX
|
|
|
|
|
this.touchendY = e.changedTouches[0].screenY
|
|
|
|
|
this.handleGesture()
|
|
|
|
|
},
|
2021-10-18 01:05:43 +02:00
|
|
|
|
registerListeners() {
|
2021-10-23 23:49:34 +02:00
|
|
|
|
this.$eventBus.$on('reader-hotkey', this.hotkey)
|
2023-06-18 21:10:01 +02:00
|
|
|
|
document.body.addEventListener('touchstart', this.touchstart)
|
|
|
|
|
document.body.addEventListener('touchend', this.touchend)
|
2021-10-18 01:05:43 +02:00
|
|
|
|
},
|
|
|
|
|
unregisterListeners() {
|
2021-10-23 23:49:34 +02:00
|
|
|
|
this.$eventBus.$off('reader-hotkey', this.hotkey)
|
2023-06-18 21:10:01 +02:00
|
|
|
|
document.body.removeEventListener('touchstart', this.touchstart)
|
|
|
|
|
document.body.removeEventListener('touchend', this.touchend)
|
2021-10-18 01:05:43 +02:00
|
|
|
|
},
|
2023-06-15 00:30:08 +02:00
|
|
|
|
loadEreaderSettings() {
|
|
|
|
|
try {
|
|
|
|
|
const settings = localStorage.getItem('ereaderSettings')
|
|
|
|
|
if (settings) {
|
|
|
|
|
this.ereaderSettings = JSON.parse(settings)
|
|
|
|
|
this.settingsUpdated()
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('Failed to load ereader settings', error)
|
|
|
|
|
}
|
|
|
|
|
},
|
2021-10-18 01:05:43 +02:00
|
|
|
|
init() {
|
|
|
|
|
this.registerListeners()
|
|
|
|
|
},
|
|
|
|
|
close() {
|
2021-10-23 23:49:34 +02:00
|
|
|
|
this.unregisterListeners()
|
2023-10-27 09:14:46 +02:00
|
|
|
|
this.isSearching = false
|
|
|
|
|
this.searchQuery = ''
|
2021-10-23 23:49:34 +02:00
|
|
|
|
this.show = false
|
2021-10-18 01:05:43 +02:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
mounted() {
|
|
|
|
|
if (this.show) this.init()
|
|
|
|
|
},
|
|
|
|
|
beforeDestroy() {
|
2021-10-23 23:49:34 +02:00
|
|
|
|
this.unregisterListeners()
|
2021-10-18 01:05:43 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style>
|
2023-05-27 18:58:01 +02:00
|
|
|
|
#reader {
|
|
|
|
|
height: 100%;
|
|
|
|
|
}
|
|
|
|
|
#reader.reader-player-open {
|
|
|
|
|
height: calc(100% - 164px);
|
|
|
|
|
}
|
|
|
|
|
@media (max-height: 400px) {
|
|
|
|
|
#reader.reader-player-open {
|
|
|
|
|
height: 100%;
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-10-18 01:05:43 +02:00
|
|
|
|
</style>
|