Работа над ContentsPage
This commit is contained in:
@@ -59,7 +59,8 @@
|
||||
</div>
|
||||
|
||||
<div class="tab-panel" v-show="selectedTab == 'bookmarks'">
|
||||
<div>
|
||||
<div class="column justify-center items-center" style="height: 100px">
|
||||
Раздел находится в разработке
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -89,9 +90,15 @@ class ContentsPage extends Vue {
|
||||
created() {
|
||||
}
|
||||
|
||||
init(currentBook, parsed) {
|
||||
async init(currentBook, parsed) {
|
||||
this.$refs.window.init();
|
||||
|
||||
if (this.parsed != parsed) {
|
||||
this.contents = [];
|
||||
await this.$nextTick();
|
||||
this.parsed = parsed;
|
||||
}
|
||||
|
||||
const prepareLabel = (title, bolder = false) => {
|
||||
let titleParts = title.split('<p>');
|
||||
const textParts = titleParts.filter(v => v).map(v => `<div>${v.replace(/(<([^>]+)>)/ig, '')}</div>`);
|
||||
@@ -100,11 +107,35 @@ class ContentsPage extends Vue {
|
||||
return textParts.join('');
|
||||
}
|
||||
|
||||
const insetStyle = inset => `width: ${(inset > 1 ? inset - 1 : 0)*20}px`;
|
||||
const insetStyle = inset => `width: ${inset*20}px`;
|
||||
const pc = parsed.contents;
|
||||
const newpc = [];
|
||||
|
||||
//преобразуем не первые разделы body в title-subtitle
|
||||
let curSubtitles = [];
|
||||
let prevBodyIndex = -1;
|
||||
for (let i = 0; i < pc.length; i++) {
|
||||
const cont = pc[i];
|
||||
if (prevBodyIndex != cont.bodyIndex)
|
||||
curSubtitles = [];
|
||||
|
||||
prevBodyIndex = cont.bodyIndex;
|
||||
|
||||
if (cont.bodyIndex > 1) {
|
||||
if (cont.inset < 1) {
|
||||
newpc.push(Object.assign({}, cont, {subtitles: curSubtitles}));
|
||||
} else {
|
||||
curSubtitles.push(Object.assign({}, cont, {inset: cont.inset - 1}));
|
||||
}
|
||||
} else {
|
||||
newpc.push(cont);
|
||||
}
|
||||
}
|
||||
|
||||
//формируем newContents
|
||||
let i = 0;
|
||||
const newContents = [];
|
||||
parsed.contents.forEach((cont) => {
|
||||
newpc.forEach((cont) => {
|
||||
const label = prepareLabel(cont.title, true);
|
||||
const style = insetStyle(cont.inset);
|
||||
|
||||
@@ -127,8 +158,10 @@ class ContentsPage extends Vue {
|
||||
this.contents = newContents;
|
||||
}
|
||||
|
||||
setBookPos(newValue) {
|
||||
async setBookPos(newValue) {
|
||||
this.$emit('book-pos-changed', {bookPos: newValue});
|
||||
await this.$nextTick();
|
||||
this.close();
|
||||
}
|
||||
|
||||
close() {
|
||||
|
||||
@@ -99,7 +99,7 @@
|
||||
<HelpPage v-if="helpActive" ref="helpPage" @do-action="doAction"></HelpPage>
|
||||
<ClickMapPage v-show="clickMapActive" ref="clickMapPage"></ClickMapPage>
|
||||
<ServerStorage v-show="hidden" ref="serverStorage"></ServerStorage>
|
||||
<ContentsPage v-show="contentsPageActive" ref="contentsPage" @do-action="doAction" @book-pos-changed="bookPosChanged"></ContentsPage>
|
||||
<ContentsPage v-show="contentsActive" ref="contentsPage" @do-action="doAction" @book-pos-changed="bookPosChanged"></ContentsPage>
|
||||
|
||||
<ReaderDialogs ref="dialogs" @donate-toggle="donateToggle" @version-history-toggle="versionHistoryToggle"></ReaderDialogs>
|
||||
</div>
|
||||
@@ -209,7 +209,7 @@ class Reader extends Vue {
|
||||
settingsActive = false;
|
||||
helpActive = false;
|
||||
clickMapActive = false;
|
||||
contentsPageActive = false;
|
||||
contentsActive = false;
|
||||
|
||||
bookPos = null;
|
||||
allowUrlParamBookPos = false;
|
||||
@@ -500,7 +500,7 @@ class Reader extends Vue {
|
||||
this.stopScrolling();
|
||||
this.stopSearch();
|
||||
this.helpActive = false;
|
||||
this.contentsPageActive = false;
|
||||
this.contentsActive = false;
|
||||
}
|
||||
|
||||
loaderToggle() {
|
||||
@@ -615,17 +615,17 @@ class Reader extends Vue {
|
||||
}
|
||||
|
||||
contentsPageToggle() {
|
||||
this.contentsPageActive = !this.contentsPageActive;
|
||||
this.contentsActive = !this.contentsActive;
|
||||
const page = this.$refs.page;
|
||||
if (this.contentsPageActive && this.activePage == 'TextPage' && page.parsed) {
|
||||
if (this.contentsActive && this.activePage == 'TextPage' && page.parsed) {
|
||||
this.closeAllWindows();
|
||||
this.contentsPageActive = true;
|
||||
this.contentsActive = true;
|
||||
|
||||
this.$nextTick(() => {
|
||||
this.$refs.contentsPage.init(this.mostRecentBook(), page.parsed);
|
||||
});
|
||||
} else {
|
||||
this.contentsPageActive = false;
|
||||
this.contentsActive = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1156,7 +1156,7 @@ class Reader extends Vue {
|
||||
if (!result && this.copyTextActive)
|
||||
result = this.$refs.copyTextPage.keyHook(event);
|
||||
|
||||
if (!result && this.contentsPageActive)
|
||||
if (!result && this.contentsActive)
|
||||
result = this.$refs.contentsPage.keyHook(event);
|
||||
|
||||
if (!result && this.$refs.page && this.$refs.page.keyHook)
|
||||
|
||||
@@ -53,12 +53,13 @@ export default class BookParser {
|
||||
let dimPromises = [];
|
||||
|
||||
//оглавление
|
||||
this.contents = [];//[{paraIndex: <number>, title: <string>, subtitles: [{paraIndex: <number>, title: <string>}, ... ]}, ... ]
|
||||
this.contents = [];
|
||||
let curTitle = {paraIndex: -1, title: '', subtitles: []};
|
||||
let curSubtitle = {paraIndex: -1, title: ''};
|
||||
let inTitle = false;
|
||||
let inSubtitle = false;
|
||||
let sectionLevel = 0;
|
||||
let bodyIndex = 0;
|
||||
|
||||
let paraIndex = -1;
|
||||
let paraOffset = 0;
|
||||
@@ -226,6 +227,7 @@ export default class BookParser {
|
||||
if (!isFirstBody)
|
||||
newParagraph(' ', 1);
|
||||
isFirstBody = false;
|
||||
bodyIndex++;
|
||||
}
|
||||
|
||||
if (tag == 'title') {
|
||||
@@ -235,7 +237,7 @@ export default class BookParser {
|
||||
center = true;
|
||||
|
||||
inTitle = true;
|
||||
curTitle = {paraIndex, title: '', inset: sectionLevel, subtitles: []};
|
||||
curTitle = {paraIndex, title: '', inset: sectionLevel, bodyIndex, subtitles: []};
|
||||
this.contents.push(curTitle);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user