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
c02945ac
Commit
c02945ac
authored
Dec 09, 2016
by
Kushal Pandya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cache commonly referenced DOM elements, cleaning up
parent
a8fa87ce
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
40 deletions
+29
-40
app/assets/javascripts/build.js
app/assets/javascripts/build.js
+29
-40
No files found.
app/assets/javascripts/build.js
View file @
c02945ac
...
@@ -31,6 +31,15 @@
...
@@ -31,6 +31,15 @@
this
.
buildStage
=
options
.
buildStage
;
this
.
buildStage
=
options
.
buildStage
;
this
.
updateDropdown
=
bind
(
this
.
updateDropdown
,
this
);
this
.
updateDropdown
=
bind
(
this
.
updateDropdown
,
this
);
this
.
$document
=
$
(
document
);
this
.
$document
=
$
(
document
);
this
.
$body
=
$
(
'
body
'
);
this
.
$buildTrace
=
$
(
'
#build-trace
'
);
this
.
$autoScrollContainer
=
$
(
'
.autoscroll-container
'
);
this
.
$autoScrollStatus
=
$
(
'
#autoscroll-status
'
);
this
.
$upBuildTrace
=
$
(
'
#up-build-trace
'
);
this
.
$downBuildTrace
=
$
(
'
#down-build-trace
'
);
this
.
$scrollTopBtn
=
$
(
'
#scroll-top
'
);
this
.
$scrollBottomBtn
=
$
(
'
#scroll-bottom
'
);
clearInterval
(
Build
.
interval
);
clearInterval
(
Build
.
interval
);
// Init breakpoint checker
// Init breakpoint checker
this
.
bp
=
Breakpoints
.
get
();
this
.
bp
=
Breakpoints
.
get
();
...
@@ -123,24 +132,15 @@
...
@@ -123,24 +132,15 @@
};
};
Build
.
prototype
.
checkAutoscroll
=
function
()
{
Build
.
prototype
.
checkAutoscroll
=
function
()
{
if
(
"
enabled
"
===
$
(
"
#autoscroll-status
"
).
data
(
"
state
"
)
)
{
if
(
$
(
"
#autoscroll-status
"
).
data
(
"
state
"
)
===
"
enabled
"
)
{
return
$
(
"
html,body
"
).
scrollTop
(
$
(
"
#build-trace
"
).
height
());
return
$
(
"
html,body
"
).
scrollTop
(
$
(
"
#build-trace
"
).
height
());
}
}
};
};
Build
.
prototype
.
initScrollButtonAffix
=
function
()
{
Build
.
prototype
.
initScrollButtonAffix
=
function
()
{
var
$body
=
$
(
'
body
'
);
this
.
$scrollTopBtn
.
hide
().
removeClass
(
'
sticky
'
);
var
$buildTrace
=
$
(
'
#build-trace
'
);
this
.
$scrollBottomBtn
.
show
().
addClass
(
'
sticky
'
);
var
$scrollTopBtn
=
$
(
'
#scroll-top
'
);
this
.
$autoScrollContainer
.
hide
();
var
$scrollBottomBtn
=
$
(
'
#scroll-bottom
'
);
var
$autoScrollContainer
=
$
(
'
.autoscroll-container
'
);
$scrollTopBtn
.
hide
().
removeClass
(
'
sticky
'
);
$scrollBottomBtn
.
show
().
addClass
(
'
sticky
'
);
if
(
$autoScrollContainer
.
length
)
{
$autoScrollContainer
.
hide
();
}
}
}
// Page scroll listener to detect if user has scrolling page
// Page scroll listener to detect if user has scrolling page
...
@@ -158,43 +158,32 @@
...
@@ -158,43 +158,32 @@
// - Show Bottom Arrow button
// - Show Bottom Arrow button
// - Disable Autoscroll and hide indicator (when build is running)
// - Disable Autoscroll and hide indicator (when build is running)
Build
.
prototype
.
initScrollMonitor
=
function
()
{
Build
.
prototype
.
initScrollMonitor
=
function
()
{
var
$body
=
$
(
'
body
'
);
if
(
isInViewport
(
this
.
$upBuildTrace
))
{
// User is at Top of Build Log
var
$buildTrace
=
$
(
'
#build-trace
'
);
this
.
$scrollTopBtn
.
hide
().
removeClass
(
'
sticky
'
);
var
$autoScrollContainer
=
$
(
'
.autoscroll-container
'
);
this
.
$scrollBottomBtn
.
show
().
addClass
(
'
sticky
'
);
var
$autoScrollStatus
=
$
(
'
#autoscroll-status
'
);
var
$upBuildTrace
=
$
(
'
#up-build-trace
'
);
var
$downBuildTrace
=
$
(
'
#down-build-trace
'
);
var
$scrollTopBtn
=
$
(
'
#scroll-top
'
);
var
$scrollBottomBtn
=
$
(
'
#scroll-bottom
'
);
if
(
isInViewport
(
$upBuildTrace
))
{
// User is at Top of Build Log
$scrollTopBtn
.
hide
().
removeClass
(
'
sticky
'
);
$scrollBottomBtn
.
show
().
addClass
(
'
sticky
'
);
}
}
if
(
isInViewport
(
$downBuildTrace
))
{
// User is at Bottom of Build Log
if
(
isInViewport
(
this
.
$downBuildTrace
))
{
// User is at Bottom of Build Log
$scrollTopBtn
.
show
().
addClass
(
'
sticky
'
);
this
.
$scrollTopBtn
.
show
().
addClass
(
'
sticky
'
);
$scrollBottomBtn
.
hide
().
removeClass
(
'
sticky
'
);
this
.
$scrollBottomBtn
.
hide
().
removeClass
(
'
sticky
'
);
if
(
$autoScrollContainer
.
length
)
{
// Show and Reposition Autoscroll Status Message
// Show and Reposition Autoscroll Status Indicator
$autoScrollContainer
.
show
().
css
({
top
:
$body
.
outerHeight
()
-
75
});
this
.
$autoScrollContainer
.
css
({
top
:
this
.
$body
.
outerHeight
()
-
75
}).
fadeIn
(
100
);
$autoScrollStatus
.
find
(
'
.status-text
'
).
addClass
(
'
animate
'
);
this
.
$autoScrollStatus
.
find
(
'
.status-text
'
).
addClass
(
'
animate
'
);
}
}
}
if
(
!
isInViewport
(
$upBuildTrace
)
&&
!
isInViewport
(
$downBuildTrace
))
{
// User is somewhere in middle of Build Log
if
(
!
isInViewport
(
this
.
$upBuildTrace
)
&&
!
isInViewport
(
this
.
$downBuildTrace
))
{
// User is somewhere in middle of Build Log
$scrollTopBtn
.
show
().
addClass
(
'
sticky
'
);
this
.
$scrollTopBtn
.
show
().
addClass
(
'
sticky
'
);
$scrollBottomBtn
.
show
().
addClass
(
'
sticky
'
);
this
.
$scrollBottomBtn
.
show
().
addClass
(
'
sticky
'
);
if
(
$autoScrollContainer
.
length
)
{
// Hide Autoscroll Status Indicator
$autoScrollContainer
.
hide
();
this
.
$autoScrollContainer
.
hide
();
$autoScrollStatus
.
find
(
'
.status-text
'
).
removeClass
(
'
animate
'
);
this
.
$autoScrollStatus
.
find
(
'
.status-text
'
).
removeClass
(
'
animate
'
);
}
}
}
if
(
this
.
buildStatus
===
"
running
"
||
this
.
buildStatus
===
"
pending
"
)
{
if
(
this
.
buildStatus
===
"
running
"
||
this
.
buildStatus
===
"
pending
"
)
{
// Check if Refresh Animation is in Viewport and enable Autoscroll, disable otherwise.
// Check if Refresh Animation is in Viewport and enable Autoscroll, disable otherwise.
$autoScrollStatus
.
data
(
"
state
"
,
isInViewport
(
$
(
'
.js-build-refresh
'
))
?
'
enabled
'
:
'
disabled
'
);
this
.
$autoScrollStatus
.
data
(
"
state
"
,
isInViewport
(
$
(
'
.js-build-refresh
'
))
?
'
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