Advertisement
Guest User

Untitled

a guest
Nov 17th, 2014
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 0 0
  1. var sendEmailDiv = document.getElementById("send-email");
  2.  
  3. initContactButton();
  4.  
  5. function initContactButton()
  6. {
  7. if (deviceName == "computer")
  8. {
  9. sendEmailDiv.onclick = function() {sendEmail()};
  10. }
  11. else //using touchstart to replace onclick on mobile device since touchevents are used
  12. {
  13. sendEmailDiv.addEventListener("touchstart", sendEmail, false);
  14. }
  15. }
  16.  
  17. function sendEmail()
  18. {
  19. hideContactConfirmationContainer(); //function from main.js
  20. positionContactConfirmationContainer(); //function from main.js
  21.  
  22. var isSubjectFilled;
  23. var isMessageFilled;
  24.  
  25. var emailAddress = $("#email-address").val();
  26. var emailSubject = $("#email-subject").val();
  27. var emailMessage = $("#email-message").val();
  28.  
  29. if (!emailAddress.match(/^([a-z0-9._-]+@[a-z0-9._-]+\.[a-z]{2,4}$)/i))
  30. {
  31. focusEmail(); //function from main.js
  32. setTimeout("showContactConfirmationContainer(0)",200); //function from main.js, setTimeout for ie since its focus is late
  33. }
  34. else
  35. {
  36. if (emailMessage.length < 1)
  37. {
  38. isMessageFilled = false;
  39. focusMessage(); //function from main.js
  40. }
  41.  
  42. if (emailMessage.length >= 1)
  43. {
  44. isMessageFilled = true;
  45. }
  46.  
  47. if (emailSubject.length < 1)
  48. {
  49. isSubjectFilled = false;
  50. focusSubject(); //function from main.js
  51. }
  52.  
  53. if (emailSubject.length >= 1)
  54. {
  55. isSubjectFilled = true;
  56. }
  57.  
  58. if ((isSubjectFilled == true) && (isMessageFilled == true))
  59. {
  60. var datastr ='email-address=' + emailAddress + '&email-subject=' + emailSubject + '&email-message=' + emailMessage;
  61.  
  62. setTimeout("showContactConfirmationContainer(2)",200); //function from main.js, setTimeout for ie since its focus is late
  63.  
  64. setTimeout("send('"+datastr+"')",2000);
  65. }
  66. else
  67. {
  68. setTimeout("showContactConfirmationContainer(1)",200); //function from main.js, setTimeout for ie since its focus is late
  69. }
  70. }
  71.  
  72. return false;
  73. }
  74.  
  75. function send(datastr){
  76. $.ajax({
  77. type: "POST",
  78. url: "email.php",
  79. data: datastr,
  80. cache: false,
  81. success: function(html){
  82.  
  83. hideContactConfirmationContainer(); //function from main.js
  84. positionContactConfirmationContainer(); //function from main.js
  85. setTimeout("showContactConfirmationContainer(4)",200); //function from main.js, setTimeout for ie since its focus is late
  86.  
  87. clearAllInputField(); //function from main.js
  88. }
  89. });
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement