From 474852d59b49b5078ef4c4b78c16b09e09c28643 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=A4=86=E0=A4=AF=E0=A5=81=E0=A4=B7=20=E0=A4=9D=E0=A4=BE?= Date: Mon, 1 Jun 2020 16:25:51 +0545 Subject: [PATCH 1/4] Fix Issue #98 When elements in the table of contents are clicked in readtheorg theme, the children are toggled. --- styles/readtheorg/js/readtheorg.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/styles/readtheorg/js/readtheorg.js b/styles/readtheorg/js/readtheorg.js index 6dff6c4..851e302 100644 --- a/styles/readtheorg/js/readtheorg.js +++ b/styles/readtheorg/js/readtheorg.js @@ -1,3 +1,23 @@ +function collapse_toc_elements_on_click (nav_li_a){ + /* + When an `a' element in the TOC is clicked, it's parent + `li' element's active attribute is toggled. This causes + the element to toggle between minimized and maximized + states. The active attribute is documented in bootstrap. + https://getbootstrap.com/docs/4.0/components/navbar/#nav + */ + $(nav_li_el).parent().toggleClass("active"); +} + +$( document ).ready(function() { + // when the document is loaded and ready, bind the + // function `collapse_toc_elements_on_click' to the + // `a' elements in the table of contents. + $("#text-table-of-contents a").click(function() { + collapse_toc_elements_on_click(this); + }); +}); + $(function() { $('.note').before("

Note

"); $('.seealso').before("

See also

"); From 4f6ad746975957e496fe514f81d7bc2656c3e5d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=A4=86=E0=A4=AF=E0=A5=81=E0=A4=B7=20=E0=A4=9D=E0=A4=BE?= Date: Mon, 1 Jun 2020 17:12:28 +0545 Subject: [PATCH 2/4] fixed name of variable --- styles/readtheorg/js/readtheorg.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/styles/readtheorg/js/readtheorg.js b/styles/readtheorg/js/readtheorg.js index 851e302..7e660b1 100644 --- a/styles/readtheorg/js/readtheorg.js +++ b/styles/readtheorg/js/readtheorg.js @@ -6,7 +6,7 @@ function collapse_toc_elements_on_click (nav_li_a){ states. The active attribute is documented in bootstrap. https://getbootstrap.com/docs/4.0/components/navbar/#nav */ - $(nav_li_el).parent().toggleClass("active"); + $(nav_li_a).parent().toggleClass("active"); } $( document ).ready(function() { From b7ee70b6906f0ec1e136788a38982f0ef44f30d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=A4=86=E0=A4=AF=E0=A5=81=E0=A4=B7=20=E0=A4=9D=E0=A4=BE?= Date: Mon, 1 Jun 2020 18:42:54 +0545 Subject: [PATCH 3/4] Remove active from other classes --- styles/readtheorg/js/readtheorg.js | 1 + 1 file changed, 1 insertion(+) diff --git a/styles/readtheorg/js/readtheorg.js b/styles/readtheorg/js/readtheorg.js index 7e660b1..ae20f65 100644 --- a/styles/readtheorg/js/readtheorg.js +++ b/styles/readtheorg/js/readtheorg.js @@ -7,6 +7,7 @@ function collapse_toc_elements_on_click (nav_li_a){ https://getbootstrap.com/docs/4.0/components/navbar/#nav */ $(nav_li_a).parent().toggleClass("active"); + $("#text-table-of-contents li").removeClass("active"); } $( document ).ready(function() { From f90147f0d690572eabd5dfb619969c9115ad64bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=A4=86=E0=A4=AF=E0=A5=81=E0=A4=B7=20=E0=A4=9D=E0=A4=BE?= Date: Mon, 1 Jun 2020 18:43:12 +0545 Subject: [PATCH 4/4] add active to all the parents, not just one parent --- styles/readtheorg/js/readtheorg.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/styles/readtheorg/js/readtheorg.js b/styles/readtheorg/js/readtheorg.js index ae20f65..213c822 100644 --- a/styles/readtheorg/js/readtheorg.js +++ b/styles/readtheorg/js/readtheorg.js @@ -6,8 +6,8 @@ function collapse_toc_elements_on_click (nav_li_a){ states. The active attribute is documented in bootstrap. https://getbootstrap.com/docs/4.0/components/navbar/#nav */ - $(nav_li_a).parent().toggleClass("active"); $("#text-table-of-contents li").removeClass("active"); + $(nav_li_a).parents().toggleClass("active"); } $( document ).ready(function() {