BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
07174514
Commit
07174514
authored
Dec 02, 2016
by
Kushal Pandya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable build log autoscroll when page scrolls to bottom
parent
528c3e2b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
9 deletions
+37
-9
build.js
app/assets/javascripts/build.js
+37
-9
No files found.
app/assets/javascripts/build.js
View file @
07174514
...
...
@@ -10,6 +10,26 @@
Build
.
state
=
null
;
function
isInViewPort
(
el
)
{
var
elTop
=
el
.
offset
().
top
;
var
elBottom
=
elTop
+
el
.
outerHeight
();
var
vpBottom
=
$
(
window
).
scrollTop
()
+
$
(
window
).
height
();
return
vpBottom
>
elTop
;
}
function
toggleAutoScroll
(
state
)
{
var
$autoScrollBtn
=
$
(
'#autoscroll-button'
);
if
(
state
)
{
$autoScrollBtn
.
data
(
"state"
,
"enabled"
);
$autoScrollBtn
.
text
(
"Disable autoscroll"
);
}
else
{
$autoScrollBtn
.
data
(
"state"
,
"disabled"
);
$autoScrollBtn
.
text
(
"Enable autoscroll"
);
}
}
function
Build
(
options
)
{
options
=
options
||
$
(
'.js-build-options'
).
data
();
this
.
pageUrl
=
options
.
pageUrl
;
...
...
@@ -40,18 +60,26 @@
this
.
initScrollButtonAffix
();
}
if
(
this
.
buildStatus
===
"running"
||
this
.
buildStatus
===
"pending"
)
{
// Bind autoscroll button to follow build output
$
(
'#autoscroll-button'
).
on
(
'click'
,
function
()
{
var
state
;
state
=
$
(
this
).
data
(
"state"
);
if
(
"enabled"
===
state
)
{
$
(
this
).
data
(
"state"
,
"disabled"
);
return
$
(
this
).
text
(
"Enable autoscroll"
);
// Bind document scroll listener to detect if user has scrolled to page bottom
// and enable autoscroll of build log, disable autoscroll otherwise
this
.
$document
.
on
(
'scroll'
,
function
()
{
var
$autoScrollBtn
=
$
(
'#autoscroll-button'
);
if
(
isInViewPort
(
$
(
'.js-build-refresh'
)))
{
// Check if Refresh Animation is in Viewport
if
(
$autoScrollBtn
.
data
(
"state"
)
===
'disabled'
)
{
toggleAutoScroll
(
true
);
// Enable Autoscroll
}
}
else
{
$
(
this
).
data
(
"state"
,
"enabled"
);
return
$
(
this
).
text
(
"Disable autoscroll"
);
if
(
$autoScrollBtn
.
data
(
"state"
)
===
'enabled'
)
{
toggleAutoScroll
(
false
);
// Disable Autoscroll
}
}
});
// Bind autoscroll button to follow build output
$
(
'#autoscroll-button'
).
on
(
'click'
,
function
()
{
toggleAutoScroll
(
$
(
this
).
data
(
"state"
)
===
'disabled'
);
});
Build
.
interval
=
setInterval
((
function
(
_this
)
{
// Check for new build output if user still watching build page
// Only valid for runnig build when output changes during time
...
...
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