46 lines
1.2 KiB
JavaScript
46 lines
1.2 KiB
JavaScript
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
|
// MIT License. See license.txt
|
|
|
|
frappe.ready(function() {
|
|
|
|
if(frappe.utils.get_url_arg('subject')) {
|
|
$('[name="subject"]').val(frappe.utils.get_url_arg('subject'));
|
|
}
|
|
|
|
$('.btn-send').off("click").on("click", function() {
|
|
var email = $('[name="email"]').val();
|
|
var message = $('[name="message"]').val();
|
|
|
|
if(!(email && message)) {
|
|
frappe.msgprint('{{ _("Please enter both your email and message so that we can get back to you. Thanks!") }}');
|
|
return false;
|
|
}
|
|
|
|
if(!validate_email(email)) {
|
|
frappe.msgprint('{{ _("You seem to have written your name instead of your email. Please enter a valid email address so that we can get back.") }}');
|
|
$('[name="email"]').focus();
|
|
return false;
|
|
}
|
|
|
|
$("#contact-alert").toggle(false);
|
|
frappe.call({
|
|
type: "POST",
|
|
method: "frappe.www.contact.send_message",
|
|
args: {
|
|
subject: $('[name="subject"]').val(),
|
|
sender: email,
|
|
message: message,
|
|
},
|
|
callback: function(r) {
|
|
if (!r.exc) {
|
|
frappe.msgprint('{{ _("Thank you for your message") }}', '{{ _("Message Sent") }}');
|
|
}
|
|
$(':input').val('');
|
|
},
|
|
});
|
|
});
|
|
});
|
|
|
|
var msgprint = function(txt) {
|
|
if(txt) $("#contact-alert").html(txt).toggle(true);
|
|
}
|