Different QR's captcha refresh listener.

This commit is contained in:
Nicolas Stepien 2011-07-20 00:29:07 +02:00
parent 9416f74ae3
commit 644bb88d70
2 changed files with 16 additions and 7 deletions

View File

@ -2405,6 +2405,7 @@
el = _ref2[_i];
el.tabIndex = 1;
}
$.bind($('#recaptcha_challenge_field_holder'), 'DOMNodeInserted', Recaptcha.reloaded);
return $.bind($('#recaptcha_response_field'), 'keydown', Recaptcha.listener);
},
listener: function(e) {
@ -2418,10 +2419,18 @@
},
reload: function() {
return window.location = 'javascript:Recaptcha.reload()';
},
reloaded: function(e) {
var dialog, target;
target = e.target;
if (dialog = $('#qr')) {
$('img', dialog).src = "http://www.google.com/recaptcha/api/image?c=" + target.value;
return $('input[name=recaptcha_challenge_field]', dialog).value = target.value;
}
}
};
nodeInserted = function(e) {
var callback, dialog, target, _i, _len, _ref2, _results;
var callback, target, _i, _len, _ref2, _results;
target = e.target;
if (target.nodeName === 'TABLE') {
_ref2 = g.callbacks;
@ -2431,9 +2440,6 @@
_results.push(callback(target));
}
return _results;
} else if (target.id === 'recaptcha_challenge_field' && (dialog = $('#qr'))) {
$('img', dialog).src = "http://www.google.com/recaptcha/api/image?c=" + target.value;
return $('input[name=recaptcha_challenge_field]', dialog).value = target.value;
}
};
imageHover = {

View File

@ -1824,6 +1824,7 @@ Recaptcha =
#hack to tab from comment straight to recaptcha
for el in $$ '#recaptcha_table a'
el.tabIndex = 1
$.bind $('#recaptcha_challenge_field_holder'), 'DOMNodeInserted', Recaptcha.reloaded
$.bind $('#recaptcha_response_field'), 'keydown', Recaptcha.listener
listener: (e) ->
if e.keyCode is 8 and @value is '' # backspace to reload
@ -1833,15 +1834,17 @@ Recaptcha =
qr.autohide.set()
reload: ->
window.location = 'javascript:Recaptcha.reload()'
reloaded: (e) ->
{target} = e
if dialog = $ '#qr'
$('img', dialog).src = "http://www.google.com/recaptcha/api/image?c=" + target.value
$('input[name=recaptcha_challenge_field]', dialog).value = target.value
nodeInserted = (e) ->
{target} = e
if target.nodeName is 'TABLE'
for callback in g.callbacks
callback target
else if target.id is 'recaptcha_challenge_field' and dialog = $ '#qr'
$('img', dialog).src = "http://www.google.com/recaptcha/api/image?c=" + target.value
$('input[name=recaptcha_challenge_field]', dialog).value = target.value
imageHover =
init: ->