blob: c13744ebc62e939116515965a7fe83c0bcfc6cc0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
class @Compare
constructor: (@opts) ->
@source_loading = $ ".js-source-loading"
@target_loading = $ ".js-target-loading"
@source_branch = $ "#merge_request_source_branch"
@target_branch = $ "#merge_request_target_branch"
@target_project = $ "#merge_request_target_project_id"
@initialState()
@cleanBinding()
@addBinding()
cleanBinding: ->
@source_branch.off "change"
@target_branch.off "change"
@target_project.off "change"
addBinding: ->
@source_branch.on "change", =>
@getSourceHtml()
@target_branch.on "change", =>
@getTargetHtml()
@target_project.on "change", =>
@getTargetProject()
initialState: ->
@getSourceHtml()
@getTargetHtml()
getTargetProject: ->
$.get @opts.targetProjectUrl,
target_project_id: @target_project.val()
getSourceHtml: ->
$.ajax(
url: @opts.sourceBranchUrl
data:
ref: @source_branch.val()
beforeSend: =>
@source_loading.show()
$(".mr_source_commit").html ""
success: (html) =>
@source_loading.hide()
$(".mr_source_commit").html html
$(".mr_source_commit .js-timeago").timeago()
)
getTargetHtml: ->
$.ajax(
url: @opts.targetBranchUrl
data:
target_project_id: @target_project.val()
ref: @target_branch.val()
beforeSend: =>
@target_loading.show()
$(".mr_target_commit").html ""
success: (html) =>
@target_loading.hide()
$(".mr_target_commit").html html
$(".mr_target_commit .js-timeago").timeago()
)
|