summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/milestone.js
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2017-04-25 15:25:20 +0100
committerPhil Hughes <me@iamphill.com>2017-04-26 12:23:29 +0100
commit52d59a4e5108d2ffd6f2bc543ee9aef1a87a8f14 (patch)
treef1f9b1b7e46fcd441d3cf860016473ec04baf6de /app/assets/javascripts/milestone.js
parentf00bb1c29ea438be66b3766545a57b468ade37d4 (diff)
downloadgitlab-ce-52d59a4e5108d2ffd6f2bc543ee9aef1a87a8f14.tar.gz
Load milestone tabs asynchronously
Diffstat (limited to 'app/assets/javascripts/milestone.js')
-rw-r--r--app/assets/javascripts/milestone.js29
1 files changed, 20 insertions, 9 deletions
diff --git a/app/assets/javascripts/milestone.js b/app/assets/javascripts/milestone.js
index 38c673e8907..1026f458733 100644
--- a/app/assets/javascripts/milestone.js
+++ b/app/assets/javascripts/milestone.js
@@ -81,9 +81,7 @@
};
function Milestone() {
- var oldMouseStart;
this.bindIssuesSorting();
- this.bindMergeRequestSorting();
this.bindTabsSwitching();
}
@@ -100,13 +98,14 @@
};
Milestone.prototype.bindTabsSwitching = function() {
- return $('a[data-toggle="tab"]').on('show.bs.tab', function(e) {
- var currentTabClass, previousTabClass;
- currentTabClass = $(e.target).data('show');
- previousTabClass = $(e.relatedTarget).data('show');
- $(previousTabClass).hide();
- $(currentTabClass).removeClass('hidden');
- return $(currentTabClass).show();
+ return $('a[data-toggle="tab"]').on('show.bs.tab', (e) => {
+ const $target = $(e.target);
+ const endpoint = $target.data('endpoint');
+
+ if (endpoint && !$target.hasClass('is-loaded')) {
+ this.loadMergeRequests($target.attr('href'), endpoint)
+ .done(() => $target.addClass('is-loaded'));
+ }
});
};
@@ -169,6 +168,18 @@
});
};
+ Milestone.prototype.loadMergeRequests = function(elId, url) {
+ return $.ajax({
+ url,
+ dataType: 'JSON',
+ })
+ .fail(() => new Flash('Error loading merge requests'))
+ .done((data) => {
+ $(elId).html(data.html);
+ this.bindMergeRequestSorting();
+ });
+ };
+
return Milestone;
})();
}).call(window);