1 $("#report-issue-modal-window").html("<%= escape_javascript(render partial: 'report_issue_popup') %>");
3 // reset form input fields, for the next time around
4 function reset_form() {
5 $('#report_issue_text').val("");
6 $('#additional_info').val("");
9 // ajax handling for report-issue function
11 on('ajax:send', function() {
12 var sendButton = document.getElementById('report-issue-submit');
14 var text = document.getElementById('report-issue-submit').firstChild;
15 text.data = "Sending...";
16 sendButton.disabled = true;
18 var cancelButton = document.getElementById('report-issue-cancel');
20 var text = document.getElementById('report-issue-cancel').firstChild;
23 $('div').remove('.modal-footer-status');
25 on('ajax:success', function() {
26 var sendButton = document.getElementById('report-issue-submit');
27 if (sendButton && sendButton.disabled) {
28 var text = document.getElementById('report-issue-submit').firstChild;
29 text.data = "Report sent";
30 $('div').remove('.modal-footer-status');
31 $('.modal-footer').append('<div class="modal-footer-status alert alert-success"><div><p align="left">Thanks for reporting this issue!</p></div></div>');
34 on('ajax:failure', function() {
35 var sendButton = document.getElementById('report-issue-submit');
36 if (sendButton && sendButton.disabled) {
37 $('div').remove('.modal-footer-status');
38 $('.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>');
39 var text = document.getElementById('report-issue-submit').firstChild;
40 text.data = "Report issue";
41 sendButton.disabled = false;
43 var cancelButton = document.getElementById('report-issue-cancel');
45 var text = document.getElementById('report-issue-cancel').firstChild;