be_pages_generic_contact.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Document : be_pages_generic_contact.js
  3. * Author : pixelcave
  4. * Description: Custom JS code used in Contact Page in Backend
  5. */
  6. var BeContact = function() {
  7. // Init Contact Form Validation, for more examples you can check out https://github.com/jzaefferer/jquery-validation
  8. var initValidationContact = function(){
  9. jQuery('.js-validation-be-contact').validate({
  10. errorClass: 'invalid-feedback animated fadeInDown',
  11. errorElement: 'div',
  12. errorPlacement: function(error, e) {
  13. jQuery(e).after(error);
  14. },
  15. highlight: function(e) {
  16. jQuery(e).removeClass('is-invalid').addClass('is-invalid');
  17. },
  18. success: function(e) {
  19. jQuery(e).prev().removeClass('is-invalid');
  20. jQuery(e).remove();
  21. },
  22. rules: {
  23. 'be-contact-name': {
  24. required: true,
  25. minlength: 2
  26. },
  27. 'be-contact-email': {
  28. required: true,
  29. email: true
  30. },
  31. 'be-contact-subject': {
  32. required: true
  33. },
  34. 'be-contact-message': {
  35. required: true,
  36. minlength: 2
  37. }
  38. },
  39. messages: {
  40. 'be-contact-name': 'Please provide at least your first name',
  41. 'be-contact-email': 'Please enter your valid email address to be able to reach you back',
  42. 'be-contact-subject': 'Please select where woul you like to send your message',
  43. 'be-contact-message': 'What would you like to say?'
  44. }
  45. });
  46. };
  47. // Init Contact Map, for more examples you can check out https://hpneo.github.io/gmaps/
  48. var initMapContact = function(){
  49. if ( jQuery('#js-map-be-contact').length ) {
  50. new GMaps({
  51. div: '#js-map-be-contact',
  52. lat: 37.840,
  53. lng: -122.500,
  54. zoom: 13,
  55. disableDefaultUI: true,
  56. scrollwheel: false
  57. }).addMarkers([
  58. {lat: 37.840, lng: -122.500, title: 'Marker #1', animation: google.maps.Animation.DROP, infoWindow: {content: 'Company LTD'}}
  59. ]);
  60. }
  61. };
  62. return {
  63. init: function () {
  64. // Init Contact Form Validation
  65. initValidationContact();
  66. // Init Contact Map
  67. initMapContact();
  68. }
  69. };
  70. }();
  71. // Initialize when page loads
  72. jQuery(function(){ BeContact.init(); });