summaryrefslogtreecommitdiffstats
path: root/web_src/js
diff options
context:
space:
mode:
Diffstat (limited to 'web_src/js')
-rw-r--r--web_src/js/features/repo-diff.js29
1 files changed, 28 insertions, 1 deletions
diff --git a/web_src/js/features/repo-diff.js b/web_src/js/features/repo-diff.js
index 9606e3baad..6741f277fb 100644
--- a/web_src/js/features/repo-diff.js
+++ b/web_src/js/features/repo-diff.js
@@ -94,13 +94,40 @@ export function initRepoDiffShowMore() {
type: 'GET',
url,
}).done((resp) => {
- if (!resp || resp.html === '' || resp.empty) {
+ if (!resp) {
$('#diff-show-more-files, #diff-show-more-files-stats').removeClass('disabled');
return;
}
$('#diff-too-many-files-stats').remove();
$('#diff-files').append($(resp).find('#diff-files li'));
$('#diff-incomplete').replaceWith($(resp).find('#diff-file-boxes').children());
+ }).fail(() => {
+ $('#diff-show-more-files, #diff-show-more-files-stats').removeClass('disabled');
+ });
+ });
+ $(document).on('click', 'a.diff-show-more-button', (e) => {
+ e.preventDefault();
+ const $target = $(e.target);
+
+ if ($target.hasClass('disabled')) {
+ return;
+ }
+
+ $target.addClass('disabled');
+
+ const url = $target.data('href');
+ $.ajax({
+ type: 'GET',
+ url,
+ }).done((resp) => {
+ if (!resp) {
+ $target.removeClass('disabled');
+ return;
+ }
+
+ $target.parent().replaceWith($(resp).find('#diff-file-boxes .diff-file-body .file-body').children());
+ }).fail(() => {
+ $target.removeClass('disabled');
});
});
}