Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove jQuery #35

Merged
merged 7 commits into from
Mar 6, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Started removing jQuery from contact.js
  • Loading branch information
tomanistor committed Feb 20, 2018
commit 3910027505f60f76def8be329d6f14ece9832c67
2 changes: 1 addition & 1 deletion layouts/partials/body-top.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ <h1>{{ .Site.Params.tagline }}<span class="cursor">|</span></h1>

<nav class="row middle-xs center-xs">
<div class="col-xs-6 col-sm-1 logo">
<a href="{{ .Site.BaseURL }}"><img src="{{ .Site.Params.logoSmall }}" alt="{{ .Site.Title }}"></a>
<a href="{{ .Site.BaseURL }}#"><img src="{{ .Site.Params.logoSmall }}" alt="{{ .Site.Title }}"></a>
</div>
{{ range .Site.Menus.main }}
<div class="col-xs-3 col-sm-2">
Expand Down
1 change: 1 addition & 0 deletions static/scripts/contact-034d3a12.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion static/scripts/contact-2c079c75.js

This file was deleted.

75 changes: 45 additions & 30 deletions static/scripts/src/contact.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,52 @@
$("#form-contact").on("submit", function(e) {
$('#form-contact').addEventListener('submit', function(e) {
e.preventDefault();

// Store form field values
var name = $("input[name=name]").val();
var email = $("input[name=email").val();
var subject = $("input[name=_subject").val();
var message = $("textarea[name=message]").val();
var name = $("input[name=name]").value;
var email = $("input[name=email").value;
var subject = $("input[name=_subject").value;
var message = $("textarea[name=message]").value;

// AJAX request
var request = new XMLHttpRequest();
var data = {
name:name,
_replyto:email,
email:email,
_subject:subject,
message:message,
}

// Send to Formspree
$.ajax({
url:"https://formspree.io/{{ .Site.Params.email }}",
method:"POST",
data:{
name:name,
_replyto:email,
email:email,
_subject:subject,
message:message,
},
dataType:"json",
success:function() {
console.log("Form successfully sent");
// Reset form
$("#form-contact").get(0).reset();
// Fade out submit button, fade in thank you message, then fade out message and fade in submit button
$("#form-submit").fadeOut(function(){
$("#form-thankyou").fadeIn(function(){
$("#form-thankyou").delay(4000).fadeOut(function(){
$("#form-submit").fadeIn();
});
});
});
}
});
request.open('POST', 'https://formspree.io/{{ .Site.Params.email }}', true);
request.setRequestHeader('Content-Type', 'application/json; charset=UTF-8');
request.send(JSON.stringify(data));


// $.ajax({
// url:"https://formspree.io/{{ .Site.Params.email }}",
// method:"POST",
// data:{
// name:name,
// _replyto:email,
// email:email,
// _subject:subject,
// message:message,
// },
// dataType:"json",
// success:function() {
// console.log("Form successfully sent");
// // Reset form
// $("#form-contact").get(0).reset();
// // Fade out submit button, fade in thank you message, then fade out message and fade in submit button
// $("#form-submit").fadeOut(function(){
// $("#form-thankyou").fadeIn(function(){
// $("#form-thankyou").delay(4000).fadeOut(function(){
// $("#form-submit").fadeIn();
// });
// });
// });
// }
// });

});