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
Show 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 @@
...
@@ -10,6 +10,26 @@
Build
.
state
=
null
;
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
)
{
function
Build
(
options
)
{
options
=
options
||
$
(
'.js-build-options'
).
data
();
options
=
options
||
$
(
'.js-build-options'
).
data
();
this
.
pageUrl
=
options
.
pageUrl
;
this
.
pageUrl
=
options
.
pageUrl
;
...
@@ -40,18 +60,26 @@
...
@@ -40,18 +60,26 @@
this
.
initScrollButtonAffix
();
this
.
initScrollButtonAffix
();
}
}
if
(
this
.
buildStatus
===
"running"
||
this
.
buildStatus
===
"pending"
)
{
if
(
this
.
buildStatus
===
"running"
||
this
.
buildStatus
===
"pending"
)
{
// Bind autoscroll button to follow build output
// Bind document scroll listener to detect if user has scrolled to page bottom
$
(
'#autoscroll-button'
).
on
(
'click'
,
function
()
{
// and enable autoscroll of build log, disable autoscroll otherwise
var
state
;
this
.
$document
.
on
(
'scroll'
,
function
()
{
state
=
$
(
this
).
data
(
"state"
);
var
$autoScrollBtn
=
$
(
'#autoscroll-button'
);
if
(
"enabled"
===
state
)
{
if
(
isInViewPort
(
$
(
'.js-build-refresh'
)))
{
// Check if Refresh Animation is in Viewport
$
(
this
).
data
(
"state"
,
"disabled"
);
if
(
$autoScrollBtn
.
data
(
"state"
)
===
'disabled'
)
{
return
$
(
this
).
text
(
"Enable autoscroll"
);
toggleAutoScroll
(
true
);
// Enable Autoscroll
}
}
else
{
}
else
{
$
(
this
).
data
(
"state"
,
"enabled"
);
if
(
$autoScrollBtn
.
data
(
"state"
)
===
'enabled'
)
{
return
$
(
this
).
text
(
"Disable autoscroll"
);
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
)
{
Build
.
interval
=
setInterval
((
function
(
_this
)
{
// Check for new build output if user still watching build page
// Check for new build output if user still watching build page
// Only valid for runnig build when output changes during time
// 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