|
@@ -1,5 +1,5 @@
|
|
<template>
|
|
<template>
|
|
- <MainContentLayout id="edition">
|
|
|
|
|
|
+ <MainContentLayout id="edition" :reftoscrollto="reftoscrollto" @onCenterScrolled="onCenterScrolled">
|
|
<template v-if="!content" #header>
|
|
<template v-if="!content" #header>
|
|
<span>Loading ...</span>
|
|
<span>Loading ...</span>
|
|
</template>
|
|
</template>
|
|
@@ -32,21 +32,32 @@
|
|
<!-- default slot -->
|
|
<!-- default slot -->
|
|
<div id="text">
|
|
<div id="text">
|
|
<template v-if="texts.length">
|
|
<template v-if="texts.length">
|
|
- <infinite-loading direction="top" @infinite="prevText" />
|
|
|
|
|
|
+ <infinite-loading
|
|
|
|
+ v-if="center_scrolled"
|
|
|
|
+ :identifier="textid"
|
|
|
|
+ direction="top"
|
|
|
|
+ :distance="inifinite_load_distance"
|
|
|
|
+ @infinite="prevText"
|
|
|
|
+ />
|
|
<EdText
|
|
<EdText
|
|
v-for="text in texts"
|
|
v-for="text in texts"
|
|
|
|
+ :ref="text.content.uuid"
|
|
:key="text.content.uuid"
|
|
:key="text.content.uuid"
|
|
:tei="text.content.tei"
|
|
:tei="text.content.tei"
|
|
:uuid="text.content.uuid"
|
|
:uuid="text.content.uuid"
|
|
|
|
+ :textid="textid"
|
|
@onHoverLink="onHoverLink"
|
|
@onHoverLink="onHoverLink"
|
|
@onLeaveLink="onLeaveLink"
|
|
@onLeaveLink="onLeaveLink"
|
|
/>
|
|
/>
|
|
- <infinite-loading @infinite="nextText" />
|
|
|
|
|
|
+ <infinite-loading
|
|
|
|
+ :identifier="textid"
|
|
|
|
+ @infinite="nextText"
|
|
|
|
+ />
|
|
</template>
|
|
</template>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<template #nav>
|
|
<template #nav>
|
|
- <EdToc :toc="toc" />
|
|
|
|
|
|
+ <EdToc :toc="toc" :loadedtextsuuids="textsuuids" @onClickTocItem="onClickTocItem" />
|
|
</template>
|
|
</template>
|
|
</MainContentLayout>
|
|
</MainContentLayout>
|
|
</template>
|
|
</template>
|
|
@@ -79,13 +90,19 @@ export default {
|
|
editionid: null,
|
|
editionid: null,
|
|
textid: null,
|
|
textid: null,
|
|
texts: [],
|
|
texts: [],
|
|
|
|
+ textsuuids: [],
|
|
metainfotitle: undefined,
|
|
metainfotitle: undefined,
|
|
title: undefined,
|
|
title: undefined,
|
|
author: undefined,
|
|
author: undefined,
|
|
texttitle: undefined,
|
|
texttitle: undefined,
|
|
//
|
|
//
|
|
indexitem: null,
|
|
indexitem: null,
|
|
- tooltip_top: null
|
|
|
|
|
|
+ tooltip_top: null,
|
|
|
|
+ //
|
|
|
|
+ next_loaded: false,
|
|
|
|
+ center_scrolled: false,
|
|
|
|
+ inifinite_load_distance: 10,
|
|
|
|
+ reftoscrollto: null
|
|
}),
|
|
}),
|
|
computed: {
|
|
computed: {
|
|
...mapState({
|
|
...mapState({
|
|
@@ -97,6 +114,7 @@ export default {
|
|
textid: function (newid, oldid) {
|
|
textid: function (newid, oldid) {
|
|
console.log('textid watcher', this, oldid, newid)
|
|
console.log('textid watcher', this, oldid, newid)
|
|
this.texts = []
|
|
this.texts = []
|
|
|
|
+ this.textsuuids = []
|
|
this.getTextContent(newid)
|
|
this.getTextContent(newid)
|
|
},
|
|
},
|
|
textdata: function (newtxtdata, oldtxtdata) {
|
|
textdata: function (newtxtdata, oldtxtdata) {
|
|
@@ -181,11 +199,14 @@ export default {
|
|
console.log('text REST: data', data)
|
|
console.log('text REST: data', data)
|
|
if (direction === 'next') {
|
|
if (direction === 'next') {
|
|
this.texts.push(data)
|
|
this.texts.push(data)
|
|
|
|
+ this.textsuuids.push(data.content.uuid)
|
|
} else {
|
|
} else {
|
|
this.texts.unshift(data)
|
|
this.texts.unshift(data)
|
|
|
|
+ this.textsuuids.unshift(data.content.uuid)
|
|
}
|
|
}
|
|
if ($state) {
|
|
if ($state) {
|
|
$state.loaded()
|
|
$state.loaded()
|
|
|
|
+ this.next_loaded = true
|
|
}
|
|
}
|
|
})
|
|
})
|
|
.catch((error) => {
|
|
.catch((error) => {
|
|
@@ -193,6 +214,13 @@ export default {
|
|
Promise.reject(error)
|
|
Promise.reject(error)
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
+ onCenterScrolled (e) {
|
|
|
|
+ // console.log('Edition centerScrolled(e)', e.target.scrollTop)
|
|
|
|
+ if (!this.center_scrolled && e.target.scrollTop > this.inifinite_load_distance * 1.5) {
|
|
|
|
+ this.center_scrolled = true
|
|
|
|
+ }
|
|
|
|
+ this.indexitem = null
|
|
|
|
+ },
|
|
nextText ($state) {
|
|
nextText ($state) {
|
|
console.log('infinite loading nextText()', this.texts[this.texts.length - 1].content.itemAfterUuid, $state)
|
|
console.log('infinite loading nextText()', this.texts[this.texts.length - 1].content.itemAfterUuid, $state)
|
|
if (this.texts[this.texts.length - 1].content.itemAfterUuid) {
|
|
if (this.texts[this.texts.length - 1].content.itemAfterUuid) {
|
|
@@ -223,17 +251,36 @@ export default {
|
|
REST.get(`/index${item.index.charAt(0).toUpperCase()}${item.index.slice(1)}/${item.uuid}`, {})
|
|
REST.get(`/index${item.index.charAt(0).toUpperCase()}${item.index.slice(1)}/${item.uuid}`, {})
|
|
.then(({ data }) => {
|
|
.then(({ data }) => {
|
|
console.log('index tooltip REST: data', data)
|
|
console.log('index tooltip REST: data', data)
|
|
- this.indexitem = data.content
|
|
|
|
|
|
+ if (this.indexitem === 'loading') {
|
|
|
|
+ this.indexitem = data.content
|
|
|
|
+ }
|
|
})
|
|
})
|
|
.catch((error) => {
|
|
.catch((error) => {
|
|
console.warn('Issue with index tooltip rest', error)
|
|
console.warn('Issue with index tooltip rest', error)
|
|
Promise.reject(error)
|
|
Promise.reject(error)
|
|
this.indexitem = null
|
|
this.indexitem = null
|
|
})
|
|
})
|
|
|
|
+ },
|
|
|
|
+ onClickTocItem (uuid) {
|
|
|
|
+ console.log('Edition onClickTocItem', uuid, this.$refs)
|
|
|
|
+ if (this.textsuuids.indexOf(uuid) !== -1) {
|
|
|
|
+ // if already loaded, scroll to uuid
|
|
|
|
+ this.reftoscrollto = `.tei[data-uuid="${uuid}"]`
|
|
|
|
+ } else {
|
|
|
|
+ // if not already loaded, change route
|
|
|
|
+ this.$router.push({
|
|
|
|
+ name: `editiontext`,
|
|
|
|
+ params: {
|
|
|
|
+ id: this.editionid,
|
|
|
|
+ textid: uuid
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
<style lang="scss" scoped>
|
|
|
|
+
|
|
</style>
|
|
</style>
|