2 on('notifications:recount',
4 var menu = $('.notification-menu');
5 n = $('.notification', menu).not('.empty').length;
6 $('.notification-count', menu).html(n>0 ? n : '');
8 on('ajax:success', 'form.new_authorized_key',
9 function(e, data, status, xhr) {
10 $(e.target).parents('.notification').eq(0).fadeOut('slow', function() {
11 $('<li class="alert alert-success daxalert">SSH key added.</li>').hide().replaceAll(this).fadeIn('slow');
12 $(document).trigger('notifications:recount');
15 on('ajax:complete', 'form.new_authorized_key',
16 function(e, data, status, xhr) {
17 $($('input[name=disable_element]', e.target).val()).
20 on('ajax:error', 'form.new_authorized_key',
21 function(e, xhr, status, error) {
23 response = $.parseJSON(xhr.responseText);
24 error_div = $(e.target).parent().find('div.ajax-errors');
25 if (error_div.length == 0) {
26 $(e.target).parent().append('<div class="alert alert-error ajax-errors"></div>');
27 error_div = $(e.target).parent().find('div.ajax-errors');
29 if (response.errors) {
30 error_div.html($('<p/>').text(response.errors).html());
32 error_div.html('<p>Sorry, request failed.</p>');
35 $($('input[name=disable_element]', e.target).val()).
38 on('click', 'form[data-remote] input[type=submit]',
40 $(e.target).parents('form').eq(0).parent().find('div.ajax-errors').html('').hide();
43 find('input[name=disable_element]').