Fix current chapter mark in chapter index modal

This commit is contained in:
Tetrakern 2024-10-18 16:13:35 +02:00
parent aa55620fc4
commit 15131f9bf8
5 changed files with 6 additions and 5 deletions

View File

@ -1376,7 +1376,7 @@ function fictioneer_get_chapter_index_html( $story_id ) {
$back_link = '<a href="' . esc_url( $story_link ) . '" class="chapter-index__back-link"><i class="fa-solid fa-caret-left"></i> <span>' . __( 'Back to Story', 'fictioneer' ) . '</span></a>';
$html = '<div class="chapter-index" data-order="asc" data-story-id="' . $story_id . '" data-current-id="' . get_the_ID() . '"><div class="chapter-index__control">' . $back_link . '<div class="chapter-index__sof">' . $toggle . '</div></div><ul id="chapter-index-list" class="chapter-index__list">' . implode( '', $items ) . '</ul></div>';
$html = '<div class="chapter-index" data-order="asc" data-story-id="' . $story_id . '"><div class="chapter-index__control">' . $back_link . '<div class="chapter-index__sof">' . $toggle . '</div></div><ul id="chapter-index-list" class="chapter-index__list">' . implode( '', $items ) . '</ul></div>';
$html = apply_filters( 'fictioneer_filter_chapter_index_html', $html, $items, $story_id, $story_link );

View File

@ -465,7 +465,7 @@ add_action( 'fictioneer_chapter_actions_bottom_center', 'fictioneer_chapter_inde
function fictioneer_render_chapter_index_modal_html( $story_id ) {
// Start HTML ---> ?>
<dialog class="dialog-modal _chapter-index" id="fictioneer-chapter-index-dialog">
<dialog class="dialog-modal _chapter-index" id="fictioneer-chapter-index-dialog" data-post-id="<?php the_ID(); ?>">
<div class="dialog-modal__wrapper">
<button class="dialog-modal__close" data-click-action="close-dialog-modal" aria-label="<?php esc_attr_e( 'Close modal', 'fictioneer' ); ?>"><?php fictioneer_icon( 'fa-xmark' ); ?></button>
<div class="dialog-modal__header"><?php _ex( 'Chapter Index', 'Chapter index modal header.', 'fictioneer' ); ?></div>

2
js/chapter.min.js vendored

File diff suppressed because one or more lines are too long

2
js/complete.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -1261,9 +1261,10 @@ _$('[data-click-action*="toggle-chapter-index-order"]')?.addEventListener('click
document.addEventListener('DOMContentLoaded', () => {
const chapterIndex = _$('.chapter-index');
const postId = chapterIndex.closest('dialog').dataset.postId ?? 0;
if (chapterIndex) {
chapterIndex.querySelector(`[data-id="${chapterIndex.dataset.currentId}"]`)?.classList.add('current');
chapterIndex.querySelector(`[data-id="${postId}"]`)?.classList.add('current');
}
});