$.globalEval -> $.global in Captcha.v1.
This commit is contained in:
parent
4fc66d19a2
commit
c8ff3f0bcd
@ -50,24 +50,19 @@ Captcha.v1 =
|
|||||||
$.replace old, container
|
$.replace old, container
|
||||||
|
|
||||||
create: ->
|
create: ->
|
||||||
$.globalEval '''
|
$.global ->
|
||||||
(function() {
|
container = document.getElementById 'captchaContainerAlt'
|
||||||
var container = document.getElementById("captchaContainerAlt");
|
return if container.firstChild
|
||||||
if (container.firstChild) return;
|
options =
|
||||||
var options = {
|
theme: 'clean'
|
||||||
theme: "clean",
|
|
||||||
tabindex: {"boards.4chan.org": 5, "sys.4chan.org": 3}[location.hostname]
|
tabindex: {"boards.4chan.org": 5, "sys.4chan.org": 3}[location.hostname]
|
||||||
};
|
if window.Recaptcha
|
||||||
if (window.Recaptcha) {
|
window.Recaptcha.create '<%= meta.recaptchaKey %>', container, options
|
||||||
window.Recaptcha.create("<%= meta.recaptchaKey %>", container, options);
|
else
|
||||||
} else {
|
script = document.head.querySelector 'script[src="//www.google.com/recaptcha/api/js/recaptcha_ajax.js"]'
|
||||||
var script = document.head.querySelector('script[src="//www.google.com/recaptcha/api/js/recaptcha_ajax.js"]');
|
script.addEventListener 'load', ->
|
||||||
script.addEventListener('load', function() {
|
window.Recaptcha.create '<%= meta.recaptchaKey %>', container, options
|
||||||
window.Recaptcha.create("<%= meta.recaptchaKey %>", container, options);
|
, false
|
||||||
}, false);
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
'''
|
|
||||||
|
|
||||||
cb:
|
cb:
|
||||||
focus: -> QR.captcha.setup false, true
|
focus: -> QR.captcha.setup false, true
|
||||||
@ -105,7 +100,7 @@ Captcha.v1 =
|
|||||||
|
|
||||||
setLifetime = (e) -> QR.captcha.lifetime = e.detail
|
setLifetime = (e) -> QR.captcha.lifetime = e.detail
|
||||||
$.on window, 'captcha:timeout', setLifetime
|
$.on window, 'captcha:timeout', setLifetime
|
||||||
$.globalEval 'window.dispatchEvent(new CustomEvent("captcha:timeout", {detail: RecaptchaState.timeout}))'
|
$.global -> window.dispatchEvent new CustomEvent 'captcha:timeout', {detail: window.RecaptchaState.timeout}
|
||||||
$.off window, 'captcha:timeout', setLifetime
|
$.off window, 'captcha:timeout', setLifetime
|
||||||
|
|
||||||
{img, input} = QR.captcha.nodes
|
{img, input} = QR.captcha.nodes
|
||||||
@ -127,7 +122,7 @@ Captcha.v1 =
|
|||||||
|
|
||||||
destroy: ->
|
destroy: ->
|
||||||
return unless @script
|
return unless @script
|
||||||
$.globalEval 'window.Recaptcha.destroy();'
|
$.global -> window.Recaptcha.destroy()
|
||||||
@beforeSetup() if @nodes
|
@beforeSetup() if @nodes
|
||||||
|
|
||||||
sync: (captchas=[]) ->
|
sync: (captchas=[]) ->
|
||||||
@ -205,14 +200,12 @@ Captcha.v1 =
|
|||||||
|
|
||||||
reload: (focus) ->
|
reload: (focus) ->
|
||||||
# Recaptcha.should_focus = false: Hack to prevent the input from being focused
|
# Recaptcha.should_focus = false: Hack to prevent the input from being focused
|
||||||
$.globalEval '''
|
$.global ->
|
||||||
if (window.Recaptcha.type === "image") {
|
if window.Recaptcha.type is 'image'
|
||||||
window.Recaptcha.reload();
|
window.Recaptcha.reload()
|
||||||
} else {
|
else
|
||||||
window.Recaptcha.switch_type("image");
|
window.Recaptcha.switch_type 'image'
|
||||||
}
|
window.Recaptcha.should_focus = false
|
||||||
window.Recaptcha.should_focus = false;
|
|
||||||
'''
|
|
||||||
@nodes.input.focus() if focus
|
@nodes.input.focus() if focus
|
||||||
|
|
||||||
keydown: (e) ->
|
keydown: (e) ->
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user