2017-12-08 07:26:39 -05:00
|
|
|
<script>
|
2018-10-10 03:06:25 -04:00
|
|
|
import DeprecatedModal from './deprecated_modal.vue';
|
2017-12-08 07:26:39 -05:00
|
|
|
|
2018-10-10 03:06:25 -04:00
|
|
|
export default {
|
|
|
|
name: 'RecaptchaModal',
|
2017-12-08 07:26:39 -05:00
|
|
|
|
2018-10-10 03:06:25 -04:00
|
|
|
components: {
|
|
|
|
DeprecatedModal,
|
|
|
|
},
|
2017-12-08 07:26:39 -05:00
|
|
|
|
2018-10-10 03:06:25 -04:00
|
|
|
props: {
|
|
|
|
html: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: '',
|
2018-01-06 13:59:49 -05:00
|
|
|
},
|
2018-10-10 03:06:25 -04:00
|
|
|
},
|
2017-12-08 07:26:39 -05:00
|
|
|
|
2018-10-10 03:06:25 -04:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
script: {},
|
2018-12-18 22:19:40 -05:00
|
|
|
scriptSrc: 'https://www.recaptcha.net/recaptcha/api.js',
|
2018-10-10 03:06:25 -04:00
|
|
|
};
|
|
|
|
},
|
2017-12-08 07:26:39 -05:00
|
|
|
|
2018-10-10 03:06:25 -04:00
|
|
|
watch: {
|
|
|
|
html() {
|
|
|
|
this.appendRecaptchaScript();
|
2018-01-06 13:59:49 -05:00
|
|
|
},
|
2018-10-10 03:06:25 -04:00
|
|
|
},
|
2017-12-08 07:26:39 -05:00
|
|
|
|
2018-10-10 03:06:25 -04:00
|
|
|
mounted() {
|
|
|
|
window.recaptchaDialogCallback = this.submit.bind(this);
|
|
|
|
},
|
2017-12-08 07:26:39 -05:00
|
|
|
|
2018-10-10 03:06:25 -04:00
|
|
|
methods: {
|
|
|
|
appendRecaptchaScript() {
|
|
|
|
this.removeRecaptchaScript();
|
2017-12-08 07:26:39 -05:00
|
|
|
|
2018-10-10 03:06:25 -04:00
|
|
|
const script = document.createElement('script');
|
|
|
|
script.src = this.scriptSrc;
|
|
|
|
script.classList.add('js-recaptcha-script');
|
|
|
|
script.async = true;
|
|
|
|
script.defer = true;
|
2017-12-08 07:26:39 -05:00
|
|
|
|
2018-10-10 03:06:25 -04:00
|
|
|
this.script = script;
|
2017-12-08 07:26:39 -05:00
|
|
|
|
2018-10-10 03:06:25 -04:00
|
|
|
document.body.appendChild(script);
|
|
|
|
},
|
2017-12-08 07:26:39 -05:00
|
|
|
|
2018-10-10 03:06:25 -04:00
|
|
|
removeRecaptchaScript() {
|
|
|
|
if (this.script instanceof Element) this.script.remove();
|
|
|
|
},
|
2017-12-08 07:26:39 -05:00
|
|
|
|
2018-10-10 03:06:25 -04:00
|
|
|
close() {
|
|
|
|
this.removeRecaptchaScript();
|
|
|
|
this.$emit('close');
|
|
|
|
},
|
2017-12-08 07:26:39 -05:00
|
|
|
|
2018-10-10 03:06:25 -04:00
|
|
|
submit() {
|
|
|
|
this.$el.querySelector('form').submit();
|
2018-01-06 13:59:49 -05:00
|
|
|
},
|
2018-10-10 03:06:25 -04:00
|
|
|
},
|
|
|
|
};
|
2017-12-08 07:26:39 -05:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2018-02-28 16:47:44 -05:00
|
|
|
<deprecated-modal
|
2018-01-06 13:59:49 -05:00
|
|
|
:hide-footer="true"
|
|
|
|
:title="__('Please solve the reCAPTCHA')"
|
2018-06-11 05:49:47 -04:00
|
|
|
kind="warning"
|
|
|
|
class="recaptcha-modal js-recaptcha-modal"
|
2018-01-06 13:59:49 -05:00
|
|
|
@cancel="close"
|
|
|
|
>
|
|
|
|
<div slot="body">
|
2018-11-16 15:07:38 -05:00
|
|
|
<p>{{ __('We want to be sure it is you, please confirm you are not a robot.') }}</p>
|
|
|
|
<div ref="recaptcha" v-html="html"></div>
|
2018-01-06 13:59:49 -05:00
|
|
|
</div>
|
2018-02-28 16:47:44 -05:00
|
|
|
</deprecated-modal>
|
2017-12-08 07:26:39 -05:00
|
|
|
</template>
|