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
df0aeae7
Commit
df0aeae7
authored
Dec 09, 2016
by
Kushal Pandya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move `isInViewport` to `gl.utils`, make scroll buttons sticky always
parent
5fc161c2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
24 deletions
+12
-24
app/assets/javascripts/build.js
app/assets/javascripts/build.js
+12
-24
No files found.
app/assets/javascripts/build.js
View file @
df0aeae7
...
...
@@ -10,18 +10,6 @@
Build
.
state
=
null
;
function
isInViewport
(
el
)
{
// Courtesy http://stackoverflow.com/a/7557433/414749
var
rect
=
el
[
0
].
getBoundingClientRect
();
return
(
rect
.
top
>=
0
&&
rect
.
left
>=
0
&&
rect
.
bottom
<=
$
(
window
).
height
()
&&
rect
.
right
<=
$
(
window
).
width
()
);
}
function
Build
(
options
)
{
options
=
options
||
$
(
'
.js-build-options
'
).
data
();
this
.
pageUrl
=
options
.
pageUrl
;
...
...
@@ -138,8 +126,8 @@
};
Build
.
prototype
.
initScrollButtonAffix
=
function
()
{
this
.
$scrollTopBtn
.
hide
()
.
removeClass
(
'
sticky
'
)
;
this
.
$scrollBottomBtn
.
show
()
.
addClass
(
'
sticky
'
)
;
this
.
$scrollTopBtn
.
hide
();
this
.
$scrollBottomBtn
.
show
();
this
.
$autoScrollContainer
.
hide
();
}
...
...
@@ -158,23 +146,23 @@
// - Show Bottom Arrow button
// - Disable Autoscroll and hide indicator (when build is running)
Build
.
prototype
.
initScrollMonitor
=
function
()
{
if
(
isInViewport
(
this
.
$upBuildTrace
))
{
// User is at Top of Build Log
this
.
$scrollTopBtn
.
hide
()
.
removeClass
(
'
sticky
'
)
;
this
.
$scrollBottomBtn
.
show
()
.
addClass
(
'
sticky
'
)
;
if
(
gl
.
utils
.
isInViewport
(
this
.
$upBuildTrace
[
0
]
))
{
// User is at Top of Build Log
this
.
$scrollTopBtn
.
hide
();
this
.
$scrollBottomBtn
.
show
();
}
if
(
isInViewport
(
this
.
$downBuildTrace
))
{
// User is at Bottom of Build Log
this
.
$scrollTopBtn
.
show
()
.
addClass
(
'
sticky
'
)
;
this
.
$scrollBottomBtn
.
hide
()
.
removeClass
(
'
sticky
'
)
;
if
(
gl
.
utils
.
isInViewport
(
this
.
$downBuildTrace
[
0
]
))
{
// User is at Bottom of Build Log
this
.
$scrollTopBtn
.
show
();
this
.
$scrollBottomBtn
.
hide
();
// Show and Reposition Autoscroll Status Indicator
this
.
$autoScrollContainer
.
css
({
top
:
this
.
$body
.
outerHeight
()
-
75
}).
fadeIn
(
100
);
this
.
$autoScrollStatus
.
find
(
'
.status-text
'
).
addClass
(
'
animate
'
);
}
if
(
!
isInViewport
(
this
.
$upBuildTrace
)
&&
!
isInViewport
(
this
.
$downBuildTrace
))
{
// User is somewhere in middle of Build Log
this
.
$scrollTopBtn
.
show
()
.
addClass
(
'
sticky
'
)
;
this
.
$scrollBottomBtn
.
show
()
.
addClass
(
'
sticky
'
)
;
if
(
!
gl
.
utils
.
isInViewport
(
this
.
$upBuildTrace
[
0
])
&&
!
gl
.
utils
.
isInViewport
(
this
.
$downBuildTrace
[
0
]
))
{
// User is somewhere in middle of Build Log
this
.
$scrollTopBtn
.
show
();
this
.
$scrollBottomBtn
.
show
();
// Hide Autoscroll Status Indicator
this
.
$autoScrollContainer
.
hide
();
...
...
@@ -183,7 +171,7 @@
if
(
this
.
buildStatus
===
"
running
"
||
this
.
buildStatus
===
"
pending
"
)
{
// Check if Refresh Animation is in Viewport and enable Autoscroll, disable otherwise.
this
.
$autoScrollStatus
.
data
(
"
state
"
,
isInViewport
(
$
(
'
.js-build-refresh
'
)
)
?
'
enabled
'
:
'
disabled
'
);
this
.
$autoScrollStatus
.
data
(
"
state
"
,
gl
.
utils
.
isInViewport
(
$
(
'
.js-build-refresh
'
)[
0
]
)
?
'
enabled
'
:
'
disabled
'
);
}
};
...
...
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