diff options
author | Gabriel Gizotti <gabriel@gizotti.com> | 2016-11-28 21:30:25 +1000 |
---|---|---|
committer | Gabriel Gizotti <gabriel@gizotti.com> | 2016-12-16 19:13:17 +1000 |
commit | e97c7100aed6fb4ca072c80a78b95d5f51805197 (patch) | |
tree | a88bc7ef3ba50e216caac53f7d41bcd3b618e2b4 | |
parent | 58609f842e1344579ed14745bb6bcb365059166f (diff) | |
download | gitlab-ce-e97c7100aed6fb4ca072c80a78b95d5f51805197.tar.gz |
move javascript code from _commit_message_container view to javascripts/merge_request.js
-rw-r--r-- | app/assets/javascripts/merge_request.js | 26 | ||||
-rw-r--r-- | app/views/shared/_commit_message_container.html.haml | 21 |
2 files changed, 26 insertions, 21 deletions
diff --git a/app/assets/javascripts/merge_request.js b/app/assets/javascripts/merge_request.js index 70f9a8d1955..309724071d2 100644 --- a/app/assets/javascripts/merge_request.js +++ b/app/assets/javascripts/merge_request.js @@ -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; })(); diff --git a/app/views/shared/_commit_message_container.html.haml b/app/views/shared/_commit_message_container.html.haml index 3e0186983e4..803cbb47e55 100644 --- a/app/views/shared/_commit_message_container.html.haml +++ b/app/views/shared/_commit_message_container.html.haml @@ -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(); - }); |