|
1 | 1 | {% block ewz_recaptcha_widget %} |
2 | 2 | {% apply spaceless %} |
3 | | - {% if form.vars.ewz_recaptcha_enabled %} |
4 | | - {% if not form.vars.ewz_recaptcha_ajax %} |
5 | | - {% if attr.options.size == 'invisible' and attr.options.callback is not defined %} |
6 | | - {% set options = attr.options|merge({'callback': 'onReCaptchaSuccess'}) %} |
7 | | - {% set attr = attr|merge({'options': options}) %} |
| 3 | + {% if form.vars.ewz_recaptcha_enabled %} |
| 4 | + {% if not form.vars.ewz_recaptcha_ajax %} |
| 5 | + {% if attr.options.size == 'invisible' and attr.options.callback is not defined %} |
| 6 | + {% set options = attr.options|merge({'callback': 'onReCaptchaSuccess'}) %} |
| 7 | + {% set attr = attr|merge({'options': options}) %} |
8 | 8 |
|
9 | | - <script> |
10 | | - var onReCaptchaSuccess = function() { |
11 | | - var errorDivs = document.getElementsByClassName('recaptcha-error'); |
12 | | - if (errorDivs.length) { |
13 | | - errorDivs[0].className = ''; |
14 | | - } |
| 9 | + <script> |
| 10 | + var onReCaptchaSuccess = function() { |
| 11 | + var errorDivs = document.getElementsByClassName('recaptcha-error'); |
| 12 | + if (errorDivs.length) { |
| 13 | + errorDivs[0].className = ''; |
| 14 | + } |
15 | 15 |
|
16 | | - var errorMsgs = document.getElementsByClassName('recaptcha-error-message'); |
17 | | - if (errorMsgs.length) { |
18 | | - errorMsgs[0].parentNode.removeChild(errorMsgs[0]); |
19 | | - } |
| 16 | + var errorMsgs = document.getElementsByClassName('recaptcha-error-message'); |
| 17 | + if (errorMsgs.length) { |
| 18 | + errorMsgs[0].parentNode.removeChild(errorMsgs[0]); |
| 19 | + } |
20 | 20 |
|
21 | | - var forms = document.getElementsByClassName('recaptcha-form'); |
22 | | - if (forms.length) { |
23 | | - var recaptchaSubmitEvent = document.createEvent('Event'); |
24 | | - recaptchaSubmitEvent.initEvent('submit', true, true); |
25 | | - forms[0].addEventListener('submit', function (e) { |
26 | | - e.target.submit(); |
27 | | - }, false); |
28 | | - forms[0].dispatchEvent(recaptchaSubmitEvent); |
29 | | - } |
30 | | - }; |
31 | | - </script> |
32 | | - {% endif %} |
| 21 | + var forms = document.getElementsByClassName('recaptcha-form'); |
| 22 | + if (forms.length) { |
| 23 | + var recaptchaSubmitEvent = document.createEvent('Event'); |
| 24 | + recaptchaSubmitEvent.initEvent('submit', true, true); |
| 25 | + forms[0].addEventListener('submit', function (e) { |
| 26 | + e.target.submit(); |
| 27 | + }, false); |
| 28 | + forms[0].dispatchEvent(recaptchaSubmitEvent); |
| 29 | + } |
| 30 | + }; |
| 31 | + </script> |
| 32 | + {% endif %} |
33 | 33 |
|
34 | | - <script src="{{ form.vars.url_challenge }}" |
35 | | - {%- if attr.options.defer is defined and attr.options.defer %} defer{% endif -%} |
36 | | - {%- if attr.options.async is defined and attr.options.async %} async{% endif -%} |
37 | | - ></script> |
38 | | - <div class="g-recaptcha" data-theme="{{ attr.options.theme }}" data-size="{{ attr.options.size }}" data-type="{{ attr.options.type }}" data-sitekey="{{ form.vars.public_key }}" |
39 | | - {%- if attr.options.callback is defined %} data-callback="{{ attr.options.callback }}"{% endif -%} |
40 | | - {%- if attr.options.errorCallback is defined %} data-error-callback="{{ attr.options.errorCallback }}"{% endif -%} |
41 | | - {%- if attr.options.expiredCallback is defined %} data-expired-callback="{{ attr.options.expiredCallback }}"{% endif -%} |
42 | | - {%- if attr.options.bind is defined %} data-bind="{{ attr.options.bind }}"{% endif -%} |
43 | | - {%- if attr.options.badge is defined %} data-badge="{{ attr.options.badge }}"{% endif -%} |
44 | | - ></div> |
45 | | - <noscript> |
46 | | - <div style="width: 302px; height: 352px;"> |
47 | | - <div style="width: 302px; height: 352px; position: relative;"> |
48 | | - <div style="width: 302px; height: 352px; position: absolute;"> |
49 | | - <iframe src="https://{{ form.vars.ewz_recaptcha_apihost }}/recaptcha/api/fallback?k={{ form.vars.public_key }}" |
50 | | - style="width: 302px; height:352px; border-style: none; overflow: hidden;" |
51 | | - > |
52 | | - </iframe> |
53 | | - </div> |
54 | | - <div style="width: 250px; height: 80px; position: absolute; border-style: none; bottom: 21px; left: 25px; margin: 0; padding: 0; right: 25px;"> |
55 | | - <textarea id="g-recaptcha-response" name="g-recaptcha-response" |
56 | | - class="g-recaptcha-response" |
57 | | - style="width: 250px; height: 80px; border: 1px solid #c1c1c1; margin: 0; padding: 0; resize: none;" |
58 | | - > |
59 | | - </textarea> |
60 | | - </div> |
61 | | - </div> |
62 | | - </div> |
63 | | - </noscript> |
64 | | - {% else %} |
65 | | - <div id="ewz_recaptcha_div"></div> |
| 34 | + <script src="{{ form.vars.url_challenge }}" |
| 35 | + {%- if attr.options.defer is defined and attr.options.defer %} defer{% endif -%} |
| 36 | + {%- if attr.options.async is defined and attr.options.async %} async{% endif -%} |
| 37 | + ></script> |
| 38 | + <div class="g-recaptcha" data-theme="{{ attr.options.theme }}" data-size="{{ attr.options.size }}" data-type="{{ attr.options.type }}" data-sitekey="{{ form.vars.public_key }}" |
| 39 | + {%- if attr.options.callback is defined %} data-callback="{{ attr.options.callback }}"{% endif -%} |
| 40 | + {%- if attr.options.errorCallback is defined %} data-error-callback="{{ attr.options.errorCallback }}"{% endif -%} |
| 41 | + {%- if attr.options.expiredCallback is defined %} data-expired-callback="{{ attr.options.expiredCallback }}"{% endif -%} |
| 42 | + {%- if attr.options.bind is defined %} data-bind="{{ attr.options.bind }}"{% endif -%} |
| 43 | + {%- if attr.options.badge is defined %} data-badge="{{ attr.options.badge }}"{% endif -%} |
| 44 | + ></div> |
| 45 | + <noscript> |
| 46 | + <div style="width: 302px; height: 352px;"> |
| 47 | + <div style="width: 302px; height: 352px; position: relative;"> |
| 48 | + <div style="width: 302px; height: 352px; position: absolute;"> |
| 49 | + <iframe src="https://{{ form.vars.ewz_recaptcha_apihost }}/recaptcha/api/fallback?k={{ form.vars.public_key }}" |
| 50 | + style="width: 302px; height:352px; border-style: none; overflow: hidden;" |
| 51 | + > |
| 52 | + </iframe> |
| 53 | + </div> |
| 54 | + <div style="width: 250px; height: 80px; position: absolute; border-style: none; bottom: 21px; left: 25px; margin: 0; padding: 0; right: 25px;"> |
| 55 | + <textarea id="g-recaptcha-response" name="g-recaptcha-response" |
| 56 | + class="g-recaptcha-response" |
| 57 | + style="width: 250px; height: 80px; border: 1px solid #c1c1c1; margin: 0; padding: 0; resize: none;" |
| 58 | + > |
| 59 | + </textarea> |
| 60 | + </div> |
| 61 | + </div> |
| 62 | + </div> |
| 63 | + </noscript> |
| 64 | + {% else %} |
| 65 | + <div id="ewz_recaptcha_div"></div> |
66 | 66 |
|
67 | | - <script> |
68 | | - (function() { |
69 | | - var script = document.createElement('script'); |
70 | | - script.type = 'text/javascript'; |
71 | | - script.onload = function() { |
72 | | - Recaptcha.create('{{ form.vars.public_key }}', 'ewz_recaptcha_div', {{ attr.options|default({})|json_encode|raw }}); |
73 | | - }; |
74 | | - script.src = '{{ form.vars.url_api }}'; |
75 | | - {% if attr.options.defer is defined and attr.options.defer %}script.defer = true;{% endif %} |
76 | | - {% if attr.options.async is defined and attr.options.async %}script.async = true;{% endif %} |
77 | | - document.getElementsByTagName('head')[0].appendChild(script); |
78 | | - })(); |
79 | | - </script> |
80 | | - {% endif %} |
| 67 | + <script> |
| 68 | + (function() { |
| 69 | + var script = document.createElement('script'); |
| 70 | + script.type = 'text/javascript'; |
| 71 | + script.onload = function() { |
| 72 | + Recaptcha.create('{{ form.vars.public_key }}', 'ewz_recaptcha_div', {{ attr.options|default({})|json_encode|raw }}); |
| 73 | + }; |
| 74 | + script.src = '{{ form.vars.url_api }}'; |
| 75 | + {% if attr.options.defer is defined and attr.options.defer %}script.defer = true;{% endif %} |
| 76 | + {% if attr.options.async is defined and attr.options.async %}script.async = true;{% endif %} |
| 77 | + document.getElementsByTagName('head')[0].appendChild(script); |
| 78 | + })(); |
| 79 | + </script> |
81 | 80 | {% endif %} |
| 81 | + {% endif %} |
82 | 82 | {% endapply %} |
83 | 83 | {% endblock ewz_recaptcha_widget %} |
84 | 84 |
|
0 commit comments