3112: report issue success event handling working in 404 error page.
[arvados.git] / apps / workbench / app / assets / javascripts / report_issue.js
1 $(document).
2   on('click', "#report-issue-submit", function(e){
3     $(this).html('Sending');
4     $(this).attr('disabled', true);
5     var $cancelButton = $('#report-issue-cancel');
6     if ($cancelButton) {
7       $cancelButton.html('Close');
8     }
9     $('div').remove('.modal-footer-status');
10
11     $.ajax('/').
12       success(function(data, status, jqxhr) {
13         var $sendButton = $('#report-issue-submit');
14         $sendButton.html('Report sent');
15         $('div').remove('.modal-footer-status');
16         $('.modal-footer').append('<div class="modal-footer-status alert alert-success"><div><p align="left">Thanks for reporting this issue!</p></div></div>');
17       }).
18       fail(function(jqxhr, status, error) {
19         var $sendButton = $('#report-issue-submit');
20         if ($sendButton && $sendButton.prop('disabled')) {
21         $('div').remove('.modal-footer-status');
22         $('.modal-footer').append('<div class="modal-footer-status alert alert-danger"></br><p align="left">We are sorry. We could not submit your report! We really want this to work, though -- please try again.</p></div>');
23         $sendButton.html('Send problem report');
24         $sendButton.attr('disabled',false);
25       }
26         var $cancelButton = $('#report-issue-cancel');
27         var text = document.getElementById('report-issue-cancel').firstChild;
28         $cancelButton.html('Cancel');
29       });
30
31   });