2 lines
4.0 KiB
JavaScript
2 lines
4.0 KiB
JavaScript
this.primereact=this.primereact||{},this.primereact.captcha=function(e,t){"use strict";function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=n(t);function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e,t){return i=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},i(e,t)}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&i(e,t)}function p(e){return p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},p(e)}function u(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function s(e,t){if(t&&("object"===p(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return u(e)}function l(e){return l=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},l(e)}function f(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}var h,y,d,b=function(e){a(y,e);var t,n,i,p,u,h=(t=y,n=f(),function(){var e,r=l(t);if(n){var o=l(this).constructor;e=Reflect.construct(r,arguments,o)}else e=r.apply(this,arguments);return s(this,e)});function y(){return o(this,y),h.apply(this,arguments)}return i=y,(p=[{key:"init",value:function(){var e=this;this._instance=window.grecaptcha.render(this.targetEL,{sitekey:this.props.siteKey,theme:this.props.theme,type:this.props.type,size:this.props.size,tabindex:this.props.tabIndex,hl:this.props.language,callback:function(t){e.recaptchaCallback(t)},"expired-callback":function(){e.recaptchaExpiredCallback()}})}},{key:"reset",value:function(){null!==this._instance&&window.grecaptcha.reset(this._instance)}},{key:"getResponse",value:function(){return null===this._instance?null:window.grecaptcha.getResponse(this._instance)}},{key:"recaptchaCallback",value:function(e){this.props.onResponse&&this.props.onResponse({response:e})}},{key:"recaptchaExpiredCallback",value:function(){this.props.onExpire&&this.props.onExpire()}},{key:"addRecaptchaScript",value:function(){var e=this;if(this.recaptchaScript=null,!window.grecaptcha){var t=document.head||document.getElementsByTagName("head")[0];this.recaptchaScript=document.createElement("script"),this.recaptchaScript.src="https://www.google.com/recaptcha/api.js?render=explicit",this.recaptchaScript.async=!0,this.recaptchaScript.defer=!0,this.recaptchaScript.onload=function(){window.grecaptcha?window.grecaptcha.ready((function(){e.init()})):console.warn("Recaptcha is not loaded")},t.appendChild(this.recaptchaScript)}}},{key:"componentDidMount",value:function(){this.addRecaptchaScript(),window.grecaptcha&&this.init()}},{key:"componentWillUnmount",value:function(){this.recaptchaScript&&this.recaptchaScript.parentNode.removeChild(this.recaptchaScript)}},{key:"render",value:function(){var e=this;return r.default.createElement("div",{id:this.props.id,ref:function(t){return e.targetEL=t}})}}])&&c(i.prototype,p),u&&c(i,u),Object.defineProperty(i,"prototype",{writable:!1}),y}(t.Component);return d={id:null,siteKey:null,theme:"light",type:"image",size:"normal",tabIndex:0,language:"en",onResponse:null,onExpire:null},(y="defaultProps")in(h=b)?Object.defineProperty(h,y,{value:d,enumerable:!0,configurable:!0,writable:!0}):h[y]=d,e.Captcha=b,Object.defineProperty(e,"__esModule",{value:!0}),e}({},React);
|