newsletter-subscription.phtml 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * @version 7.9 [rev.7.9.02]
  4. */
  5. ?>
  6. <h5><?php echo $this->_('Subscribe to Newsletter'); ?></h5>
  7. <form method="post"
  8. class="form-inline"
  9. action="<?php echo $this->url(array('module' => 'app', 'controller' => 'async', 'action' => 'newsletter-subscription')); ?>"
  10. id="form-newsletter-subscription">
  11. <input type="text" name="email" value="" class="form-control input-medium"
  12. placeholder="<?php echo $this->_('Enter your email address'); ?>">
  13. <button type="submit" name="submit" class="btn btn-primary"><?php echo $this->_('Subscribe'); ?></button>
  14. <div class="message"></div>
  15. </form>
  16. <script type="text/javascript">
  17. $(document).ready(function () {
  18. // submit modal forms in the modal box, and replace the current html with the response html
  19. $('#form-newsletter-subscription').find('[type=submit]').on('click', function (e) {
  20. e.preventDefault();
  21. var newsletterSubmitButton = $(this);
  22. var newsletterSubmitValue = newsletterSubmitButton.text();
  23. newsletterSubmitButton.attr('disabled', true).text('Please wait..');
  24. var newsletterSubscriptionForm = $(this).closest('form');
  25. $.ajax({
  26. type: newsletterSubscriptionForm.attr('method'),
  27. url: newsletterSubscriptionForm.attr('action'),
  28. data: newsletterSubscriptionForm.serialize(),
  29. success: function (data) {
  30. newsletterSubmitButton.attr('disabled', false).text(newsletterSubmitValue);
  31. newsletterSubscriptionForm.find('.message').html(data.message);
  32. newsletterSubscriptionForm.find('[name="email"]').val('');
  33. setTimeout(function() {
  34. newsletterSubscriptionForm.find('.message').html('');
  35. }, 5000);
  36. }
  37. });
  38. });
  39. });
  40. </script>