Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
toc_js
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
toc_js
Merge requests
!25
Issue
#3212033
by mably: Collapsible children items
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Issue
#3212033
by mably: Collapsible children items
issue/toc_js-3212033:3212033-collapsible-children-items
into
3.0.x
Overview
0
Commits
1
Pipelines
11
Changes
7
Merged
Frank Mably
requested to merge
issue/toc_js-3212033:3212033-collapsible-children-items
into
3.0.x
9 months ago
Overview
0
Commits
1
Pipelines
11
Changes
7
Expand
Closes
#3212033
0
0
Merge request reports
Compare
3.0.x
version 10
c04fdc98
9 months ago
version 9
c722ae43
9 months ago
version 8
71013d8b
9 months ago
version 7
62ceb7e4
9 months ago
version 6
c10835a0
9 months ago
version 5
160737d5
9 months ago
version 4
230c15e2
9 months ago
version 3
58c5618d
9 months ago
version 2
f7894088
9 months ago
version 1
01b78bd4
9 months ago
3.0.x (base)
and
latest version
latest version
bcfdcc04
1 commit,
9 months ago
version 10
c04fdc98
1 commit,
9 months ago
version 9
c722ae43
1 commit,
9 months ago
version 8
71013d8b
1 commit,
9 months ago
version 7
62ceb7e4
1 commit,
9 months ago
version 6
c10835a0
1 commit,
9 months ago
version 5
160737d5
1 commit,
9 months ago
version 4
230c15e2
1 commit,
9 months ago
version 3
58c5618d
1 commit,
9 months ago
version 2
f7894088
1 commit,
9 months ago
version 1
01b78bd4
1 commit,
9 months ago
7 files
+
100
−
2
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
7
Search (e.g. *.vue) (Ctrl+P)
assets/js/tocjs.js
+
24
−
1
Options
@@ -339,8 +339,28 @@
currentList
.
appendChild
(
li
);
lastLi
=
li
;
}
else
if
(
level
>
currentLevel
)
{
currentLevel
=
level
;
const
ul
=
document
.
createElement
(
opts
.
listType
);
if
(
currentLevel
>
0
&&
opts
.
collapsibleItems
)
{
ul
.
classList
.
add
(
'
collapsible
'
);
const
expanded
=
opts
.
collapsibleExpanded
;
lastLi
.
role
=
'
button
'
;
lastLi
.
tabIndex
=
0
;
lastLi
.
setAttribute
(
'
aria-label
'
,
expanded
?
'
Collapse
'
:
'
Expand
'
);
lastLi
.
setAttribute
(
'
aria-expanded
'
,
expanded
?
'
true
'
:
'
false
'
);
lastLi
.
addEventListener
(
'
click
'
,
function
toggleCollapse
(
e
)
{
if
(
e
.
target
===
this
)
{
const
isExpanded
=
this
.
getAttribute
(
'
aria-expanded
'
)
===
'
true
'
;
this
.
setAttribute
(
'
aria-expanded
'
,
!
isExpanded
);
}
});
lastLi
.
addEventListener
(
'
keydown
'
,
function
toggleCollapse
(
e
)
{
if
(
e
.
key
===
'
Enter
'
||
e
.
key
===
'
'
)
{
e
.
preventDefault
();
// Prevent space from scrolling the page
this
.
click
();
}
});
}
currentLevel
=
level
;
ul
.
level
=
level
;
ul
.
appendChild
(
li
);
lastLi
.
appendChild
(
ul
);
@@ -670,7 +690,10 @@
highlightOffset
:
0
,
skipInvisibleHeadings
:
false
,
useHeadingHtml
:
false
,
collapsibleItems
:
false
,
collapsibleExpanded
:
true
,
backToTop
:
false
,
backToTopLabel
:
'
Back to top
'
,
headingFocus
:
false
,
backToToc
:
false
,
tocContainer
:
''
,
Loading