Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
SWLab UI
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Jobs
Commits
Open sidebar
SWD
SWLab UI
Commits
d391191c
Commit
d391191c
authored
Oct 21, 2024
by
박민석
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rollback
parent
b34b20f0
Pipeline
#21611
passed with stages
in 3 minutes and 54 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
29 deletions
+18
-29
01-nav.js
src/js/01-nav.js
+18
-29
No files found.
src/js/01-nav.js
View file @
d391191c
...
...
@@ -39,16 +39,16 @@
}
})
document
.
querySelectorAll
(
'.nav-link'
).
forEach
(
function
(
link
)
{
link
.
addEventListener
(
'click'
,
function
(
e
)
{
e
.
preventDefault
()
// 기본 링크 동작 방지
var
parentToggle
=
link
.
closest
(
'.nav-item'
).
querySelector
(
'.nav-item-toggle'
)
if
(
parentToggle
)
{
parentToggle
.
click
()
// 트리 토글
}
window
.
location
.
href
=
link
.
href
// 첫 번째 링크로 이동
})
})
//
document.querySelectorAll('.nav-link').forEach(function (link) {
//
link.addEventListener('click', function (e) {
//
e.preventDefault() // 기본 링크 동작 방지
//
var parentToggle = link.closest('.nav-item').querySelector('.nav-item-toggle')
//
if (parentToggle) {
//
parentToggle.click() // 트리 토글
//
}
//
window.location.href = link.href // 첫 번째 링크로 이동
//
})
//
})
if
(
navMenuToggle
&&
menuPanel
.
querySelector
(
'.nav-item-toggle'
))
{
navMenuToggle
.
style
.
display
=
''
...
...
@@ -120,6 +120,7 @@
}
}
var
navItem
console
.
log
(
navLink
)
if
(
navLink
)
{
navItem
=
navLink
.
parentNode
}
else
if
(
originalPageItem
)
{
...
...
@@ -127,25 +128,13 @@
}
else
{
return
}
// if (navItem === currentPageItem) return
// find(menuPanel, '.nav-item.is-active').forEach(function (el) {
// el.classList.remove('is-active', 'is-current-path', 'is-current-page')
// })
// navItem.classList.add('is-current-page')
// currentPageItem = navItem
// activateCurrentPath(navItem)
// 중복 펼침 방지
if
(
!
navItem
.
classList
.
contains
(
'is-current-page'
))
{
find
(
menuPanel
,
'.nav-item.is-active'
).
forEach
(
function
(
el
)
{
el
.
classList
.
remove
(
'is-active'
,
'is-current-path'
,
'is-current-page'
)
})
navItem
.
classList
.
add
(
'is-current-page'
)
currentPageItem
=
navItem
activateCurrentPath
(
navItem
)
}
if
(
navItem
===
currentPageItem
)
return
find
(
menuPanel
,
'.nav-item.is-active'
).
forEach
(
function
(
el
)
{
el
.
classList
.
remove
(
'is-active'
,
'is-current-path'
,
'is-current-page'
)
})
navItem
.
classList
.
add
(
'is-current-page'
)
currentPageItem
=
navItem
activateCurrentPath
(
navItem
)
scrollItemToMidpoint
(
menuPanel
,
navLink
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment