Convert user feedback mechanism to use modal dialog

instead of navigating to new page.  this is how it should have been done
to begin with...
This commit is contained in:
Lance Edgar 2017-10-13 08:01:43 -07:00
parent 827cc592b4
commit 8d002f76d2
5 changed files with 143 additions and 6 deletions

View file

@ -204,3 +204,40 @@ body > #body-wrapper {
position: absolute;
width: 100%;
}
/******************************
* feedback
******************************/
#feedback-dialog {
display: none;
}
#feedback-dialog p {
margin-top: 1em;
}
#feedback-dialog .red {
color: red;
font-weight: bold;
}
#feedback-dialog .field-wrapper {
margin-top: 1em;
padding: 0;
}
#feedback-dialog .field {
margin-bottom: 0;
margin-top: 0.5em;
}
#feedback-dialog .referrer .field {
clear: both;
float: none;
margin-top: 1em;
}
#feedback-dialog textarea {
width: auto;
}

View file

@ -0,0 +1,58 @@
$(function() {
$('#feedback').click(function() {
var dialog = $('#feedback-dialog');
var form = dialog.find('form');
var textarea = form.find('textarea');
dialog.find('.referrer .field').html(location.href);
textarea.val('');
dialog.dialog({
title: "User Feedback",
width: 500,
modal: true,
buttons: [
{
text: "Send",
click: function(event) {
var msg = $.trim(textarea.val());
if (! msg) {
alert("Please enter a message.");
textarea.select();
textarea.focus();
return;
}
disable_button(dialog_button(event));
var data = {
_csrf: form.find('input[name="_csrf"]').val(),
referrer: location.href,
user: form.find('input[name="user"]').val(),
user_name: form.find('input[name="user_name"]').val(),
message: msg
};
$.ajax(form.attr('action'), {
method: 'POST',
data: data,
success: function(data) {
dialog.dialog('close');
alert("Message successfully sent.\n\nThank you for your feedback.");
}
});
}
},
{
text: "Cancel",
click: function() {
dialog.dialog('close');
}
}
]
});
});
});