summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2016-06-10 09:22:59 +0100
committerPhil Hughes <me@iamphill.com>2016-06-10 09:25:12 +0100
commit2c5f343fe800ed6aaf1e499925ce003a19d8e179 (patch)
treefd4340753b076019fa4104569dcbab86a2896017
parent2889e29c5cffe31fc7b1750a83c89046594c481b (diff)
downloadgitlab-ce-custom-notification-modal-window.tar.gz
Moved beforeSend into a methodcustom-notification-modal-window
Fixed JS style issues
-rw-r--r--app/assets/javascripts/notifications_form.js.coffee19
-rw-r--r--app/assets/javascripts/project.js.coffee8
2 files changed, 15 insertions, 12 deletions
diff --git a/app/assets/javascripts/notifications_form.js.coffee b/app/assets/javascripts/notifications_form.js.coffee
index e3212c0311f..cfe8e133b66 100644
--- a/app/assets/javascripts/notifications_form.js.coffee
+++ b/app/assets/javascripts/notifications_form.js.coffee
@@ -12,24 +12,27 @@ class @NotificationsForm
$(document).on 'change', '.js-custom-notification-event', @toggleCheckbox
toggleCheckbox: (e) =>
- $checkbox = $(e.target)
+ $checkbox = $(e.currentTarget)
$parent = $checkbox.closest('.checkbox')
@saveEvent($checkbox, $parent)
+ showCheckboxLoadingSpinner: ($parent) ->
+ $parent
+ .addClass 'is-loading'
+ .find '.custom-notification-event-loading'
+ .removeClass 'fa-check'
+ .addClass 'fa-spin fa-spinner'
+ .removeClass 'is-done'
+
saveEvent: ($checkbox, $parent) ->
$.ajax(
url: @form.attr('action')
method: 'patch'
dataType: 'json'
data: @form.serialize()
- beforeSend: ->
- $parent
- .addClass 'is-loading'
- .find '.custom-notification-event-loading'
- .removeClass 'fa-check'
- .addClass 'fa-spin fa-spinner'
- .removeClass 'is-done'
+ beforeSend: =>
+ @showCheckboxLoadingSpinner($parent)
).done (data) ->
$checkbox.enable()
diff --git a/app/assets/javascripts/project.js.coffee b/app/assets/javascripts/project.js.coffee
index 06d31965516..236f0899147 100644
--- a/app/assets/javascripts/project.js.coffee
+++ b/app/assets/javascripts/project.js.coffee
@@ -38,22 +38,22 @@ class @Project
.off 'click', '.update-notification'
.on 'click', '.update-notification', (e) ->
e.preventDefault()
- notification_level = $(@).data 'notification-level'
+ notificationLevel = $(@).data 'notification-level'
label = $(@).data 'notification-title'
$('.js-notification-loading').toggleClass 'fa-bell fa-spin fa-spinner'
- $('#notification_setting_level').val(notification_level)
+ $('#notification_setting_level').val(notificationLevel)
$('#notification-form').submit()
$(document)
.off 'ajax:success', '#notification-form'
.on 'ajax:success', '#notification-form', (e, data) ->
if data.saved
- new Flash("Notification settings saved", "notice")
+ new Flash('Notification settings saved', 'notice')
$('.js-notification-toggle-btns')
.closest('.notification-dropdown')
.replaceWith(data.html)
else
- new Flash("Failed to save new settings", "alert")
+ new Flash('Failed to save new settings', 'alert')
@projectSelectDropdown()