3112: ajax event handling on form not working. reverting back to document for now.
[arvados.git] / apps / workbench / app / assets / javascripts / report_issue.js
1 // ajax handling for report-issue function
2 $(document).
3   on('ajax:send', function() {
4     var $sendButton = $('#report-issue-submit');
5     if ($sendButton) {
6       $sendButton.html('Sending...');
7       $sendButton.attr('disabled',true);
8     }
9     var $cancelButton = $('#report-issue-cancel');
10     if ($cancelButton) {
11       $cancelButton.html('Close');
12     }
13     $('div').remove('.modal-footer-status');
14   }).
15   on('ajax:success', function() {
16     var $sendButton = $('#report-issue-submit');
17     if ($sendButton  && $sendButton.prop('disabled')) {
18       $sendButton.html('Report sent');
19       $('div').remove('.modal-footer-status');
20       $('.modal-footer').append('<div class="modal-footer-status alert alert-success"><div><p align="left">Thanks for reporting this issue!</p></div></div>');
21     }
22   }).
23   on('ajax:failure', function() {
24     var $sendButton = $('#report-issue-submit');
25     if ($sendButton && $sendButton.prop('disabled')) {
26       $('div').remove('.modal-footer-status');
27       $('.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>');
28       $sendButton.html('Send problem report');
29       $sendButton.attr('disabled',false);
30     }
31     var $cancelButton = $('#report-issue-cancel');
32     if ($cancelButton) {
33       var text = document.getElementById('report-issue-cancel').firstChild;
34       $cancelButton.html('Cancel');
35     }
36   });