diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-06 21:09:02 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-06 21:09:02 +0300 |
commit | 0c4a28ded2d4539eafa7ff077c34682227b43292 (patch) | |
tree | 2502827b071a2b8b661572edd1b843415c272270 /app/assets/javascripts/pager.js | |
parent | 2e1b10493f9ed9685eb892ab747335983e58f154 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/pager.js')
-rw-r--r-- | app/assets/javascripts/pager.js | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/app/assets/javascripts/pager.js b/app/assets/javascripts/pager.js index bdb33a82b66..3ad9d80b4f2 100644 --- a/app/assets/javascripts/pager.js +++ b/app/assets/javascripts/pager.js @@ -8,19 +8,21 @@ const ENDLESS_SCROLL_BOTTOM_PX = 400; const ENDLESS_SCROLL_FIRE_DELAY_MS = 1000; export default { - init( + init({ limit = 0, preload = false, disable = false, prepareData = $.noop, - callback = $.noop, + successCallback = $.noop, + errorCallback = $.noop, container = '', - ) { + } = {}) { this.limit = limit; this.offset = parseInt(getParameterByName('offset'), 10) || this.limit; this.disable = disable; this.prepareData = prepareData; - this.callback = callback; + this.successCallback = successCallback; + this.errorCallback = errorCallback; this.loading = $(`${container} .loading`).first(); if (preload) { this.offset = 0; @@ -42,7 +44,7 @@ export default { }) .then(({ data }) => { this.append(data.count, this.prepareData(data.html)); - this.callback(); + this.successCallback(); // keep loading until we've filled the viewport height if (!this.disable && !this.isScrollable()) { @@ -51,7 +53,8 @@ export default { this.loading.hide(); } }) - .catch(() => this.loading.hide()); + .catch((err) => this.errorCallback(err)) + .finally(() => this.loading.hide()); }, append(count, html) { |