texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

branch master updated: * js/info.js (updater.navigate): Relative movemen


From: Per Bothner
Subject: branch master updated: * js/info.js (updater.navigate): Relative movement without node links.
Date: Tue, 04 May 2021 12:30:41 -0400

This is an automated email from the git hooks/post-receive script.

bothner pushed a commit to branch master
in repository texinfo.

The following commit(s) were added to refs/heads/master by this push:
     new 5231b32  * js/info.js (updater.navigate): Relative movement without 
node links.
5231b32 is described below

commit 5231b32a82a74059822d3ac0c5098de97c02bfd3
Author: Per Bothner <per@bothner.com>
AuthorDate: Tue May 4 09:30:15 2021 -0700

    * js/info.js (updater.navigate): Relative movement without node links.
    
    For example if the current item is a @subsection without a @node,
    requesting the 'next' item can't use the Next link as there is none.
    Instead, use the nesting in the sidebar ToC.
---
 ChangeLog  |  5 +++++
 js/info.js | 26 ++++++++++++++++++++++++++
 2 files changed, 31 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index a78f339..d63be26 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2021-05-04  Per Bothner  <per@bothner.com>
 
+       * js/info.js (updater.navigate): Relative movement without node links.
+       For example if the current item is a @subsection without a @node,
+       requesting the 'next' item can't use the Next link as there is none.
+       Instead, use the nesting in the sidebar ToC.
+
        * js/info.js: Use keydown event handler instead of keyup.
        The former is more standard.
 
diff --git a/js/info.js b/js/info.js
index 3e311e2..4198a9e 100644
--- a/js/info.js
+++ b/js/info.js
@@ -288,6 +288,32 @@
           linkid = ids[action.direction];
           if (!linkid)
             {
+              // Look for sibling link in ToC.
+              // Needed for (say) @subsection without corresponding @node.
+              let toc_current =
+                document.querySelector ('#slider a[toc-current="yes"]');
+              if (toc_current)
+                {
+                  let item_current = toc_current.parentNode; // 'li' element
+                  let nlink = (action.direction === "next"
+                               ? item_current.nextElementSibling
+                               : action.direction === "prev"
+                               ? item_current.previousElementSibling
+                               : action.direction === "up"
+                               ? item_current.parentNode.parentNode
+                               : null);
+                  if (nlink)
+                    nlink = nlink.firstElementChild;
+                  if (nlink && nlink.matches("a"))
+                    {
+                      let href = link_href (nlink)
+                      if (href)
+                        linkid = href_hash (href) ;
+                    }
+                }
+            }
+          if (!linkid)
+            {
               /* When CURRENT is in index but doesn't have the requested
                  direction, ask its corresponding 'pageid'.  */
               var is_index_ref =



reply via email to

[Prev in Thread] Current Thread [Next in Thread]