diff options
author | Phil Hughes <me@iamphill.com> | 2017-04-25 15:25:20 +0100 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2017-04-26 12:23:29 +0100 |
commit | 52d59a4e5108d2ffd6f2bc543ee9aef1a87a8f14 (patch) | |
tree | f1f9b1b7e46fcd441d3cf860016473ec04baf6de /app/assets/javascripts/milestone.js | |
parent | f00bb1c29ea438be66b3766545a57b468ade37d4 (diff) | |
download | gitlab-ce-52d59a4e5108d2ffd6f2bc543ee9aef1a87a8f14.tar.gz |
Load milestone tabs asynchronously
Diffstat (limited to 'app/assets/javascripts/milestone.js')
-rw-r--r-- | app/assets/javascripts/milestone.js | 29 |
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); |