Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2016-04-05 12:17:00 +0300
committerPhil Hughes <me@iamphill.com>2016-04-14 12:28:05 +0300
commit82164a9f777f7eee37707b19ae6ec514a588c1ec (patch)
tree51a87191dc7d0b7fcdf4dc20124311d94de641fa /app/assets/javascripts/gl_form.js.coffee
parent8ee04ebe2966240da973d4428b0b8822663b1d7e (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.coffee40
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'