scripts.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. jQuery(document).ready(function() {
  2. /*
  3. Fullscreen background
  4. */
  5. $.backstretch("assets/img/backgrounds/1.jpg");
  6. $('#top-navbar-1').on('shown.bs.collapse', function(){
  7. $.backstretch("resize");
  8. });
  9. $('#top-navbar-1').on('hidden.bs.collapse', function(){
  10. $.backstretch("resize");
  11. });
  12. /*
  13. Contact form
  14. */
  15. $('.contact-form form input[type="text"], .contact-form form textarea').on('focus', function() {
  16. $('.contact-form form input[type="text"], .contact-form form textarea').removeClass('input-error');
  17. });
  18. $('.contact-form form').submit(function(e) {
  19. e.preventDefault();
  20. $('.contact-form form input[type="text"], .contact-form form textarea').removeClass('input-error');
  21. var postdata = $('.contact-form form').serialize();
  22. $.ajax({
  23. type: 'POST',
  24. url: 'assets/contact.php',
  25. data: postdata,
  26. dataType: 'json',
  27. success: function(json) {
  28. if(json.emailMessage != '') {
  29. $('.contact-form form .contact-email').addClass('input-error');
  30. }
  31. if(json.subjectMessage != '') {
  32. $('.contact-form form .contact-subject').addClass('input-error');
  33. }
  34. if(json.messageMessage != '') {
  35. $('.contact-form form textarea').addClass('input-error');
  36. }
  37. if(json.emailMessage == '' && json.subjectMessage == '' && json.messageMessage == '') {
  38. $('.contact-form form').fadeOut('fast', function() {
  39. $('.contact-form').append('<p>Thanks for contacting us! We will get back to you very soon.</p>');
  40. // reload background
  41. $.backstretch("resize");
  42. });
  43. }
  44. }
  45. });
  46. });
  47. });