diff options
author | Kushal Pandya <kushal@gitlab.com> | 2017-01-02 13:01:27 +0530 |
---|---|---|
committer | Kushal Pandya <kushal@gitlab.com> | 2017-01-12 10:31:04 -0500 |
commit | 2b63470f4ef9e743ae94df39162a38089dca77aa (patch) | |
tree | 1c9e71cc2937d261f973428ec5705ba5a3712121 /app/assets/javascripts/build.js | |
parent | 3c9a3918e6a93a3e3cdcbe63214809d2ba9eb959 (diff) | |
download | gitlab-ce-2b63470f4ef9e743ae94df39162a38089dca77aa.tar.gz |
Scroll to bottom on build completion if autoscroll was active
Diffstat (limited to 'app/assets/javascripts/build.js')
-rw-r--r-- | app/assets/javascripts/build.js | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/app/assets/javascripts/build.js b/app/assets/javascripts/build.js index bc13c46443a..207eb639780 100644 --- a/app/assets/javascripts/build.js +++ b/app/assets/javascripts/build.js @@ -83,6 +83,10 @@ return window.location.href.split("#")[0]; }; + Build.prototype.locationHash = function() { + return window.location.href.split("#")[1]; + }; + Build.prototype.getInitialBuildTrace = function() { var removeRefreshStatuses = ['success', 'failed', 'canceled', 'skipped'] @@ -91,6 +95,9 @@ dataType: 'json', success: function(buildData) { $('.js-build-output').html(buildData.trace_html); + if (this.locationHash() === 'down-build-trace') { + $("html,body").scrollTop(this.$buildTrace.height()); + } if (removeRefreshStatuses.indexOf(buildData.status) >= 0) { this.$buildRefreshAnimation.remove(); return this.initScrollMonitor(); @@ -105,6 +112,8 @@ dataType: "json", success: (function(_this) { return function(log) { + var pageUrl; + if (log.state) { _this.state = log.state; } @@ -116,7 +125,12 @@ } return _this.checkAutoscroll(); } else if (log.status !== _this.buildStatus) { - return Turbolinks.visit(_this.pageUrl); + pageUrl = _this.pageUrl; + if (_this.$autoScrollStatus.data('state') === 'enabled') { + pageUrl += '#down-build-trace'; + } + + return Turbolinks.visit(pageUrl); } }; })(this) |