MDL-73464 book: Scroll to chapter top when navigating through the book

When navigating to the next / previous chapter, the chapter should be
the page element that gets the user's attention and focus. Its title
should be displayed at the prominent top page area without the need to
scroll to it all the time.
This commit is contained in:
David Mudrák 2021-12-29 13:00:45 +01:00 committed by Mathew May
parent d78de537ff
commit b407af725f
2 changed files with 3 additions and 3 deletions

View File

@ -42,12 +42,12 @@
<div class="row"> <div class="row">
{{#previous}} {{#previous}}
<div class="navitem"> <div class="navitem">
<a class="btn btn-secondary" href="{{url}}">{{title}}</a> <a class="btn btn-secondary" href="{{url}}#mod_book-chaptersnavigation">{{title}}</a>
</div> </div>
{{/previous}} {{/previous}}
{{#next}} {{#next}}
<div class="navitem ml-auto"> <div class="navitem ml-auto">
<a class="btn btn-secondary" href="{{url}}">{{title}}</a> <a class="btn btn-secondary" href="{{url}}#mod_book-chaptersnavigation">{{title}}</a>
</div> </div>
{{/next}} {{/next}}
</div> </div>

View File

@ -123,7 +123,7 @@ if (!$chapterid) {
$renderer = $PAGE->get_renderer('mod_book'); $renderer = $PAGE->get_renderer('mod_book');
$actionmenu = new \mod_book\output\main_action_menu($cm->id, $chapters, $chapter, $book); $actionmenu = new \mod_book\output\main_action_menu($cm->id, $chapters, $chapter, $book);
$renderedmenu = $renderer->render($actionmenu); $renderedmenu = $renderer->render($actionmenu);
echo $renderedmenu; echo html_writer::div($renderedmenu, '', ['id' => 'mod_book-chaptersnavigation']);
// The chapter itself. // The chapter itself.
$hidden = $chapter->hidden ? ' dimmed_text' : null; $hidden = $chapter->hidden ? ' dimmed_text' : null;