3781: Fix progress% (100, not NaN) and manifest format (>=1 data locator) for zero...
[arvados.git] / apps / workbench / app / assets / javascripts / users.js
1 $(document).
2     on('notifications:recount',
3        function() {
4            var menu = $('.notification-menu');
5            n = $('.notification', menu).not('.empty').length;
6            $('.notification-count', menu).html(n>0 ? n : '');
7        }).
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');
13            });
14        }).
15     on('ajax:complete', 'form.new_authorized_key',
16        function(e, data, status, xhr) {
17            $($('input[name=disable_element]', e.target).val()).
18                fadeTo(200, 1.0);
19        }).
20     on('ajax:error', 'form.new_authorized_key',
21        function(e, xhr, status, error) {
22            var error_div;
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');
28            }
29            if (response.errors) {
30                error_div.html($('<p/>').text(response.errors).html());
31            } else {
32                error_div.html('<p>Sorry, request failed.');
33            }
34            error_div.show();
35            $($('input[name=disable_element]', e.target).val()).
36                fadeTo(200, 1.0);
37        }).
38     on('click', 'form[data-remote] input[type=submit]',
39        function(e) {
40            $(e.target).parents('form').eq(0).parent().find('div.ajax-errors').html('').hide();
41            $($(e.target).
42              parents('form').
43              find('input[name=disable_element]').
44              val()).
45                fadeTo(200, 0.3);
46            return true;
47        });