diff options
author | Phil Hughes <me@iamphill.com> | 2016-04-05 10:28:10 +0100 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2016-04-14 10:28:05 +0100 |
commit | 5dd01f572c9a7504f34c5a3b30792197c856bd6f (patch) | |
tree | 247ad64654252090c4d7b32c41c52cc9eefb9c36 | |
parent | 82164a9f777f7eee37707b19ae6ec514a588c1ec (diff) | |
download | gitlab-ce-5dd01f572c9a7504f34c5a3b30792197c856bd6f.tar.gz |
Destroy discussion form
-rw-r--r-- | app/assets/javascripts/gl_form.js.coffee | 22 | ||||
-rw-r--r-- | app/assets/javascripts/notes.js.coffee | 8 |
2 files changed, 22 insertions, 8 deletions
diff --git a/app/assets/javascripts/gl_form.js.coffee b/app/assets/javascripts/gl_form.js.coffee index efa9284ed09..087a46cbac2 100644 --- a/app/assets/javascripts/gl_form.js.coffee +++ b/app/assets/javascripts/gl_form.js.coffee @@ -1,18 +1,30 @@ class @GLForm constructor: (@form) -> - @textarea = @form.find(".js-note-text") + @textarea = @form.find('.js-note-text') @setupForm() + @form.data 'gl-form', @ + + destroy: -> + # Destroy actions + actions = @form.data 'form-actions' + actions.clearEventListeners() + @form.data 'form-actions', null + + # Clean form listeners + @clearEventListeners() + @form.data 'gl-form', null + setupForm: -> isNewForm = @form.is(':not(.gfm-form)') - @form.removeClass "js-new-note-form" + @form.removeClass 'js-new-note-form' if isNewForm @form.find('.div-dropzone').remove() @form.addClass('gfm-form') - disableButtonIfEmptyField @form.find(".js-note-text"), @form.find(".js-comment-button") + disableButtonIfEmptyField @form.find('.js-note-text'), @form.find('.js-comment-button') # remove notify commit author checkbox for non-commit notes GitLab.GfmAutoComplete.setup() @@ -32,6 +44,10 @@ class @GLForm @form.show() + clearEventListeners: -> + @textarea.off 'focus' + @textarea.off 'blur' + addEventListeners: -> @textarea.on 'focus', -> $(@).closest('.md-area').addClass 'is-focused' diff --git a/app/assets/javascripts/notes.js.coffee b/app/assets/javascripts/notes.js.coffee index 0581774424f..fa91baa07c0 100644 --- a/app/assets/javascripts/notes.js.coffee +++ b/app/assets/javascripts/notes.js.coffee @@ -513,6 +513,9 @@ class @Notes removeDiscussionNoteForm: (form)-> row = form.closest("tr") + glForm = form.data 'gl-form' + glForm.destroy() + form.find(".js-note-text").data("autosave").reset() # show the reply button (will only work for replies) @@ -524,11 +527,6 @@ class @Notes # only remove the form form.remove() - # Remove the note actions - actions = form.data('form-actions') - actions.clearEventListeners() - form.data('form-actions', null) - cancelDiscussionForm: (e) => e.preventDefault() form = $(e.target).closest(".js-discussion-note-form") |