debian-mirror-gitlab/app/assets/javascripts/vue_shared/components/recaptcha_eventhub.js

22 lines
555 B
JavaScript
Raw Normal View History

2020-05-24 23:13:21 +05:30
import createEventHub from '~/helpers/event_hub_factory';
2019-12-21 20:55:43 +05:30
// see recaptcha_tags in app/views/shared/_recaptcha_form.html.haml
export const callbackName = 'recaptchaDialogCallback';
2020-05-24 23:13:21 +05:30
export const eventHub = createEventHub();
2019-12-21 20:55:43 +05:30
const throwDuplicateCallbackError = () => {
throw new Error(`${callbackName} is already defined!`);
};
if (window[callbackName]) {
throwDuplicateCallbackError();
}
const callback = () => eventHub.$emit('submit');
Object.defineProperty(window, callbackName, {
get: () => callback,
set: throwDuplicateCallbackError,
});