Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
25d6a6c4
Commit
25d6a6c4
authored
Aug 02, 2017
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stop mobile from showing the sub-items
parent
e67c4a6d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
3 deletions
+51
-3
app/assets/javascripts/fly_out_nav.js
app/assets/javascripts/fly_out_nav.js
+7
-2
spec/javascripts/fly_out_nav_spec.js
spec/javascripts/fly_out_nav_spec.js
+44
-1
No files found.
app/assets/javascripts/fly_out_nav.js
View file @
25d6a6c4
/* global bp */
import
'
./breakpoints
'
;
export
const
canShowSubItems
=
()
=>
bp
.
getBreakpointSize
()
===
'
md
'
||
bp
.
getBreakpointSize
()
===
'
lg
'
;
export
const
calculateTop
=
(
boundingRect
,
outerHeight
)
=>
{
const
windowHeight
=
window
.
innerHeight
;
const
bottomOverflow
=
windowHeight
-
(
boundingRect
.
top
+
outerHeight
);
...
...
@@ -9,7 +14,7 @@ export const calculateTop = (boundingRect, outerHeight) => {
export
const
showSubLevelItems
=
(
el
)
=>
{
const
subItems
=
el
.
querySelector
(
'
.sidebar-sub-level-items
'
);
if
(
!
subItems
)
return
;
if
(
!
subItems
||
!
canShowSubItems
()
)
return
;
subItems
.
style
.
display
=
'
block
'
;
el
.
classList
.
add
(
'
is-over
'
);
...
...
@@ -28,7 +33,7 @@ export const showSubLevelItems = (el) => {
export
const
hideSubLevelItems
=
(
el
)
=>
{
const
subItems
=
el
.
querySelector
(
'
.sidebar-sub-level-items
'
);
if
(
!
subItems
)
return
;
if
(
!
subItems
||
!
canShowSubItems
()
)
return
;
el
.
classList
.
remove
(
'
is-over
'
);
subItems
.
style
.
display
=
'
none
'
;
...
...
spec/javascripts/fly_out_nav_spec.js
View file @
25d6a6c4
/* global bp */
import
{
calculateTop
,
hideSubLevelItems
,
showSubLevelItems
,
canShowSubItems
,
}
from
'
~/fly_out_nav
'
;
describe
(
'
Fly out sidebar navigation
'
,
()
=>
{
let
el
;
let
breakpointSize
=
'
lg
'
;
beforeEach
(()
=>
{
el
=
document
.
createElement
(
'
div
'
);
el
.
style
.
position
=
'
relative
'
;
document
.
body
.
appendChild
(
el
);
spyOn
(
bp
,
'
getBreakpointSize
'
).
and
.
callFake
(()
=>
breakpointSize
);
});
afterEach
(()
=>
{
el
.
remove
();
breakpointSize
=
'
lg
'
;
});
describe
(
'
calculateTop
'
,
()
=>
{
...
...
@@ -53,6 +60,16 @@ describe('Fly out sidebar navigation', () => {
).
toBe
(
'
none
'
);
});
it
(
'
does not hude subitems on mobile
'
,
()
=>
{
breakpointSize
=
'
sm
'
;
hideSubLevelItems
(
el
);
expect
(
el
.
querySelector
(
'
.sidebar-sub-level-items
'
).
style
.
display
,
).
not
.
toBe
(
'
none
'
);
});
it
(
'
removes is-over class
'
,
()
=>
{
spyOn
(
el
.
classList
,
'
remove
'
);
...
...
@@ -103,7 +120,17 @@ describe('Fly out sidebar navigation', () => {
).
toHaveBeenCalledWith
(
'
is-over
'
);
});
it
(
'
shows sub-items
'
,
()
=>
{
it
(
'
does not show sub-items on mobile
'
,
()
=>
{
breakpointSize
=
'
sm
'
;
showSubLevelItems
(
el
);
expect
(
el
.
querySelector
(
'
.sidebar-sub-level-items
'
).
style
.
display
,
).
not
.
toBe
(
'
block
'
);
});
it
(
'
does not shows sub-items
'
,
()
=>
{
showSubLevelItems
(
el
);
expect
(
...
...
@@ -134,4 +161,20 @@ describe('Fly out sidebar navigation', () => {
).
toHaveBeenCalledWith
(
'
is-above
'
);
});
});
describe
(
'
canShowSubItems
'
,
()
=>
{
it
(
'
returns true if on desktop size
'
,
()
=>
{
expect
(
canShowSubItems
(),
).
toBeTruthy
();
});
it
(
'
returns false if on mobile size
'
,
()
=>
{
breakpointSize
=
'
sm
'
;
expect
(
canShowSubItems
(),
).
toBeFalsy
();
});
});
});
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