gitlabhq/app/assets/javascripts/merge_requests.js

43 lines
1.1 KiB
JavaScript
Raw Normal View History

2011-12-13 10:07:52 +02:00
var MergeRequest = {
2011-12-13 20:40:45 +02:00
diffs_loaded: false,
2011-12-13 10:07:52 +02:00
commits_loaded: false,
init:
function() {
2012-04-10 08:51:08 +03:00
$(".nav-tabs a").live("click", function() {
$(".nav-tabs a").parent().removeClass("active");
2012-01-27 00:13:19 +02:00
$(this).parent().addClass("active");
2011-12-13 10:07:52 +02:00
});
2012-04-10 08:51:08 +03:00
$(".nav-tabs a.merge-notes-tab").live("click", function(e) {
$(".merge-request-diffs").hide();
2012-03-15 23:01:50 +02:00
$(".merge_request_notes").show();
e.preventDefault();
2011-12-13 20:40:45 +02:00
});
2012-04-10 08:51:08 +03:00
$(".nav-tabs a.merge-diffs-tab").live("click", function(e) {
2011-12-13 20:40:45 +02:00
if(!MergeRequest.diffs_loaded) {
MergeRequest.loadDiff();
}
2012-03-15 23:01:50 +02:00
$(".merge_request_notes").hide();
2011-12-13 20:40:45 +02:00
$(".merge-request-diffs").show();
e.preventDefault();
2011-12-13 10:07:52 +02:00
});
},
loadDiff:
function() {
2011-12-13 20:40:45 +02:00
$(".dashboard-loader").show();
$.ajax({
type: "GET",
url: $(".merge-diffs-tab").attr("data-url"),
beforeSend: function(){ $('.status').addClass("loading")},
2011-12-13 20:40:45 +02:00
complete: function(){
MergeRequest.diffs_loaded = true;
2012-03-15 23:01:50 +02:00
$(".merge_request_notes").hide();
$('.status').removeClass("loading");
},
2011-12-13 20:40:45 +02:00
dataType: "script"});
2011-12-13 10:07:52 +02:00
}
}