Skip to content

Commit f2579c2

Browse files
committed
TOC: Fix clickable toggle area
1 parent db23767 commit f2579c2

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

github-toc.user.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,12 @@
2828
/* z-index > 1000 to be above the */
2929
.ghus-toc { position:fixed; z-index:1001; min-width:200px; top:60px; right:10px; }
3030
.ghus-toc h3 { cursor:move; }
31+
.ghus-toc-title { padding-left:20px; }
3132
/* icon toggles TOC container & subgroups */
32-
.ghus-toc h3 svg, .ghus-toc li.collapsible .ghus-toc-icon { cursor:pointer; vertical-align:baseline; }
33+
.ghus-toc .ghus-toc-icon { vertical-align:baseline; }
34+
.ghus-toc h3 .ghus-toc-icon, .ghus-toc li.collapsible .ghus-toc-icon { cursor:pointer; }
35+
.ghus-toc .ghus-toc-toggle { position:absolute; width:28px; height:38px; top:0px; left:0px; }
36+
.ghus-toc .ghus-toc-toggle svg { margin-top:10px; margin-left:9px; }
3337
.ghus-toc .ghus-toc-docs { float:right; }
3438
/* move collapsed TOC to top right corner */
3539
.ghus-toc.collapsed {
@@ -40,7 +44,7 @@
4044
.ghus-toc.collapsed .ghus-toc-docs { display:none; }
4145
.ghus-toc:not(.ghus-toc-hidden).collapsed ~ .js-header-wrapper .Header { padding-right: 48px !important; }
4246
/* move header text out-of-view when collapsed */
43-
.ghus-toc.collapsed > h3 svg { margin-bottom: 10px; }
47+
.ghus-toc.collapsed > h3 svg { margin-top:6px; }
4448
.ghus-toc-hidden, .ghus-toc.collapsed .boxed-group-inner,
4549
.ghus-toc li:not(.collapsible) .ghus-toc-icon { display:none; }
4650
.ghus-toc .boxed-group-inner { max-width:250px; max-height:400px; overflow-y:auto; overflow-x:hidden; }
@@ -253,9 +257,10 @@
253257
group = [];
254258
on(container, "click", event => {
255259
// Allow doc link to work
256-
if (event.target.nodeName.toLowerCase() !== "a") {
257-
stopPropag(event);
260+
if (event.target.nodeName.toLowerCase() === "a") {
261+
return;
258262
}
263+
stopPropag(event);
259264
// click on icon, then target LI parent
260265
let els, name, indx;
261266
const el = event.target.parentNode;
@@ -350,10 +355,12 @@
350355
container.setAttribute("unselectable", "on");
351356
container.innerHTML = `
352357
<h3 class="js-wiki-toggle-collapse wiki-auxiliary-content" data-hotkey="g t">
353-
<svg class="octicon ghus-toc-icon" height="14" width="14" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 16 12">
354-
<path d="M2 13c0 .6 0 1-.6 1H.6c-.6 0-.6-.4-.6-1s0-1 .6-1h.8c.6 0 .6.4.6 1zm2.6-9h6.8c.6 0 .6-.4.6-1s0-1-.6-1H4.6C4 2 4 2.4 4 3s0 1 .6 1zM1.4 7H.6C0 7 0 7.4 0 8s0 1 .6 1h.8C2 9 2 8.6 2 8s0-1-.6-1zm0-5H.6C0 2 0 2.4 0 3s0 1 .6 1h.8C2 4 2 3.6 2 3s0-1-.6-1zm10 5H4.6C4 7 4 7.4 4 8s0 1 .6 1h6.8c.6 0 .6-.4.6-1s0-1-.6-1zm0 5H4.6c-.6 0-.6.4-.6 1s0 1 .6 1h6.8c.6 0 .6-.4.6-1s0-1-.6-1z"/>
355-
</svg>
356-
<span>${title}</span>
358+
<span class="ghus-toc-toggle ghus-toc-icon">
359+
<svg class="octicon" height="14" width="14" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 16 12">
360+
<path d="M2 13c0 .6 0 1-.6 1H.6c-.6 0-.6-.4-.6-1s0-1 .6-1h.8c.6 0 .6.4.6 1zm2.6-9h6.8c.6 0 .6-.4.6-1s0-1-.6-1H4.6C4 2 4 2.4 4 3s0 1 .6 1zM1.4 7H.6C0 7 0 7.4 0 8s0 1 .6 1h.8C2 9 2 8.6 2 8s0-1-.6-1zm0-5H.6C0 2 0 2.4 0 3s0 1 .6 1h.8C2 4 2 3.6 2 3s0-1-.6-1zm10 5H4.6C4 7 4 7.4 4 8s0 1 .6 1h6.8c.6 0 .6-.4.6-1s0-1-.6-1zm0 5H4.6c-.6 0-.6.4-.6 1s0 1 .6 1h6.8c.6 0 .6-.4.6-1s0-1-.6-1z"/>
361+
</svg>
362+
</span>
363+
<span class="ghus-toc-title">${title}</span>
357364
<a class="ghus-toc-docs tooltipped tooltipped-w" aria-label="Go to documentation" href="https://github.com/Mottie/GitHub-userscripts/wiki/GitHub-table-of-contents">
358365
<svg class="octicon" xmlns="http://www.w3.org/2000/svg" height="16" width="14" viewBox="0 0 16 14">
359366
<path d="M6 10h2v2H6V10z m4-3.5c0 2.14-2 2.5-2 2.5H6c0-0.55 0.45-1 1-1h0.5c0.28 0 0.5-0.22 0.5-0.5v-1c0-0.28-0.22-0.5-0.5-0.5h-1c-0.28 0-0.5 0.22-0.5 0.5v0.5H4c0-1.5 1.5-3 3-3s3 1 3 2.5zM7 2.3c3.14 0 5.7 2.56 5.7 5.7S10.14 13.7 7 13.7 1.3 11.14 1.3 8s2.56-5.7 5.7-5.7m0-1.3C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7S10.86 1 7 1z" />

0 commit comments

Comments
 (0)