Advertisement
Guest User

Untitled

a guest
May 26th, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.57 KB | None | 0 0
  1. <?php
  2. /**
  3. Template Name: Contact Page
  4. **/
  5.  
  6. get_header(); ?>
  7.  
  8. <!-- form validation scripts -->
  9. <script src="<?php bloginfo('template_url'); ?>/js/jquery.validate.min.js" type="text/javascript"></script>
  10. <script type="text/javascript">
  11. // initialize form validation
  12. jQuery(document).ready(function() {
  13. $j("#CommentForm").validate({
  14. submitHandler: function(form) {
  15. // form is valid, submit it
  16. ajaxContact(form);
  17. return false;
  18. }
  19. });
  20. });
  21. </script>
  22.  
  23.  
  24.  
  25. <?php
  26. if(have_posts()) :
  27. while(have_posts()) :
  28. the_post();
  29. ?>
  30. <!-- Page Content -->
  31. <div class="contentArea">
  32. <!-- Title / Page Headline -->
  33. <div class="full-page">
  34. <h1 class="headline"><strong><?php the_title(); ?></strong><?php
  35. if (get_theme_var("contactSubTitle") != '') {
  36. echo ' &nbsp;//&nbsp; '. get_theme_var("contactSubTitle");
  37. }
  38. ?></h1>
  39. </div>
  40.  
  41. <div class="hr"></div>
  42.  
  43. <!-- Breadcrumbs -->
  44. <div class="full-page">
  45. <p class="breadcrumbs">
  46. <?php show_breadcrumbs(); ?>
  47. </p>
  48. </div>
  49.  
  50. <!-- End of Content -->
  51. <div class="clear"></div>
  52. </div>
  53.  
  54. <div class="contentArea">
  55.  
  56.  
  57. <div class="half-page">
  58. <!-- Contact form -->
  59. <?php echo stripslashes(get_theme_var("contactContent")); ?>
  60.  
  61. <div id="Note"></div>
  62. <form class="cmxform" id="CommentForm" method="post" action="">
  63. <fieldset>
  64. <legend>Contact Form</legend>
  65. <div>
  66. <label for="ContactName" class="overlabel">Name</label>
  67. <input id="ContactName" name="ContactName" class="textInput required" />
  68. </div>
  69. <div>
  70. <label for="ContactEmail" class="overlabel">E-Mail</label>
  71. <input id="ContactEmail" name="ContactEmail" class="textInput required email" />
  72. </div>
  73. <div>
  74. <label for="ContactPhone" class="overlabel">Phone</label>
  75. <input id="ContactPhone" name="ContactPhone" class="textInput digits" value="" />
  76. </div>
  77. <div>
  78. <label for="ContactComment" class="overlabel">Comments</label>
  79. <textarea id="ContactComment" name="ContactComment" class="textInput required" rows="10" cols="4"></textarea>
  80. </div>
  81. <div>
  82. <button type="submit" class="btn"><span>Send</span></button>
  83. <input class="" type="hidden" name="to" value="<?php theme_var("contactEmail");?>" />
  84. <input class="" type="hidden" name="subject" value="<?php theme_var("contactEmailSubject");?>" />
  85. <label id="loader" style="display:none;"><img src="<?php echo bloginfo('template_url'); ?>/images/ajax-loader.gif" alt="Loading..." id="LoadingGraphic" /></label>
  86. </div>
  87. </fieldset>
  88. </form>
  89.  
  90. </div>
  91.  
  92. <div class="half-page">
  93. <?php the_content('More Information...'); ?>
  94. </div>
  95.  
  96. <!-- End of Content -->
  97. <div class="clear"></div>
  98. </div>
  99.  
  100. <!-- End of Content -->
  101. <div class="clear"></div>
  102. <?php
  103.  
  104. endwhile;
  105. endif;
  106. ?>
  107.  
  108. <script type="text/javascript">
  109.  
  110. // Contact form submit function
  111. function ajaxContact(theForm) {
  112. var $ = jQuery;
  113.  
  114. $('#loader').fadeIn();
  115.  
  116. var formData = $(theForm).serialize(),
  117. note = $('#Note');
  118.  
  119. $.ajax({
  120. type: "POST",
  121. url: "<?php echo bloginfo('template_url'); ?>/contact-send.php",
  122. data: formData,
  123. success: function(response) {
  124. if ( note.height() ) {
  125. note.fadeIn('fast', function() { $(this).hide(); });
  126. } else {
  127. note.hide();
  128. }
  129.  
  130. $('#LoadingGraphic').fadeOut('fast', function() {
  131. //$(this).remove();
  132. if (response === 'success') {
  133. $(theForm).animate({opacity: 0},'fast');
  134. }
  135.  
  136. // Message Sent? Show the 'Thank You' message and hide the form
  137. result = '';
  138. c = '';
  139. if (response === 'success') {
  140. result = '<?php
  141. if (get_theme_var("contactThankYouMessage") != '') {
  142. echo stripslashes(get_theme_var("contactThankYouMessage"));
  143. } else {
  144. echo "Your message has been sent. Thank you!";
  145. }?>';
  146. c = 'success';
  147. } else {
  148. result = response;
  149. c = 'error';
  150. }
  151.  
  152. note.removeClass('success').removeClass('error').text('');
  153. var i = setInterval(function() {
  154. if ( !note.is(':visible') ) {
  155. note.html(result).addClass(c).slideDown('fast');
  156. clearInterval(i);
  157. }
  158. }, 40);
  159. }); // end loading image fadeOut
  160. }
  161. });
  162.  
  163. return false;
  164. }
  165.  
  166. </script>
  167.  
  168.  
  169. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement