From 04dd17901972959b73d23479918d29b4e80ec6d3 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Mon, 25 Jan 2016 19:34:33 -0800 Subject: [PATCH] Another $.globalEval -> $.global. --- src/Posting/Captcha.v2.coffee | 38 ++++++++++++++--------------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/src/Posting/Captcha.v2.coffee b/src/Posting/Captcha.v2.coffee index d8c2795db..b2612a6c8 100644 --- a/src/Posting/Captcha.v2.coffee +++ b/src/Posting/Captcha.v2.coffee @@ -103,29 +103,21 @@ Captcha.v2 = $.add @nodes.container, [iframe, div] setupJS: -> - $.globalEval ''' - (function() { - function render() { - var container = document.querySelector("#qr .captcha-container"); - container.dataset.widgetID = window.grecaptcha.render(container, { - sitekey: '<%= meta.recaptchaKey %>', - theme: document.documentElement.classList.contains('tomorrow') ? 'dark' : 'light', - callback: function(response) { - window.dispatchEvent(new CustomEvent("captcha:success", {detail: response})); - } - }); - } - if (window.grecaptcha) { - render(); - } else { - var cbNative = window.onRecaptchaLoaded; - window.onRecaptchaLoaded = function() { - render(); - cbNative(); - } - } - })(); - ''' + $.global -> + render = -> + container = document.querySelector '#qr .captcha-container' + container.dataset.widgetID = window.grecaptcha.render container, + sitekey: '<%= meta.recaptchaKey %>' + theme: if document.documentElement.classList.contains('tomorrow') then 'dark' else 'light' + callback: (response) -> + window.dispatchEvent new CustomEvent('captcha:success', {detail: response}) + if window.grecaptcha + render() + else + cbNative = window.onRecaptchaLoaded + window.onRecaptchaLoaded = -> + render() + cbNative() afterSetup: (mutations) -> for mutation in mutations