diff options
Diffstat (limited to 'app/assets/javascripts/new_commit_form.js.coffee')
-rw-r--r-- | app/assets/javascripts/new_commit_form.js.coffee | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/app/assets/javascripts/new_commit_form.js.coffee b/app/assets/javascripts/new_commit_form.js.coffee new file mode 100644 index 00000000000..03f0f51acfa --- /dev/null +++ b/app/assets/javascripts/new_commit_form.js.coffee @@ -0,0 +1,21 @@ +class @NewCommitForm + constructor: (form) -> + @newBranch = form.find('.js-target-branch') + @originalBranch = form.find('.js-original-branch') + @createMergeRequest = form.find('.js-create-merge-request') + @createMergeRequestContainer = form.find('.js-create-merge-request-container') + + @renderDestination() + @newBranch.keyup @renderDestination + + renderDestination: => + different = @newBranch.val() != @originalBranch.val() + + if different + @createMergeRequestContainer.show() + @createMergeRequest.prop('checked', true) unless @wasDifferent + else + @createMergeRequestContainer.hide() + @createMergeRequest.prop('checked', false) + + @wasDifferent = different |