less qr.cb

This commit is contained in:
James Campos 2011-08-06 09:44:42 -07:00
parent 066a3d8ba5
commit d330cbe8c9
2 changed files with 74 additions and 74 deletions

View File

@ -1230,13 +1230,13 @@
qr = { qr = {
init: function() { init: function() {
var iframe; var iframe;
g.callbacks.push(qr.cb.node); g.callbacks.push(qr.node);
iframe = $.el('iframe', { iframe = $.el('iframe', {
name: 'iframe', name: 'iframe',
hidden: true hidden: true
}); });
$.append(d.body, iframe); $.append(d.body, iframe);
$.bind(window, 'message', qr.cb.message); $.bind(window, 'message', qr.message);
$('#recaptcha_response_field').id = ''; $('#recaptcha_response_field').id = '';
return qr.captcha = []; return qr.captcha = [];
}, },
@ -1250,6 +1250,44 @@
return (_ref = $('#autohide:checked', qr.el)) != null ? _ref.click() : void 0; return (_ref = $('#autohide:checked', qr.el)) != null ? _ref.click() : void 0;
} }
}, },
message: function(e) {
var data, duration, file, oldFile;
Recaptcha.reload();
$('iframe[name=iframe]').src = 'about:blank';
data = e.data;
if (data) {
data = JSON.parse(data);
$.extend($('#error', qr.el), data);
$('input[name=recaptcha_response_field]', qr.el).value = '';
qr.autohide.unset();
if (data.textContent === 'You seem to have mistyped the verification.') {
qr.auto();
}
return;
}
if (qr.el) {
file = $('#files input', qr.el);
if (g.REPLY && (conf['Persistent QR'] || file)) {
qr.refresh();
if (file) {
oldFile = $('#qr_form input[type=file]', qr.el);
$.replace(oldFile, file);
}
} else {
qr.close();
}
}
if (conf['Cooldown']) {
duration = qr.sage ? 60 : 30;
$.setValue(g.BOARD + '/cooldown', Date.now() + duration * 1000);
return cooldown.start();
}
},
node: function(root) {
var quote;
quote = $('a.quotejs:not(:first-child)', root);
return $.bind(quote, 'click', qr.cb.quote);
},
cb: { cb: {
autohide: function(e) { autohide: function(e) {
if (this.checked) { if (this.checked) {
@ -1258,44 +1296,6 @@
return $.removeClass(qr.el, 'auto'); return $.removeClass(qr.el, 'auto');
} }
}, },
message: function(e) {
var data, duration, file, oldFile;
Recaptcha.reload();
$('iframe[name=iframe]').src = 'about:blank';
data = e.data;
if (data) {
data = JSON.parse(data);
$.extend($('#error', qr.el), data);
$('input[name=recaptcha_response_field]', qr.el).value = '';
qr.autohide.unset();
if (data.textContent === 'You seem to have mistyped the verification.') {
qr.auto();
}
return;
}
if (qr.el) {
file = $('#files input', qr.el);
if (g.REPLY && (conf['Persistent QR'] || file)) {
qr.refresh();
if (file) {
oldFile = $('#qr_form input[type=file]', qr.el);
$.replace(oldFile, file);
}
} else {
qr.close();
}
}
if (conf['Cooldown']) {
duration = qr.sage ? 60 : 30;
$.setValue(g.BOARD + '/cooldown', Date.now() + duration * 1000);
return cooldown.start();
}
},
node: function(root) {
var quote;
quote = $('a.quotejs:not(:first-child)', root);
return $.bind(quote, 'click', qr.cb.quote);
},
quote: function(e) { quote: function(e) {
e.preventDefault(); e.preventDefault();
return qr.quote(this); return qr.quote(this);

View File

@ -967,12 +967,12 @@ cooldown =
qr = qr =
init: -> init: ->
g.callbacks.push qr.cb.node g.callbacks.push qr.node
iframe = $.el 'iframe', iframe = $.el 'iframe',
name: 'iframe' name: 'iframe'
hidden: true hidden: true
$.append d.body, iframe $.append d.body, iframe
$.bind window, 'message', qr.cb.message $.bind window, 'message', qr.message
#hack - nuke id so it doesn't grab focus when reloading #hack - nuke id so it doesn't grab focus when reloading
$('#recaptcha_response_field').id = '' $('#recaptcha_response_field').id = ''
@ -984,6 +984,38 @@ qr =
unset: -> unset: ->
$('#autohide:checked', qr.el)?.click() $('#autohide:checked', qr.el)?.click()
message: (e) ->
Recaptcha.reload()
$('iframe[name=iframe]').src = 'about:blank'
{data} = e
if data # error message
data = JSON.parse data
$.extend $('#error', qr.el), data
$('input[name=recaptcha_response_field]', qr.el).value = ''
qr.autohide.unset()
if data.textContent is 'You seem to have mistyped the verification.'
qr.auto()
return
if qr.el
file = $ '#files input', qr.el
if g.REPLY and (conf['Persistent QR'] or file)
qr.refresh()
if file
oldFile = $ '#qr_form input[type=file]', qr.el
$.replace oldFile, file
else
qr.close()
if conf['Cooldown']
duration = if qr.sage then 60 else 30
$.setValue g.BOARD+'/cooldown', Date.now() + duration * 1000
cooldown.start()
node: (root) ->
quote = $ 'a.quotejs:not(:first-child)', root
$.bind quote, 'click', qr.cb.quote
cb: cb:
autohide: (e) -> autohide: (e) ->
if @checked if @checked
@ -991,38 +1023,6 @@ qr =
else else
$.removeClass qr.el, 'auto' $.removeClass qr.el, 'auto'
message: (e) ->
Recaptcha.reload()
$('iframe[name=iframe]').src = 'about:blank'
{data} = e
if data # error message
data = JSON.parse data
$.extend $('#error', qr.el), data
$('input[name=recaptcha_response_field]', qr.el).value = ''
qr.autohide.unset()
if data.textContent is 'You seem to have mistyped the verification.'
qr.auto()
return
if qr.el
file = $ '#files input', qr.el
if g.REPLY and (conf['Persistent QR'] or file)
qr.refresh()
if file
oldFile = $ '#qr_form input[type=file]', qr.el
$.replace oldFile, file
else
qr.close()
if conf['Cooldown']
duration = if qr.sage then 60 else 30
$.setValue g.BOARD+'/cooldown', Date.now() + duration * 1000
cooldown.start()
node: (root) ->
quote = $ 'a.quotejs:not(:first-child)', root
$.bind quote, 'click', qr.cb.quote
quote: (e) -> quote: (e) ->
e.preventDefault() e.preventDefault()
qr.quote @ qr.quote @