Skip to content

Commit

Permalink
Merge pull request #132 from slsfi/develop
Browse files Browse the repository at this point in the history
Merge develop into master
  • Loading branch information
SebastianKohler authored Oct 13, 2022
2 parents e6cbf9d + 8e338d1 commit 13acd7f
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export class TableOfContentsAccordionComponent {
if (value.searchTocItem !== undefined && value.searchTocItem) {
// Find toc item and open its parents
if (value.searchItemId) {
value.searchItemId = String(value.searchItemId).replace('_nochapter', '').replace(':chapterID', '');
value.searchItemId = String(value.searchItemId).replace('_nochapter', '').replace(':chapterID', '').replace('%3AchapterID', '');
// Try to find the correct position in the TOC. If not found, try to find the nearest.
if ( this.findTocByPubOnly(this.collapsableItems, value.searchItemId) === false ) {
// try to find without position
Expand Down
7 changes: 5 additions & 2 deletions src/components/text-changer/text-changer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -440,12 +440,15 @@ export class TextChangerComponent {
this.legacyId = this.params.get('collectionID');
if (this.params.get('publicationID') !== undefined) {
this.legacyId += '_' + this.params.get('publicationID')
if (this.params.get('chapterID') !== undefined && this.params.get('chapterID') !== 'nochapter') {
if (this.params.get('chapterID') !== undefined
&& this.params.get('chapterID') !== 'nochapter'
&& this.params.get('chapterID') !== ':chapterID'
&& this.params.get('chapterID') !== '%3AchapterID') {
this.legacyId += '_' + this.params.get('chapterID');
}
}
}
this.legacyId = String(this.legacyId);
this.legacyId = String(this.legacyId).replace('_nochapter', '').replace(':chapterID', '').replace('%3AchapterID', '');
}

findNext(toc) {
Expand Down
7 changes: 7 additions & 0 deletions src/config-sample.json
Original file line number Diff line number Diff line change
Expand Up @@ -570,5 +570,12 @@
"print": true
},
"usePrintNotDownloadIcon": false
},
"showDisplayOptionsButton": {
"pageTitle": true,
"pageForeword": true,
"pageIntroduction": true,
"pageRead": true,
"pageEpub": true
}
}
2 changes: 1 addition & 1 deletion src/pages/introduction/introduction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ export class IntroductionPage {
textDownloadOptions.enabledIntroductionFormats !== null &&
Object.keys(textDownloadOptions.enabledIntroductionFormats).length !== 0) {
for (const [key, value] of Object.entries(textDownloadOptions.enabledIntroductionFormats)) {
if (`${value}`) {
if (value) {
this.showTextDownloadButton = true;
break;
}
Expand Down
34 changes: 23 additions & 11 deletions src/pages/read/read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ export class ReadPage /*implements OnDestroy*/ {
textDownloadOptions.enabledEstablishedFormats !== null &&
Object.keys(textDownloadOptions.enabledEstablishedFormats).length !== 0) {
for (const [key, value] of Object.entries(textDownloadOptions.enabledEstablishedFormats)) {
if (`${value}`) {
if (value) {
this.showTextDownloadButton = true;
break;
}
Expand All @@ -280,7 +280,7 @@ export class ReadPage /*implements OnDestroy*/ {
textDownloadOptions.enabledCommentsFormats !== null &&
Object.keys(textDownloadOptions.enabledCommentsFormats).length !== 0) {
for (const [key, value] of Object.entries(textDownloadOptions.enabledCommentsFormats)) {
if (`${value}`) {
if (value) {
this.showTextDownloadButton = true;
break;
}
Expand Down Expand Up @@ -524,19 +524,31 @@ export class ReadPage /*implements OnDestroy*/ {

ngAfterViewInit() {
this.ngZone.runOutsideAngular(() => {
setTimeout(function () {
let iterationsLeft = 6;
clearInterval(this.intervalTimerId);
this.intervalTimerId = window.setInterval(function() {
try {
const itemId = 'toc_' + this.establishedText.link;
let foundElem = document.getElementById(itemId);
if (foundElem === null) {
// Scroll to toc item without position
foundElem = document.getElementById(itemId.split(';').shift());
if (iterationsLeft < 1) {
clearInterval(this.intervalTimerId);
} else {
iterationsLeft -= 1;
if (this.establishedText && this.establishedText.link) {
const itemId = 'toc_' + this.establishedText.link;
let foundElem = document.getElementById(itemId);
if (foundElem === null || foundElem === undefined) {
// Scroll to toc item without position
foundElem = document.getElementById(itemId.split(';').shift());
}
if (foundElem) {
this.scrollToTOC(foundElem);
clearInterval(this.intervalTimerId);
}
}
}
this.scrollToTOC(foundElem);
} catch (e) {
console.log(e);
console.log('error in setInterval function in PageRead.ngAfterViewInit()', e);
}
}.bind(this), 1000);
}.bind(this), 500);
});
this.setFabBackdropWidth();
}
Expand Down

0 comments on commit 13acd7f

Please sign in to comment.