Skip to content

Commit 87be260

Browse files
committed
updated site
1 parent ac53045 commit 87be260

24 files changed

Lines changed: 5642 additions & 5426 deletions

1.x/sitemap.xml

Lines changed: 5305 additions & 5305 deletions
Large diffs are not rendered by default.

1.x/sitemap.xml.gz

58 Bytes
Binary file not shown.

2.x/docs/en/book.js

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -515,17 +515,39 @@ aria-label="Show hidden lines"></button>';
515515
})();
516516

517517
(function sidebar() {
518-
const body = document.querySelector('body');
519518
const sidebar = document.getElementById('sidebar');
520519
const sidebarLinks = document.querySelectorAll('#sidebar a');
521520
const sidebarToggleButton = document.getElementById('sidebar-toggle');
522-
const sidebarToggleAnchor = document.getElementById('sidebar-toggle-anchor');
523521
const sidebarResizeHandle = document.getElementById('sidebar-resize-handle');
522+
const sidebarCheckbox = document.getElementById('sidebar-toggle-anchor');
524523
let firstContact = null;
525524

525+
526+
/* Because we cannot change the `display` using only CSS after/before the transition, we
527+
need JS to do it. We change the display to prevent the browsers search to find text inside
528+
the collapsed sidebar. */
529+
if (!document.documentElement.classList.contains('sidebar-visible')) {
530+
sidebar.style.display = 'none';
531+
}
532+
sidebar.addEventListener('transitionend', () => {
533+
/* We only change the display to "none" if we're collapsing the sidebar. */
534+
if (!sidebarCheckbox.checked) {
535+
sidebar.style.display = 'none';
536+
}
537+
});
538+
sidebarToggleButton.addEventListener('click', () => {
539+
/* To allow the sidebar expansion animation, we first need to put back the display. */
540+
if (!sidebarCheckbox.checked) {
541+
sidebar.style.display = '';
542+
// Workaround for Safari skipping the animation when changing
543+
// `display` and a transform in the same event loop. This forces a
544+
// reflow after updating the display.
545+
sidebar.offsetHeight;
546+
}
547+
});
548+
526549
function showSidebar() {
527-
body.classList.remove('sidebar-hidden');
528-
body.classList.add('sidebar-visible');
550+
document.documentElement.classList.add('sidebar-visible');
529551
Array.from(sidebarLinks).forEach(function(link) {
530552
link.setAttribute('tabIndex', 0);
531553
});
@@ -539,8 +561,7 @@ aria-label="Show hidden lines"></button>';
539561
}
540562

541563
function hideSidebar() {
542-
body.classList.remove('sidebar-visible');
543-
body.classList.add('sidebar-hidden');
564+
document.documentElement.classList.remove('sidebar-visible');
544565
Array.from(sidebarLinks).forEach(function(link) {
545566
link.setAttribute('tabIndex', -1);
546567
});
@@ -554,8 +575,8 @@ aria-label="Show hidden lines"></button>';
554575
}
555576

556577
// Toggle sidebar
557-
sidebarToggleAnchor.addEventListener('change', function sidebarToggle() {
558-
if (sidebarToggleAnchor.checked) {
578+
sidebarCheckbox.addEventListener('change', function sidebarToggle() {
579+
if (sidebarCheckbox.checked) {
559580
const current_width = parseInt(
560581
document.documentElement.style.getPropertyValue('--sidebar-target-width'), 10);
561582
if (current_width < 150) {
@@ -572,14 +593,14 @@ aria-label="Show hidden lines"></button>';
572593
function initResize() {
573594
window.addEventListener('mousemove', resize, false);
574595
window.addEventListener('mouseup', stopResize, false);
575-
body.classList.add('sidebar-resizing');
596+
document.documentElement.classList.add('sidebar-resizing');
576597
}
577598
function resize(e) {
578599
let pos = e.clientX - sidebar.offsetLeft;
579600
if (pos < 20) {
580601
hideSidebar();
581602
} else {
582-
if (body.classList.contains('sidebar-hidden')) {
603+
if (!document.documentElement.classList.contains('sidebar-visible')) {
583604
showSidebar();
584605
}
585606
pos = Math.min(pos, window.innerWidth - 100);
@@ -588,7 +609,7 @@ aria-label="Show hidden lines"></button>';
588609
}
589610
//on mouseup remove windows functions mousemove & mouseup
590611
function stopResize() {
591-
body.classList.remove('sidebar-resizing');
612+
document.documentElement.classList.remove('sidebar-resizing');
592613
window.removeEventListener('mousemove', resize, false);
593614
window.removeEventListener('mouseup', stopResize, false);
594615
}
@@ -765,7 +786,7 @@ aria-label="Show hidden lines"></button>';
765786
let scrollTop = document.scrollingElement.scrollTop;
766787
let prevScrollTop = scrollTop;
767788
const minMenuY = -menu.clientHeight - 50;
768-
// When the script loads, the page can be at any scroll (e.g. if you reforesh it).
789+
// When the script loads, the page can be at any scroll (e.g. if you refresh it).
769790
menu.style.top = scrollTop + 'px';
770791
// Same as parseInt(menu.style.top.slice(0, -2), but faster
771792
let topCache = menu.style.top.slice(0, -2);

2.x/docs/en/css/chrome.css

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,9 +344,34 @@ mark.fade-out {
344344
max-width: var(--content-max-width);
345345
}
346346

347+
#searchbar-outer.searching #searchbar {
348+
padding-right: 30px;
349+
}
350+
#searchbar-outer .spinner-wrapper {
351+
display: none;
352+
}
353+
#searchbar-outer.searching .spinner-wrapper {
354+
display: block;
355+
}
356+
357+
.search-wrapper {
358+
position: relative;
359+
}
360+
361+
.spinner-wrapper {
362+
--spinner-margin: 2px;
363+
position: absolute;
364+
margin-block-start: calc(var(--searchbar-margin-block-start) + var(--spinner-margin));
365+
right: var(--spinner-margin);
366+
top: 0;
367+
bottom: var(--spinner-margin);
368+
padding: 6px;
369+
background-color: var(--bg);
370+
}
371+
347372
#searchbar {
348373
width: 100%;
349-
margin-block-start: 5px;
374+
margin-block-start: var(--searchbar-margin-block-start);
350375
margin-block-end: 0;
351376
margin-inline-start: auto;
352377
margin-inline-end: auto;
@@ -505,7 +530,6 @@ html:not(.sidebar-resizing) .sidebar {
505530
/* sidebar-hidden */
506531
#sidebar-toggle-anchor:not(:checked) ~ .sidebar {
507532
transform: translateX(calc(0px - var(--sidebar-width) - var(--sidebar-resize-indicator-width)));
508-
z-index: -1;
509533
}
510534
[dir=rtl] #sidebar-toggle-anchor:not(:checked) ~ .sidebar {
511535
transform: translateX(calc(var(--sidebar-width) + var(--sidebar-resize-indicator-width)));

2.x/docs/en/css/general.css

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,12 @@ h6:target::before {
8686
box-sizing: border-box;
8787
background-color: var(--bg);
8888
}
89-
.no-js .page-wrapper,
89+
html:not(.js) .page-wrapper,
9090
.js:not(.sidebar-resizing) .page-wrapper {
9191
transition: margin-left 0.3s ease, transform 0.3s ease; /* Animation: slide away */
9292
}
93-
[dir=rtl] .js:not(.sidebar-resizing) .page-wrapper {
93+
[dir=rtl]:not(.js) .page-wrapper,
94+
[dir=rtl].js:not(.sidebar-resizing) .page-wrapper {
9495
transition: margin-right 0.3s ease, transform 0.3s ease; /* Animation: slide away */
9596
}
9697

2.x/docs/en/css/variables.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
--menu-bar-height: 50px;
1212
--mono-font: "Source Code Pro", Consolas, "Ubuntu Mono", Menlo, "DejaVu Sans Mono", monospace, monospace;
1313
--code-font-size: 0.875em; /* please adjust the ace font size accordingly in editor.js */
14+
--searchbar-margin-block-start: 5px;
1415
}
1516

1617
/* Themes */

2.x/docs/en/searcher.js

Lines changed: 41 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ window.search = window.search || {};
2222
}
2323

2424
const search_wrap = document.getElementById('search-wrapper'),
25+
searchbar_outer = document.getElementById('searchbar-outer'),
2526
searchbar = document.getElementById('searchbar'),
2627
searchresults = document.getElementById('searchresults'),
2728
searchresults_outer = document.getElementById('searchresults-outer'),
@@ -262,6 +263,18 @@ window.search = window.search || {};
262263
doc_urls = config.doc_urls;
263264
searchindex = elasticlunr.Index.load(config.index);
264265

266+
searchbar_outer.classList.remove('searching');
267+
268+
searchbar.focus();
269+
270+
const searchterm = searchbar.value.trim();
271+
if (searchterm !== '') {
272+
searchbar.classList.add('active');
273+
doSearch(searchterm);
274+
}
275+
}
276+
277+
function initSearchInteractions(config) {
265278
// Set up events
266279
searchicon.addEventListener('click', () => {
267280
searchIconClickHandler();
@@ -288,6 +301,8 @@ window.search = window.search || {};
288301
config.hasFocus = hasFocus;
289302
}
290303

304+
initSearchInteractions(window.search);
305+
291306
function unfocusSearchbar() {
292307
// hacky, but just focusing a div only works once
293308
const tmp = document.createElement('input');
@@ -401,8 +416,28 @@ window.search = window.search || {};
401416
}
402417
}
403418

419+
function loadSearchScript(url, id) {
420+
if (document.getElementById(id)) {
421+
return;
422+
}
423+
searchbar_outer.classList.add('searching');
424+
425+
const script = document.createElement('script');
426+
script.src = url;
427+
script.id = id;
428+
script.onload = () => init(window.search);
429+
script.onerror = error => {
430+
console.error(`Failed to load \`${url}\`: ${error}`);
431+
};
432+
document.head.append(script);
433+
}
434+
404435
function showSearch(yes) {
405436
if (yes) {
437+
loadSearchScript(
438+
window.path_to_searchindex_js ||
439+
path_to_root + 'searchindex.js',
440+
'search-index');
406441
search_wrap.classList.remove('hidden');
407442
searchicon.setAttribute('aria-expanded', 'true');
408443
} else {
@@ -485,14 +520,14 @@ window.search = window.search || {};
485520
// Don't search the same twice
486521
if (current_searchterm === searchterm) {
487522
return;
488-
} else {
489-
current_searchterm = searchterm;
490523
}
491-
524+
searchbar_outer.classList.add('searching');
492525
if (searchindex === null) {
493526
return;
494527
}
495528

529+
current_searchterm = searchterm;
530+
496531
// Do the actual search
497532
const results = searchindex.search(searchterm, search_options);
498533
const resultcount = Math.min(results.length, results_options.limit_results);
@@ -511,19 +546,9 @@ window.search = window.search || {};
511546

512547
// Display results
513548
showResults(true);
549+
searchbar_outer.classList.remove('searching');
514550
}
515551

516-
function loadScript(url, id) {
517-
const script = document.createElement('script');
518-
script.src = url;
519-
script.id = id;
520-
script.onload = () => init(window.search);
521-
script.onerror = error => {
522-
console.error(`Failed to load \`${url}\`: ${error}`);
523-
};
524-
document.head.append(script);
525-
}
526-
527-
loadScript(path_to_root + 'searchindex.js', 'search-index');
528-
552+
// Exported functions
553+
search.hasFocus = hasFocus;
529554
})(window.search);

2.x/docs/en/searchindex.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

2.x/docs/ja/book.js

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -515,17 +515,39 @@ aria-label="Show hidden lines"></button>';
515515
})();
516516

517517
(function sidebar() {
518-
const body = document.querySelector('body');
519518
const sidebar = document.getElementById('sidebar');
520519
const sidebarLinks = document.querySelectorAll('#sidebar a');
521520
const sidebarToggleButton = document.getElementById('sidebar-toggle');
522-
const sidebarToggleAnchor = document.getElementById('sidebar-toggle-anchor');
523521
const sidebarResizeHandle = document.getElementById('sidebar-resize-handle');
522+
const sidebarCheckbox = document.getElementById('sidebar-toggle-anchor');
524523
let firstContact = null;
525524

525+
526+
/* Because we cannot change the `display` using only CSS after/before the transition, we
527+
need JS to do it. We change the display to prevent the browsers search to find text inside
528+
the collapsed sidebar. */
529+
if (!document.documentElement.classList.contains('sidebar-visible')) {
530+
sidebar.style.display = 'none';
531+
}
532+
sidebar.addEventListener('transitionend', () => {
533+
/* We only change the display to "none" if we're collapsing the sidebar. */
534+
if (!sidebarCheckbox.checked) {
535+
sidebar.style.display = 'none';
536+
}
537+
});
538+
sidebarToggleButton.addEventListener('click', () => {
539+
/* To allow the sidebar expansion animation, we first need to put back the display. */
540+
if (!sidebarCheckbox.checked) {
541+
sidebar.style.display = '';
542+
// Workaround for Safari skipping the animation when changing
543+
// `display` and a transform in the same event loop. This forces a
544+
// reflow after updating the display.
545+
sidebar.offsetHeight;
546+
}
547+
});
548+
526549
function showSidebar() {
527-
body.classList.remove('sidebar-hidden');
528-
body.classList.add('sidebar-visible');
550+
document.documentElement.classList.add('sidebar-visible');
529551
Array.from(sidebarLinks).forEach(function(link) {
530552
link.setAttribute('tabIndex', 0);
531553
});
@@ -539,8 +561,7 @@ aria-label="Show hidden lines"></button>';
539561
}
540562

541563
function hideSidebar() {
542-
body.classList.remove('sidebar-visible');
543-
body.classList.add('sidebar-hidden');
564+
document.documentElement.classList.remove('sidebar-visible');
544565
Array.from(sidebarLinks).forEach(function(link) {
545566
link.setAttribute('tabIndex', -1);
546567
});
@@ -554,8 +575,8 @@ aria-label="Show hidden lines"></button>';
554575
}
555576

556577
// Toggle sidebar
557-
sidebarToggleAnchor.addEventListener('change', function sidebarToggle() {
558-
if (sidebarToggleAnchor.checked) {
578+
sidebarCheckbox.addEventListener('change', function sidebarToggle() {
579+
if (sidebarCheckbox.checked) {
559580
const current_width = parseInt(
560581
document.documentElement.style.getPropertyValue('--sidebar-target-width'), 10);
561582
if (current_width < 150) {
@@ -572,14 +593,14 @@ aria-label="Show hidden lines"></button>';
572593
function initResize() {
573594
window.addEventListener('mousemove', resize, false);
574595
window.addEventListener('mouseup', stopResize, false);
575-
body.classList.add('sidebar-resizing');
596+
document.documentElement.classList.add('sidebar-resizing');
576597
}
577598
function resize(e) {
578599
let pos = e.clientX - sidebar.offsetLeft;
579600
if (pos < 20) {
580601
hideSidebar();
581602
} else {
582-
if (body.classList.contains('sidebar-hidden')) {
603+
if (!document.documentElement.classList.contains('sidebar-visible')) {
583604
showSidebar();
584605
}
585606
pos = Math.min(pos, window.innerWidth - 100);
@@ -588,7 +609,7 @@ aria-label="Show hidden lines"></button>';
588609
}
589610
//on mouseup remove windows functions mousemove & mouseup
590611
function stopResize() {
591-
body.classList.remove('sidebar-resizing');
612+
document.documentElement.classList.remove('sidebar-resizing');
592613
window.removeEventListener('mousemove', resize, false);
593614
window.removeEventListener('mouseup', stopResize, false);
594615
}
@@ -765,7 +786,7 @@ aria-label="Show hidden lines"></button>';
765786
let scrollTop = document.scrollingElement.scrollTop;
766787
let prevScrollTop = scrollTop;
767788
const minMenuY = -menu.clientHeight - 50;
768-
// When the script loads, the page can be at any scroll (e.g. if you reforesh it).
789+
// When the script loads, the page can be at any scroll (e.g. if you refresh it).
769790
menu.style.top = scrollTop + 'px';
770791
// Same as parseInt(menu.style.top.slice(0, -2), but faster
771792
let topCache = menu.style.top.slice(0, -2);

0 commit comments

Comments
 (0)