Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
Bielefeld-CeBiTec-Temp-until-thaw
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package Registry
Model registry
Operate
Terraform modules
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Liliana Sanfilippo
Bielefeld-CeBiTec-Temp-until-thaw
Commits
73b4e8ed
Commit
73b4e8ed
authored
5 months ago
by
Liliana Sanfilippo
Browse files
Options
Downloads
Patches
Plain Diff
engineering pushstate
parent
45eccb2a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/sidebars/engS.tsx
+2
-2
2 additions, 2 deletions
src/sidebars/engS.tsx
src/utils/openThem.ts
+45
-46
45 additions, 46 deletions
src/utils/openThem.ts
with
47 additions
and
48 deletions
src/sidebars/engS.tsx
+
2
−
2
View file @
73b4e8ed
...
...
@@ -31,7 +31,7 @@ export function EngSide(){
<
div
className
=
"sticky-top"
>
<
nav
className
=
"sidebar"
id
=
"eng-sidebar"
>
<
div
>
<
a
onClick
=
{
openThem
({
it
:
"
our-cycle
"
,
scrollToId
:
"
o
urcycle
"
})
}
>
<
a
onClick
=
{
openThem
({
it
:
"
our-cycle
"
,
scrollToId
:
"
O
ur
cycle
"
})
}
>
<
div
className
=
"detail-sideitem"
>
<
div
id
=
"parent-our-cycle"
className
=
"sideitem active-sideitem"
>
<
summary
>
Our Cycle
</
summary
>
...
...
@@ -43,7 +43,7 @@ export function EngSide(){
</
a
>
</
div
>
<
div
>
<
a
onClick
=
{
openThem
({
it
:
"
proof-of-concept
"
})
}
>
<
a
onClick
=
{
openThem
({
it
:
"
proof-of-concept
"
,
scrollToId
:
""
})
}
>
<
div
className
=
"detail-sideitem"
>
<
div
id
=
"parent-proof-of-concept"
className
=
"sideitem"
>
<
summary
>
Proof Of Concept
</
summary
>
...
...
This diff is collapsed.
Click to expand it.
src/utils/openThem.ts
+
45
−
46
View file @
73b4e8ed
export
function
openThem
({
it
,
scrollToId
}:
{
it
:
string
;
scrollToId
?:
string
})
{
const
gotoandopen
=
(
_event
:
React
.
MouseEvent
<
HTMLElement
,
MouseEvent
>
)
=>
{
updateTabs
(
it
,
scrollToId
);
// Update der URL
const
newUrl
=
`?tab=
${
it
}
`
;
window
.
history
.
pushState
({
tab
:
it
},
''
,
newUrl
);
};
const
gotoandopen
=
(
_event
:
React
.
MouseEvent
<
HTMLElement
,
MouseEvent
>
)
=>
{
updateTabs
(
it
,
scrollToId
);
return
gotoandopen
;
}
function
updateTabs
(
it
:
string
,
scrollToId
?:
string
)
{
let
contenttabid
=
"
tab-
"
+
it
;
let
parent
=
"
parent-
"
+
it
;
// Verstecke alle Subtabs und Content-Tabs
const
subtabs
=
document
.
getElementsByClassName
(
"
sidesubtab
"
);
const
contenttabs
=
document
.
getElementsByClassName
(
"
enginneeringtab
"
);
const
sideitems
=
document
.
getElementsByClassName
(
"
sideitem
"
);
for
(
let
i
=
0
;
i
<
subtabs
.
length
;
i
++
)
{
(
subtabs
[
i
]
as
HTMLElement
).
style
.
display
=
"
none
"
;
}
for
(
let
i
=
0
;
i
<
contenttabs
.
length
;
i
++
)
{
(
contenttabs
[
i
]
as
HTMLElement
).
style
.
display
=
"
none
"
;
}
for
(
let
i
=
0
;
i
<
sideitems
.
length
;
i
++
)
{
(
sideitems
[
i
]
as
HTMLElement
)
!
.
classList
.
remove
(
"
active-sideitem
"
);
}
// Zeige den aktuellen Tab und markiere das entsprechende Sidebar-Item
document
.
getElementById
(
it
)
!
.
style
.
display
=
"
block
"
;
document
.
getElementById
(
parent
)
!
.
classList
.
add
(
"
active-sideitem
"
);
document
.
getElementById
(
contenttabid
)
!
.
style
.
display
=
"
block
"
;
// Update der URL
const
newUrl
=
`?tab=
${
it
}
`
;
window
.
history
.
pushState
({
tab
:
it
},
''
,
newUrl
);
};
// Scrolle zu der angegebenen ID, falls vorhanden
if
(
scrollToId
&&
document
.
getElementById
(
scrollToId
))
{
document
.
getElementById
(
scrollToId
)
!
.
scrollIntoView
({
behavior
:
"
smooth
"
});
}
return
gotoandopen
;
}
function
updateTabs
(
it
:
string
,
scrollToId
?:
string
)
{
let
contenttabid
=
"
tab-
"
+
it
;
let
parent
=
"
parent-
"
+
it
;
// Verstecke alle Subtabs und Content-Tabs
const
subtabs
=
document
.
getElementsByClassName
(
"
sidesubtab
"
);
const
contenttabs
=
document
.
getElementsByClassName
(
"
enginneeringtab
"
);
const
sideitems
=
document
.
getElementsByClassName
(
"
sideitem
"
);
for
(
let
i
=
0
;
i
<
subtabs
.
length
;
i
++
)
{
(
subtabs
[
i
]
as
HTMLElement
).
style
.
display
=
"
none
"
;
}
// Füge einen Event Listener für `popstate` hinzu
window
.
addEventListener
(
'
popstate
'
,
(
event
)
=>
{
if
(
event
.
state
)
{
const
tab
=
event
.
state
.
tab
;
updateTabs
(
tab
);
}
});
\ No newline at end of file
for
(
let
i
=
0
;
i
<
contenttabs
.
length
;
i
++
)
{
(
contenttabs
[
i
]
as
HTMLElement
).
style
.
display
=
"
none
"
;
}
for
(
let
i
=
0
;
i
<
sideitems
.
length
;
i
++
)
{
(
sideitems
[
i
]
as
HTMLElement
)
!
.
classList
.
remove
(
"
active-sideitem
"
);
}
// Zeige den aktuellen Tab und markiere das entsprechende Sidebar-Item
document
.
getElementById
(
it
)
!
.
style
.
display
=
"
block
"
;
document
.
getElementById
(
parent
)
!
.
classList
.
add
(
"
active-sideitem
"
);
document
.
getElementById
(
contenttabid
)
!
.
style
.
display
=
"
block
"
;
// Scrolle zu der angegebenen ID, falls vorhanden
if
(
scrollToId
&&
document
.
getElementById
(
scrollToId
))
{
document
.
getElementById
(
scrollToId
)
!
.
scrollIntoView
({
behavior
:
"
smooth
"
});
}
}
// Füge einen Event Listener für `popstate` hinzu
window
.
addEventListener
(
'
popstate
'
,
(
event
)
=>
{
if
(
event
.
state
)
{
const
tab
=
event
.
state
.
tab
;
updateTabs
(
tab
);
}
});
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment