summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/notifications_dropdown.js
diff options
context:
space:
mode:
authorFatih Acet <acetfatih@gmail.com>2016-07-22 17:01:57 +0300
committerFatih Acet <acetfatih@gmail.com>2016-07-22 17:07:29 +0300
commitbc3f33f92a16d3afdb8a472f60940e7c46a31564 (patch)
treec6e568504b7888591ad15586bb1ace99db8941ca /app/assets/javascripts/notifications_dropdown.js
parent033e5423a2594e08a7ebcd2379bd2331f4c39032 (diff)
downloadgitlab-ce-jsify.tar.gz
JSify all the things!jsify
Diffstat (limited to 'app/assets/javascripts/notifications_dropdown.js')
-rw-r--r--app/assets/javascripts/notifications_dropdown.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/app/assets/javascripts/notifications_dropdown.js b/app/assets/javascripts/notifications_dropdown.js
new file mode 100644
index 00000000000..a08bb596d5d
--- /dev/null
+++ b/app/assets/javascripts/notifications_dropdown.js
@@ -0,0 +1,27 @@
+this.NotificationsDropdown = (function() {
+ function NotificationsDropdown() {
+ $(document).off('click', '.update-notification').on('click', '.update-notification', function(e) {
+ var form, label, notificationLevel;
+ e.preventDefault();
+ if ($(this).is('.is-active') && $(this).data('notification-level') === 'custom') {
+ return;
+ }
+ notificationLevel = $(this).data('notification-level');
+ label = $(this).data('notification-title');
+ form = $(this).parents('.notification-form:first');
+ form.find('.js-notification-loading').toggleClass('fa-bell fa-spin fa-spinner');
+ form.find('#notification_setting_level').val(notificationLevel);
+ return form.submit();
+ });
+ $(document).off('ajax:success', '.notification-form').on('ajax:success', '.notification-form', function(e, data) {
+ if (data.saved) {
+ return $(e.currentTarget).closest('.notification-dropdown').replaceWith(data.html);
+ } else {
+ return new Flash('Failed to save new settings', 'alert');
+ }
+ });
+ }
+
+ return NotificationsDropdown;
+
+})();