Commit 04ad197b authored by Robert Schilling's avatar Robert Schilling

Trigger an update of save button if user pressed a preview color

parent b9519c83
......@@ -59,18 +59,18 @@ window.rstrip = (val) ->
# Disable button if text field is empty
window.disableButtonIfEmptyField = (field_selector, button_selector) ->
field = $(field_selector)
closest_submit = field.closest("form").find(button_selector)
closest_submit = field.closest('form').find(button_selector)
closest_submit.disable() if rstrip(field.val()) is ""
field.on "input", ->
field.on 'input', ->
if rstrip($(@).val()) is ""
closest_submit.disable()
else
closest_submit.enable()
# Disable button if any input field with given selector is empty
window.disableButtonIfEmptyField = (form, form_selector, button_selector) ->
window.disableButtonIfAnyEmptyField = (form, form_selector, button_selector) ->
closest_submit = form.find(button_selector)
empty = false
form.find('input').filter(form_selector).each ->
......
......@@ -16,7 +16,7 @@ class Labels
# Initializes the form to disable the save button if no color or title is entered
setupLabelForm: (form) ->
disableButtonIfEmptyField form, '.form-control', form.find('.js-save-button')
disableButtonIfAnyEmptyField form, '.form-control', form.find('.js-save-button')
# Updates the the preview color with the hex-color input
updateColorPreview: =>
......@@ -28,6 +28,8 @@ class Labels
color = $(e.currentTarget).data('color')
$('input#label_color').val(color)
@updateColorPreview()
# Notify the form, that color has changed
$('.label-form').trigger('keyup')
e.preventDefault()
@Labels = Labels
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