diff options
author | Phil Hughes <me@iamphill.com> | 2016-04-05 12:17:00 +0300 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2016-04-14 12:28:05 +0300 |
commit | 82164a9f777f7eee37707b19ae6ec514a588c1ec (patch) | |
tree | 51a87191dc7d0b7fcdf4dc20124311d94de641fa /app/assets/javascripts/gl_form.js.coffee | |
parent | 8ee04ebe2966240da973d4428b0b8822663b1d7e (diff) |
Notes form JS update
Updated the JS to have a standard class with standard actions for each form
Created ability to have toolbar buttons that insert different prefixes dependant upon the data-prefix attribute
Diffstat (limited to 'app/assets/javascripts/gl_form.js.coffee')
-rw-r--r-- | app/assets/javascripts/gl_form.js.coffee | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/app/assets/javascripts/gl_form.js.coffee b/app/assets/javascripts/gl_form.js.coffee new file mode 100644 index 00000000000..efa9284ed09 --- /dev/null +++ b/app/assets/javascripts/gl_form.js.coffee @@ -0,0 +1,40 @@ +class @GLForm + constructor: (@form) -> + @textarea = @form.find(".js-note-text") + + @setupForm() + + setupForm: -> + isNewForm = @form.is(':not(.gfm-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") + + # remove notify commit author checkbox for non-commit notes + GitLab.GfmAutoComplete.setup() + new DropzoneInput(@form) + + autosize(@textarea) + + # Setup action buttons + actions = new GLFormActions @form, @textarea + @form.data 'form-actions', actions + + # form and textarea event listeners + @addEventListeners() + + # hide discard button + @form.find('.js-note-discard').hide() + + @form.show() + + addEventListeners: -> + @textarea.on 'focus', -> + $(@).closest('.md-area').addClass 'is-focused' + + @textarea.on 'blur', -> + $(@).closest('.md-area').removeClass 'is-focused' |