2011-12-13 03:07:52 -05:00
|
|
|
var MergeRequest = {
|
2011-12-13 13:40:45 -05:00
|
|
|
diffs_loaded: false,
|
2011-12-13 03:07:52 -05:00
|
|
|
commits_loaded: false,
|
2012-04-16 15:08:03 -04:00
|
|
|
opts: false,
|
2011-12-13 03:07:52 -05:00
|
|
|
|
|
|
|
init:
|
2012-04-16 15:08:03 -04:00
|
|
|
function(opts) {
|
2012-04-26 17:53:55 -04:00
|
|
|
var self = this;
|
|
|
|
self.opts = opts;
|
2012-04-16 15:08:03 -04:00
|
|
|
|
2012-04-26 17:53:55 -04:00
|
|
|
self.showState(self.opts.current_state);
|
|
|
|
if($(".automerge_widget").length && self.opts.check_enable){
|
2012-04-16 15:08:03 -04:00
|
|
|
$.get(opts.url_to_automerge_check, function(data){
|
2012-04-26 17:53:55 -04:00
|
|
|
self.showState(data.state);
|
2012-04-16 15:08:03 -04:00
|
|
|
}, "json");
|
|
|
|
}
|
|
|
|
|
2012-04-10 01:51:08 -04:00
|
|
|
$(".nav-tabs a").live("click", function() {
|
|
|
|
$(".nav-tabs a").parent().removeClass("active");
|
2012-01-26 17:13:19 -05:00
|
|
|
$(this).parent().addClass("active");
|
2011-12-13 03:07:52 -05:00
|
|
|
});
|
|
|
|
|
2012-04-10 01:51:08 -04:00
|
|
|
$(".nav-tabs a.merge-notes-tab").live("click", function(e) {
|
2012-02-14 18:15:02 -05:00
|
|
|
$(".merge-request-diffs").hide();
|
2012-03-15 17:01:50 -04:00
|
|
|
$(".merge_request_notes").show();
|
2012-02-21 15:04:01 -05:00
|
|
|
e.preventDefault();
|
2011-12-13 13:40:45 -05:00
|
|
|
});
|
|
|
|
|
2012-04-10 01:51:08 -04:00
|
|
|
$(".nav-tabs a.merge-diffs-tab").live("click", function(e) {
|
2011-12-13 13:40:45 -05:00
|
|
|
if(!MergeRequest.diffs_loaded) {
|
|
|
|
MergeRequest.loadDiff();
|
|
|
|
}
|
2012-03-15 17:01:50 -04:00
|
|
|
$(".merge_request_notes").hide();
|
2011-12-13 13:40:45 -05:00
|
|
|
$(".merge-request-diffs").show();
|
2012-02-21 15:04:01 -05:00
|
|
|
e.preventDefault();
|
2011-12-13 03:07:52 -05:00
|
|
|
});
|
2012-06-20 14:29:55 -04:00
|
|
|
|
|
|
|
$(".mr_show_all_commits").bind("click", function() {
|
|
|
|
MergeRequest.showAllCommits();
|
|
|
|
})
|
2011-12-13 03:07:52 -05:00
|
|
|
},
|
|
|
|
|
2012-04-26 17:53:55 -04:00
|
|
|
showState:
|
|
|
|
function(state){
|
|
|
|
$(".automerge_widget").hide();
|
|
|
|
$(".automerge_widget." + state).show();
|
|
|
|
},
|
|
|
|
|
|
|
|
|
2011-12-13 03:07:52 -05:00
|
|
|
loadDiff:
|
|
|
|
function() {
|
2011-12-13 13:40:45 -05:00
|
|
|
$(".dashboard-loader").show();
|
|
|
|
$.ajax({
|
|
|
|
type: "GET",
|
|
|
|
url: $(".merge-diffs-tab").attr("data-url"),
|
2012-03-26 14:41:58 -04:00
|
|
|
beforeSend: function(){ $('.status').addClass("loading")},
|
2011-12-13 13:40:45 -05:00
|
|
|
complete: function(){
|
|
|
|
MergeRequest.diffs_loaded = true;
|
2012-03-15 17:01:50 -04:00
|
|
|
$(".merge_request_notes").hide();
|
2012-03-26 14:41:58 -04:00
|
|
|
$('.status').removeClass("loading");
|
|
|
|
},
|
2011-12-13 13:40:45 -05:00
|
|
|
dataType: "script"});
|
2012-04-17 15:08:07 -04:00
|
|
|
},
|
|
|
|
|
2012-06-20 14:01:00 -04:00
|
|
|
showAllCommits:
|
|
|
|
function() {
|
|
|
|
$(".first_mr_commits").remove();
|
|
|
|
$(".all_mr_commits").removeClass("hide");
|
|
|
|
},
|
|
|
|
|
2012-04-16 16:05:08 -04:00
|
|
|
already_cannot_be_merged:
|
|
|
|
function(){
|
|
|
|
$(".automerge_widget").hide();
|
|
|
|
$(".automerge_widget.already_cannot_be_merged").show();
|
2011-12-13 03:07:52 -05:00
|
|
|
}
|
|
|
|
}
|