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
Boxiang Sun
gitlab-ce
Commits
728be6af
Commit
728be6af
authored
Jun 18, 2017
by
Bryce Johnson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make setSidebarHeight more efficient with SidebarHeightManager.
parent
1a449b24
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
46 deletions
+38
-46
app/assets/javascripts/issuable_bulk_update_sidebar.js
app/assets/javascripts/issuable_bulk_update_sidebar.js
+2
-24
app/assets/javascripts/right_sidebar.js
app/assets/javascripts/right_sidebar.js
+3
-22
app/assets/javascripts/sidebar_height_manager.js
app/assets/javascripts/sidebar_height_manager.js
+33
-0
No files found.
app/assets/javascripts/issuable_bulk_update_sidebar.js
View file @
728be6af
...
...
@@ -5,6 +5,7 @@
/* global SubscriptionSelect */
import
IssuableBulkUpdateActions
from
'
./issuable_bulk_update_actions
'
;
import
SidebarHeightManager
from
'
./sidebar_height_manager
'
;
const
HIDDEN_CLASS
=
'
hidden
'
;
const
DISABLED_CONTENT_CLASS
=
'
disabled-content
'
;
...
...
@@ -56,18 +57,6 @@ export default class IssuableBulkUpdateSidebar {
return
navbarHeight
+
layoutNavHeight
+
subNavScroll
;
}
initSidebar
()
{
if
(
!
this
.
navHeight
)
{
this
.
navHeight
=
this
.
getNavHeight
();
}
if
(
!
this
.
sidebarInitialized
)
{
$
(
document
).
off
(
'
scroll
'
).
on
(
'
scroll
'
,
_
.
throttle
(
this
.
setSidebarHeight
,
10
).
bind
(
this
));
$
(
window
).
off
(
'
resize
'
).
on
(
'
resize
'
,
_
.
throttle
(
this
.
setSidebarHeight
,
10
).
bind
(
this
));
this
.
sidebarInitialized
=
true
;
}
}
setupBulkUpdateActions
()
{
IssuableBulkUpdateActions
.
setOriginalDropdownData
();
}
...
...
@@ -97,7 +86,7 @@ export default class IssuableBulkUpdateSidebar {
this
.
toggleCheckboxDisplay
(
enable
);
if
(
enable
)
{
this
.
initSidebar
();
SidebarHeightManager
.
init
();
}
}
...
...
@@ -143,17 +132,6 @@ export default class IssuableBulkUpdateSidebar {
this
.
$bulkEditSubmitBtn
.
enable
();
}
}
// loosely based on method of the same name in right_sidebar.js
setSidebarHeight
()
{
const
currentScrollDepth
=
window
.
pageYOffset
||
0
;
const
diff
=
this
.
navHeight
-
currentScrollDepth
;
if
(
diff
>
0
)
{
this
.
$sidebar
.
outerHeight
(
window
.
innerHeight
-
diff
);
}
else
{
this
.
$sidebar
.
outerHeight
(
'
100%
'
);
}
}
static
getCheckedIssueIds
()
{
const
$checkedIssues
=
$
(
'
.selected_issue:checked
'
);
...
...
app/assets/javascripts/right_sidebar.js
View file @
728be6af
/* eslint-disable func-names, space-before-function-paren, no-var, prefer-rest-params, wrap-iife, no-unused-vars, consistent-return, one-var, one-var-declaration-per-line, quotes, prefer-template, object-shorthand, comma-dangle, no-else-return, no-param-reassign, max-len */
import
Cookies
from
'
js-cookie
'
;
import
SidebarHeightManager
from
'
./sidebar_height_manager
'
;
(
function
()
{
this
.
Sidebar
=
(
function
()
{
...
...
@@ -8,12 +9,6 @@ import Cookies from 'js-cookie';
this
.
toggleTodo
=
this
.
toggleTodo
.
bind
(
this
);
this
.
sidebar
=
$
(
'
aside
'
);
this
.
$sidebarInner
=
this
.
sidebar
.
find
(
'
.issuable-sidebar
'
);
this
.
$navGitlab
=
$
(
'
.navbar-gitlab
'
);
this
.
$layoutNav
=
$
(
'
.layout-nav
'
);
this
.
$subScroll
=
$
(
'
.sub-nav-scroll
'
);
this
.
$rightSidebar
=
$
(
'
.js-right-sidebar
'
);
this
.
removeListeners
();
this
.
addEventListeners
();
}
...
...
@@ -27,16 +22,14 @@ import Cookies from 'js-cookie';
};
Sidebar
.
prototype
.
addEventListeners
=
function
()
{
SidebarHeightManager
.
init
();
const
$document
=
$
(
document
);
const
throttledSetSidebarHeight
=
_
.
throttle
(
this
.
setSidebarHeight
.
bind
(
this
),
20
);
const
slowerThrottledSetSidebarHeight
=
_
.
throttle
(
this
.
setSidebarHeight
.
bind
(
this
),
200
);
this
.
sidebar
.
on
(
'
click
'
,
'
.sidebar-collapsed-icon
'
,
this
,
this
.
sidebarCollapseClicked
);
$
(
'
.dropdown
'
).
on
(
'
hidden.gl.dropdown
'
,
this
,
this
.
onSidebarDropdownHidden
);
$
(
'
.dropdown
'
).
on
(
'
loading.gl.dropdown
'
,
this
.
sidebarDropdownLoading
);
$
(
'
.dropdown
'
).
on
(
'
loaded.gl.dropdown
'
,
this
.
sidebarDropdownLoaded
);
$
(
window
).
on
(
'
resize
'
,
()
=>
throttledSetSidebarHeight
());
$document
.
on
(
'
scroll
'
,
()
=>
slowerThrottledSetSidebarHeight
());
$document
.
on
(
'
click
'
,
'
.js-sidebar-toggle
'
,
function
(
e
,
triggered
)
{
var
$allGutterToggleIcons
,
$this
,
$thisIcon
;
e
.
preventDefault
();
...
...
@@ -214,18 +207,6 @@ import Cookies from 'js-cookie';
}
};
Sidebar
.
prototype
.
setSidebarHeight
=
function
()
{
const
$navHeight
=
this
.
$navGitlab
.
outerHeight
()
+
this
.
$layoutNav
.
outerHeight
()
+
(
this
.
$subScroll
?
this
.
$subScroll
.
outerHeight
()
:
0
);
const
diff
=
$navHeight
-
$
(
window
).
scrollTop
();
if
(
diff
>
0
)
{
this
.
$rightSidebar
.
outerHeight
(
$
(
window
).
height
()
-
diff
);
this
.
$sidebarInner
.
height
(
'
100%
'
);
}
else
{
this
.
$rightSidebar
.
outerHeight
(
'
100%
'
);
this
.
$sidebarInner
.
height
(
''
);
}
};
Sidebar
.
prototype
.
isOpen
=
function
()
{
return
this
.
sidebar
.
is
(
'
.right-sidebar-expanded
'
);
};
...
...
app/assets/javascripts/sidebar_height_manager.js
0 → 100644
View file @
728be6af
export
default
{
init
()
{
if
(
!
this
.
initialized
)
{
this
.
$window
=
$
(
window
);
this
.
$rightSidebar
=
$
(
'
.js-right-sidebar
'
);
this
.
$navHeight
=
$
(
'
.navbar-gitlab
'
).
outerHeight
()
+
$
(
'
.layout-nav
'
).
outerHeight
()
+
$
(
'
.sub-nav-scroll
'
).
outerHeight
();
const
throttledSetSidebarHeight
=
_
.
throttle
(()
=>
this
.
setSidebarHeight
(),
20
);
const
debouncedSetSidebarHeight
=
_
.
debounce
(()
=>
this
.
setSidebarHeight
(),
200
);
this
.
$window
.
on
(
'
scroll
'
,
throttledSetSidebarHeight
);
this
.
$window
.
on
(
'
resize
'
,
debouncedSetSidebarHeight
);
this
.
initialized
=
true
;
}
},
setSidebarHeight
()
{
const
currentScrollDepth
=
window
.
pageYOffset
||
0
;
const
diff
=
this
.
$navHeight
-
currentScrollDepth
;
if
(
diff
>
0
)
{
const
newSidebarHeight
=
window
.
innerHeight
-
diff
;
this
.
$rightSidebar
.
outerHeight
(
newSidebarHeight
);
this
.
sidebarHeightIsCustom
=
true
;
}
else
if
(
this
.
sidebarHeightIsCustom
)
{
this
.
$rightSidebar
.
outerHeight
(
'
100%
'
);
this
.
sidebarHeightIsCustom
=
false
;
}
},
};
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