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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
acc5eed3
Commit
acc5eed3
authored
Dec 19, 2019
by
Martin Wortschack
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace breakpoints with GlBreakpointInstance
parent
41537027
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
9 deletions
+8
-9
app/assets/javascripts/contextual_sidebar.js
app/assets/javascripts/contextual_sidebar.js
+8
-9
No files found.
app/assets/javascripts/contextual_sidebar.js
View file @
acc5eed3
import
$
from
'
jquery
'
;
import
Cookies
from
'
js-cookie
'
;
import
_
from
'
underscore
'
;
import
bp
from
'
./breakpoint
s
'
;
import
{
GlBreakpointInstance
as
bp
,
breakpoints
}
from
'
@gitlab/ui/dist/util
s
'
;
import
{
parseBoolean
}
from
'
~/lib/utils/common_utils
'
;
// NOTE: at 1200px nav sidebar should not overlap the content
// https://gitlab.com/gitlab-org/gitlab-foss/merge_requests/24555#note_134136110
const
NAV_SIDEBAR_BREAKPOINT
=
1200
;
export
const
SIDEBAR_COLLAPSED_CLASS
=
'
js-sidebar-collapsed
'
;
export
default
class
ContextualSidebar
{
...
...
@@ -50,9 +46,10 @@ export default class ContextualSidebar {
$
(
window
).
on
(
'
resize
'
,
()
=>
_
.
debounce
(
this
.
render
(),
100
));
}
// TODO: use the breakpoints from breakpoints.js once they have been updated for bootstrap 4
// See documentation: https://design.gitlab.com/regions/navigation#contextual-navigation
static
isDesktopBreakpoint
=
()
=>
bp
.
windowWidth
()
>=
NAV_SIDEBAR_BREAKPOINT
;
// NOTE: at 1200px nav sidebar should not overlap the content
// https://gitlab.com/gitlab-org/gitlab-foss/merge_requests/24555#note_134136110
static
isDesktopBreakpoint
=
()
=>
bp
.
windowWidth
()
>=
breakpoints
.
xl
;
static
setCollapsedCookie
(
value
)
{
if
(
!
ContextualSidebar
.
isDesktopBreakpoint
())
{
return
;
...
...
@@ -63,12 +60,13 @@ export default class ContextualSidebar {
toggleSidebarNav
(
show
)
{
const
breakpoint
=
bp
.
getBreakpointSize
();
const
dbp
=
ContextualSidebar
.
isDesktopBreakpoint
();
const
supportedSizes
=
[
'
xs
'
,
'
sm
'
,
'
md
'
];
this
.
$sidebar
.
toggleClass
(
SIDEBAR_COLLAPSED_CLASS
,
!
show
);
this
.
$sidebar
.
toggleClass
(
'
sidebar-expanded-mobile
'
,
!
dbp
?
show
:
false
);
this
.
$overlay
.
toggleClass
(
'
mobile-nav-open
'
,
breakpoint
===
'
xs
'
||
breakpoint
===
'
sm
'
?
show
:
false
,
supportedSizes
.
includes
(
breakpoint
)
?
show
:
false
,
);
this
.
$sidebar
.
removeClass
(
'
sidebar-collapsed-desktop
'
);
}
...
...
@@ -76,13 +74,14 @@ export default class ContextualSidebar {
toggleCollapsedSidebar
(
collapsed
,
saveCookie
)
{
const
breakpoint
=
bp
.
getBreakpointSize
();
const
dbp
=
ContextualSidebar
.
isDesktopBreakpoint
();
const
supportedSizes
=
[
'
xs
'
,
'
sm
'
,
'
md
'
];
if
(
this
.
$sidebar
.
length
)
{
this
.
$sidebar
.
toggleClass
(
`sidebar-collapsed-desktop
${
SIDEBAR_COLLAPSED_CLASS
}
`
,
collapsed
);
this
.
$sidebar
.
toggleClass
(
'
sidebar-expanded-mobile
'
,
!
dbp
?
!
collapsed
:
false
);
this
.
$page
.
toggleClass
(
'
page-with-icon-sidebar
'
,
breakpoint
===
'
xs
'
||
breakpoint
===
'
sm
'
?
true
:
collapsed
,
supportedSizes
.
includes
(
breakpoint
)
?
true
:
collapsed
,
);
}
...
...
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