diff --git a/client/components/Reader/ContentsPage/ContentsPage.vue b/client/components/Reader/ContentsPage/ContentsPage.vue index bb873354..6a8baa24 100644 --- a/client/components/Reader/ContentsPage/ContentsPage.vue +++ b/client/components/Reader/ContentsPage/ContentsPage.vue @@ -24,36 +24,30 @@
-
- - - - -
-
-
-
{{ subitem.perc }}%
-
-
-
- -
-
+
+
+
+ +
+
+
+
+
{{ item.perc }}%
- +
+ +
+
+
+
+
+
+
{{ subitem.perc }}%
+
+
+
@@ -74,7 +68,7 @@ import Component from 'vue-class-component'; //import _ from 'lodash'; import Window from '../../share/Window.vue'; -//import * as utils from '../../../share/utils'; +import * as utils from '../../../share/utils'; export default @Component({ components: { @@ -93,11 +87,15 @@ class ContentsPage extends Vue { async init(currentBook, parsed) { this.$refs.window.init(); - if (this.parsed != parsed) { - this.contents = []; - await this.$nextTick(); - this.parsed = parsed; - } + //закладки + + //далее формаирование оглавления + if (this.parsed == parsed) + return; + + this.parsed = parsed; + this.contents = []; + await this.$nextTick(); const prepareLabel = (title, bolder = false) => { let titleParts = title.split('

'); @@ -137,7 +135,7 @@ class ContentsPage extends Vue { const newContents = []; newpc.forEach((cont) => { const label = prepareLabel(cont.title, true); - const style = insetStyle(cont.inset); + const indentStyle = insetStyle(cont.inset); let j = 0; const list = []; @@ -145,12 +143,12 @@ class ContentsPage extends Vue { const l = prepareLabel(sub.title); const s = insetStyle(sub.inset + 1); const p = parsed.para[sub.paraIndex]; - list.push({perc: (p.offset/parsed.textLength*100).toFixed(2), label: l, key: j, offset: p.offset, style: s}); + list[j] = {perc: (p.offset/parsed.textLength*100).toFixed(2), label: l, key: j, offset: p.offset, indentStyle: s}; j++; }); const p = parsed.para[cont.paraIndex]; - newContents.push({perc: (p.offset/parsed.textLength*100).toFixed(0), label, key: i, offset: p.offset, style, list}); + newContents[i] = {perc: (p.offset/parsed.textLength*100).toFixed(0), label, key: i, offset: p.offset, indentStyle, expanded: false, list}; i++; }); @@ -158,6 +156,25 @@ class ContentsPage extends Vue { this.contents = newContents; } + async expandClick(key) { + const item = this.contents[key]; + const expanded = !item.expanded; + + if (!expanded) { + const subitems = this.$refs[`subitem${key}`][0]; + subitems.style.height = '0'; + await utils.sleep(200); + } + + this.$set(this.contents, key, Object.assign({}, item, {expanded})); + + if (expanded) { + await this.$nextTick(); + const subitems = this.$refs[`subitem${key}`][0]; + subitems.style.height = subitems.scrollHeight + 'px'; + } + } + async setBookPos(newValue) { this.$emit('book-pos-changed', {bookPos: newValue}); await this.$nextTick(); @@ -190,18 +207,36 @@ class ContentsPage extends Vue { cursor: pointer; } -.item:hover { +.item, .subitem { + height: 40px; + border-bottom: 1px solid #e0e0e0; +} + +.item:hover, .subitem:hover { background-color: #f0f0f0; } -.subitem:hover { - background-color: #e0e0e0; +.expand-button, .no-expand-button { + width: 40px; } -.separator-top { - border-top: 1px solid #e0e0e0; +.expand-button:hover { + background-color: white; + border-radius: 15px; + border: 1px solid #d0d0d0; } -.separator-bottom { - border-top: 1px solid #e0e0e0; + +.subitems-transition { + height: 0; + transition: height 0.2s linear; + overflow: hidden; +} + +.icon { + transition: transform 0.2s; +} + +.expanded-icon { + transform: rotate(180deg); }