Commit e97c7100 authored by Gabriel Gizotti's avatar Gabriel Gizotti

move javascript code from _commit_message_container view to javascripts/merge_request.js

parent 58609f84
......@@ -27,6 +27,8 @@
// Prevent duplicate event bindings
this.disableTaskList();
this.initMRBtnListeners();
this.initMessageWithDescriptionListener();
this.initMessageWithoutDescriptionListener();
if ($("a.btn-close").length) {
this.initTaskList();
}
......@@ -108,6 +110,30 @@
// note so that we can re-use its form here
};
MergeRequest.prototype.initMessageWithDescriptionListener = function() {
return $('a.with-description-link').on('click', function(e) {
e.preventDefault();
var textarea = $('textarea.js-commit-message');
textarea.val(textarea.data('messageWithDescription'));
$('p.with-description-hint').hide();
$('p.without-description-hint').show();
});
};
MergeRequest.prototype.initMessageWithoutDescriptionListener = function() {
return $('a.without-description-link').on('click', function(e) {
e.preventDefault();
var textarea = $('textarea.js-commit-message');
textarea.val(textarea.data('messageWithoutDescription'));
$('p.with-description-hint').show();
$('p.without-description-hint').hide();
});
};
return MergeRequest;
})();
......
......@@ -22,24 +22,3 @@
%p.hint.without-description-hint.hide
= link_to "#", class: "without-description-link" do
Don't include description in commit message
:javascript
$('.with-description-link').on('click', function(e) {
e.preventDefault();
var textarea = $('.js-commit-message')
textarea.val(textarea.data('messageWithDescription'))
$('.with-description-hint').hide();
$('.without-description-hint').show();
});
$('.without-description-link').on('click', function(e) {
e.preventDefault();
var textarea = $('.js-commit-message')
textarea.val(textarea.data('messageWithoutDescription'))
$('.with-description-hint').show();
$('.without-description-hint').hide();
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment