contact.html 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. {{ $ := .root }}
  2. {{ $st := .page }}
  3. {{ $autolink := default true $st.Params.content.autolink }}
  4. {{ $data := site.Params }}
  5. {{ $form_provider := lower $st.Params.contents.form.provider | default "" }}
  6. {{ $form_provider_legacy := $st.Params.email_form | default 0 }}
  7. {{ $use_netlify_form := eq $form_provider "netlify" | or (eq $form_provider_legacy 1) }}
  8. {{ $use_formspree_form := eq $form_provider "formspree" | or (eq $form_provider_legacy 2) }}
  9. {{ $use_form := or $use_netlify_form $use_formspree_form }}
  10. {{ $columns := $st.Params.design.columns | default "2" }}
  11. <div class="col-12 {{if eq $columns "2"}}col-lg-8{{end}}">
  12. {{ with $st.Content }}{{ . }}{{ end }}
  13. {{ if $use_form }}
  14. {{ $post_action := "" }}
  15. {{ if $use_netlify_form }}
  16. {{ $post_action = "netlify" }}
  17. {{ else if $use_formspree_form }}
  18. {{ if not $st.Params.contents.form.formspree.id }}
  19. {{ errorf "You have chosen to use Formspree as the provider for the contact form. Please set your Formspree Form ID in the Contact widget or disable the form." }}
  20. {{ errorf "Documentation: https://wowchemy.com/docs/page-builder/#contact" }}
  21. {{ end }}
  22. {{ $post_action = printf "action=\"https://formspree.io/f/%s\"" $st.Params.contents.form.formspree.id }}
  23. {{end}}
  24. <div class="mb-3">
  25. <form name="contact" method="POST" {{ $post_action | safeHTMLAttr }} {{ if $use_netlify_form }}netlify-honeypot="welcome-bot"{{end}} {{ if $st.Params.contents.form.netlify.captcha }}data-netlify-recaptcha="true"{{end}}>
  26. <div class="form-group form-inline">
  27. <label class="sr-only" for="inputName">{{ i18n "contact_name" }}</label>
  28. <input type="text" name="name" class="form-control w-100" id="inputName" placeholder="{{ i18n "contact_name" | default "Name" }}" required>
  29. </div>
  30. <div class="form-group form-inline">
  31. <label class="sr-only" for="inputEmail">{{ i18n "contact_email" }}</label>
  32. <input type="email" name="email" class="form-control w-100" id="inputEmail" placeholder="{{ i18n "contact_email" | default "Email" }}" required>
  33. </div>
  34. <div class="form-group">
  35. <label class="sr-only" for="inputMessage">{{ i18n "contact_message" }}</label>
  36. <textarea name="message" class="form-control" id="inputMessage" rows="5" placeholder="{{ i18n "contact_message" | default "Message" }}" required></textarea>
  37. </div>
  38. {{ if $use_netlify_form }}
  39. <div class="d-none">
  40. <label>Do not fill this field unless you are a bot: <input name="welcome-bot"></label>
  41. </div>
  42. {{ if $st.Params.contents.form.netlify.captcha }}
  43. <div class="form-group" data-netlify-recaptcha="true"></div>
  44. {{ end }}
  45. {{ end }}
  46. <button type="submit" class="btn btn-outline-primary px-3 py-2">{{ i18n "contact_send" | default "Send" }}</button>
  47. </form>
  48. </div>
  49. {{end}}
  50. <ul class="fa-ul">
  51. {{ if and $data.email (not $use_form) }}
  52. <li>
  53. <i class="fa-li fas fa-envelope fa-2x" aria-hidden="true"></i>
  54. <span id="person-email">
  55. {{- if $autolink }}<a href="mailto:{{ $data.email }}">{{ $data.email }}</a>{{ else }}{{ $data.email }}{{ end -}}
  56. </span>
  57. </li>
  58. {{ end }}
  59. {{ with $data.phone }}
  60. <li>
  61. <i class="fa-li fas fa-phone fa-2x" aria-hidden="true"></i>
  62. <span id="person-telephone">
  63. {{- if $autolink }}<a href="tel:{{ . }}">{{ . }}</a>{{ else }}{{ . }}{{ end -}}
  64. </span>
  65. </li>
  66. {{ end }}
  67. {{ $addr_formatted := "" }}{{/* Scoping for maps. */}}
  68. {{ if $data.address.street | or $data.address.city | or $data.address.region | or $data.address.postcode | or $data.address.country }}
  69. {{ $addr_formatted = partial "functions/get_address" (dict "root" . "address" $data.address) }}
  70. <li>
  71. <i class="fa-li fas fa-map-marker fa-2x" aria-hidden="true"></i>
  72. <span id="person-address">{{$addr_formatted}}</span>
  73. </li>
  74. {{ end }}
  75. {{ with $data.directions }}
  76. <li>
  77. <i class="fa-li fas fa-compass fa-2x" aria-hidden="true"></i>
  78. <span>{{ . | markdownify | emojify }}</span>
  79. </li>
  80. {{ end }}
  81. {{ with $data.office_hours }}
  82. <li>
  83. <i class="fa-li fas fa-clock fa-2x" aria-hidden="true"></i>
  84. <span>
  85. {{- if not (reflect.IsSlice .)}}{{/* Support legacy string format. */}}
  86. {{- . | markdownify | emojify -}}
  87. {{else}}
  88. {{- delimit . "<br>" | markdownify | emojify -}}
  89. {{end -}}
  90. </span>
  91. </li>
  92. {{ end }}
  93. {{ with $data.appointment_url }}
  94. <li>
  95. <i class="fa-li fas fa-calendar-check fa-2x" aria-hidden="true"></i>
  96. <a href="{{ . }}" target="_blank" rel="noopener">{{ i18n "book_appointment" | default "Book an appointment" }}</a>
  97. </li>
  98. {{ end }}
  99. {{/* Contact links. */}}
  100. {{ range $data.contact_links }}
  101. {{ $pack := or .icon_pack "fas" }}
  102. {{ $pack_prefix := $pack }}
  103. {{ if in (slice "fab" "fas" "far" "fal") $pack }}
  104. {{ $pack_prefix = "fa" }}
  105. {{ end }}
  106. {{ $link := .link }}
  107. {{ $scheme := (urls.Parse $link).Scheme }}
  108. {{ $target := "" }}
  109. {{ if not $scheme }}
  110. {{ $link = .link | relLangURL }}
  111. {{ else if in (slice "http" "https") $scheme }}
  112. {{ $target = "target=\"_blank\" rel=\"noopener\"" }}
  113. {{ end }}
  114. <li>
  115. <i class="fa-li {{ $pack }} {{ $pack_prefix }}-{{ .icon }} fa-2x" aria-hidden="true"></i>
  116. <a href="{{ $link | safeURL }}" {{ $target | safeHTMLAttr }}>{{.name|markdownify|emojify|safeHTML}}</a>
  117. </li>
  118. {{ end }}
  119. </ul>
  120. {{ if and site.Params.map.engine $data.coordinates.latitude }}
  121. <div class="d-none">
  122. <input id="map-provider" value="{{ site.Params.map.engine }}">
  123. <input id="map-lat" value="{{ $data.coordinates.latitude }}">
  124. <input id="map-lng" value="{{ $data.coordinates.longitude }}">
  125. <input id="map-dir" value="{{ $addr_formatted }}">
  126. <input id="map-zoom" value="{{ site.Params.map.zoom | default "15" }}">
  127. <input id="map-api-key" value="{{ site.Params.map.api_key }}">
  128. </div>
  129. <div id="map"></div>
  130. {{ end }}
  131. </div>