FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Source.Python/docs/_static/sidebar.js at master · Source-Python-Dev-Team/Source.Python · GitHub
Source-Python-Dev-Team
Source.Python
Repository navigation
Code
Issues
9
(9)
Pull requests
11
(11)
Discussions
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
Source.Python
/
docs
/
_static
/
sidebar.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
64 lines (52 loc) · 2.34 KB
Breadcrumbs
Source.Python
/
docs
/
_static
/
sidebar.js
Copy path
File metadata and controls
64 lines (52 loc) · 2.34 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
* This script makes the Sphinx sidebar collapsible.
*
* .sphinxsidebar contains .sphinxsidebarwrapper. This script adds
* in .sphixsidebar, after .sphinxsidebarwrapper, the #sidebarbutton
* used to collapse and expand the sidebar.
*
* When the sidebar is collapsed the .sphinxsidebarwrapper is hidden
* and the width of the sidebar and the margin-left of the document
* are decreased. When the sidebar is expanded the opposite happens.
* This script saves a per-browser/per-session cookie used to
* remember the position of the sidebar among the pages.
* Once the browser is closed the cookie is deleted and the position
* reset to the default (expanded).
*
*/
const
initialiseSidebar
=
(
)
=>
{
// global elements used by the functions.
const
bodyWrapper
=
document
.
getElementsByClassName
(
"bodywrapper"
)
[
0
]
const
sidebar
=
document
.
getElementsByClassName
(
"sphinxsidebar"
)
[
0
]
const
sidebarWrapper
=
document
.
getElementsByClassName
(
'sphinxsidebarwrapper'
)
[
0
]
const
sidebarButton
=
document
.
getElementById
(
"sidebarbutton"
)
const
sidebarArrow
=
sidebarButton
.
querySelector
(
'span'
)
// for some reason, the document has no sidebar; do not run into errors
if
(
typeof
sidebar
===
"undefined"
)
return
;
const
flipArrow
=
element
=>
element
.
innerText
=
(
element
.
innerText
===
"»"
)
?
"«"
:
"»"
const
collapse_sidebar
=
(
)
=>
{
bodyWrapper
.
style
.
marginLeft
=
".8em"
;
sidebar
.
style
.
width
=
".8em"
sidebarWrapper
.
style
.
display
=
"none"
flipArrow
(
sidebarArrow
)
sidebarButton
.
title
=
_
(
'Expand sidebar'
)
window
.
localStorage
.
setItem
(
"sidebar"
,
"collapsed"
)
}
const
expand_sidebar
=
(
)
=>
{
bodyWrapper
.
style
.
marginLeft
=
""
sidebar
.
style
.
removeProperty
(
"width"
)
sidebarWrapper
.
style
.
display
=
""
flipArrow
(
sidebarArrow
)
sidebarButton
.
title
=
_
(
'Collapse sidebar'
)
window
.
localStorage
.
setItem
(
"sidebar"
,
"expanded"
)
}
sidebarButton
.
addEventListener
(
"click"
,
(
)
=>
{
(
sidebarWrapper
.
style
.
display
===
"none"
)
?
expand_sidebar
(
)
:
collapse_sidebar
(
)
}
)
if
(
!
window
.
localStorage
.
getItem
(
"sidebar"
)
)
return
const
value
=
window
.
localStorage
.
getItem
(
"sidebar"
)
if
(
value
===
"collapsed"
)
collapse_sidebar
(
)
;
else
if
(
value
===
"expanded"
)
expand_sidebar
(
)
;
}
if
(
document
.
readyState
!==
"loading"
)
initialiseSidebar
(
)
else
document
.
addEventListener
(
"DOMContentLoaded"
,
initialiseSidebar
)
Back
|
FazBrowse Home
|
New Git URL