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
8dccc22a
Commit
8dccc22a
authored
Jun 18, 2020
by
Mike Greiling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move collapse sidebar on resize behavior
parent
1fbf76cc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
36 deletions
+44
-36
app/assets/javascripts/behaviors/collapse_sidebar_on_window_resize.js
...avascripts/behaviors/collapse_sidebar_on_window_resize.js
+41
-0
app/assets/javascripts/behaviors/index.js
app/assets/javascripts/behaviors/index.js
+2
-0
app/assets/javascripts/main.js
app/assets/javascripts/main.js
+1
-36
No files found.
app/assets/javascripts/behaviors/collapse_sidebar_on_window_resize.js
0 → 100644
View file @
8dccc22a
import
$
from
'
jquery
'
;
import
{
GlBreakpointInstance
as
bp
}
from
'
@gitlab/ui/dist/utils
'
;
/**
* This behavior collapses the right sidebar
* if the window size changes
*
* @sentrify
*/
export
default
()
=>
{
const
$sidebarGutterToggle
=
$
(
'
.js-sidebar-toggle
'
);
let
bootstrapBreakpoint
=
bp
.
getBreakpointSize
();
$
(
window
).
on
(
'
resize.app
'
,
()
=>
{
const
oldBootstrapBreakpoint
=
bootstrapBreakpoint
;
bootstrapBreakpoint
=
bp
.
getBreakpointSize
();
if
(
bootstrapBreakpoint
!==
oldBootstrapBreakpoint
)
{
const
breakpointSizes
=
[
'
md
'
,
'
sm
'
,
'
xs
'
];
if
(
breakpointSizes
.
includes
(
bootstrapBreakpoint
))
{
const
$gutterIcon
=
$sidebarGutterToggle
.
find
(
'
i
'
);
if
(
$gutterIcon
.
hasClass
(
'
fa-angle-double-right
'
))
{
$sidebarGutterToggle
.
trigger
(
'
click
'
);
}
const
sidebarGutterVueToggleEl
=
document
.
querySelector
(
'
.js-sidebar-vue-toggle
'
);
// Sidebar has an icon which corresponds to collapsing the sidebar
// only then trigger the click.
if
(
sidebarGutterVueToggleEl
)
{
const
collapseIcon
=
sidebarGutterVueToggleEl
.
querySelector
(
'
i.fa-angle-double-right
'
);
if
(
collapseIcon
)
{
collapseIcon
.
click
();
}
}
}
}
});
};
app/assets/javascripts/behaviors/index.js
View file @
8dccc22a
...
...
@@ -11,9 +11,11 @@ import './requires_input';
import
initPageShortcuts
from
'
./shortcuts
'
;
import
'
./toggler_behavior
'
;
import
'
./preview_markdown
'
;
import
initCollapseSidebarOnWindowResize
from
'
./collapse_sidebar_on_window_resize
'
;
installGlEmojiElement
();
initGFMInput
();
initCopyAsGFM
();
initCopyToClipboard
();
initPageShortcuts
();
initCollapseSidebarOnWindowResize
();
app/assets/javascripts/main.js
View file @
8dccc22a
...
...
@@ -179,9 +179,7 @@ function deferredInitialisation() {
document
.
addEventListener
(
'
DOMContentLoaded
'
,
()
=>
{
const
$body
=
$
(
'
body
'
);
const
$document
=
$
(
document
);
const
$window
=
$
(
window
);
const
$sidebarGutterToggle
=
$
(
'
.js-sidebar-toggle
'
);
let
bootstrapBreakpoint
=
bp
.
getBreakpointSize
();
const
bootstrapBreakpoint
=
bp
.
getBreakpointSize
();
if
(
document
.
querySelector
(
'
#js-peek
'
))
initPerformanceBar
({
container
:
'
#js-peek
'
});
...
...
@@ -290,39 +288,6 @@ document.addEventListener('DOMContentLoaded', () => {
$
(
document
).
trigger
(
'
toggle.comments
'
);
});
$document
.
on
(
'
breakpoint:change
'
,
(
e
,
breakpoint
)
=>
{
const
breakpointSizes
=
[
'
md
'
,
'
sm
'
,
'
xs
'
];
if
(
breakpointSizes
.
includes
(
breakpoint
))
{
const
$gutterIcon
=
$sidebarGutterToggle
.
find
(
'
i
'
);
if
(
$gutterIcon
.
hasClass
(
'
fa-angle-double-right
'
))
{
$sidebarGutterToggle
.
trigger
(
'
click
'
);
}
const
sidebarGutterVueToggleEl
=
document
.
querySelector
(
'
.js-sidebar-vue-toggle
'
);
// Sidebar has an icon which corresponds to collapsing the sidebar
// only then trigger the click.
if
(
sidebarGutterVueToggleEl
)
{
const
collapseIcon
=
sidebarGutterVueToggleEl
.
querySelector
(
'
i.fa-angle-double-right
'
);
if
(
collapseIcon
)
{
collapseIcon
.
click
();
}
}
}
});
function
fitSidebarForSize
()
{
const
oldBootstrapBreakpoint
=
bootstrapBreakpoint
;
bootstrapBreakpoint
=
bp
.
getBreakpointSize
();
if
(
bootstrapBreakpoint
!==
oldBootstrapBreakpoint
)
{
$document
.
trigger
(
'
breakpoint:change
'
,
[
bootstrapBreakpoint
]);
}
}
$window
.
on
(
'
resize.app
'
,
fitSidebarForSize
);
$
(
'
form.filter-form
'
).
on
(
'
submit
'
,
function
filterFormSubmitCallback
(
event
)
{
const
link
=
document
.
createElement
(
'
a
'
);
link
.
href
=
this
.
action
;
...
...
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