merge QR.autoPost into QR.submit

This commit is contained in:
James Campos 2011-09-03 12:43:27 -07:00
parent 9f21c5df35
commit 6d80885a5d
2 changed files with 12 additions and 12 deletions

View File

@ -1291,12 +1291,6 @@
} }
return $.replace(oldFile, file); return $.replace(oldFile, file);
}, },
autoPost: function() {
if (!QR.hasContent()) {
return;
}
return QR.submit();
},
captchaNode: function(e) { captchaNode: function(e) {
var c; var c;
c = e.target.value; c = e.target.value;
@ -1359,7 +1353,7 @@
disabled: false disabled: false
}); });
if ($('#auto', QR.qr).checked) { if ($('#auto', QR.qr).checked) {
return QR.autoPost(); return QR.submit();
} }
} }
}, },
@ -1455,6 +1449,12 @@
}, },
submit: function(e) { submit: function(e) {
var captcha, challenge, el, qr, response; var captcha, challenge, el, qr, response;
if (!QR.hasContent()) {
if (e) {
alert('Error: No text entered.');
}
return;
}
qr = QR.qr; qr = QR.qr;
$('.error', qr).textContent = ''; $('.error', qr).textContent = '';
if ((el = $('#recaptcha_response_field', qr)).value) { if ((el = $('#recaptcha_response_field', qr)).value) {

View File

@ -1008,9 +1008,6 @@ QR =
name: 'upfile' name: 'upfile'
accept: QR.accept accept: QR.accept
$.replace oldFile, file $.replace oldFile, file
autoPost: ->
return unless QR.hasContent()
QR.submit()
captchaNode: (e) -> captchaNode: (e) ->
c = e.target.value c = e.target.value
$('img', QR.qr).src = "http://www.google.com/recaptcha/api/image?c=#{c}" $('img', QR.qr).src = "http://www.google.com/recaptcha/api/image?c=#{c}"
@ -1056,7 +1053,7 @@ QR =
$.extend b, $.extend b,
textContent: 'Submit' textContent: 'Submit'
disabled: false disabled: false
QR.autoPost() if $('#auto', QR.qr).checked QR.submit() if $('#auto', QR.qr).checked
dialog: (text='') -> dialog: (text='') ->
QR.qr = qr = ui.dialog 'qr', top: '0', left: '0', " QR.qr = qr = ui.dialog 'qr', top: '0', left: '0', "
<a class=close title=close>X</a><input type=checkbox id=autohide title=autohide> <a class=close title=close>X</a><input type=checkbox id=autohide title=autohide>
@ -1136,7 +1133,10 @@ QR =
$('textarea', QR.qr).value = '' $('textarea', QR.qr).value = ''
QR.attachNext() QR.attachNext()
submit: (e) -> submit: (e) ->
#XXX e is undefined if we're called from QR.autoPost #XXX e is undefined if method is called explicitly, eg, from auto posting
unless QR.hasContent()
alert 'Error: No text entered.' if e
return
{qr} = QR {qr} = QR
$('.error', qr).textContent = '' $('.error', qr).textContent = ''
if (el = $('#recaptcha_response_field', qr)).value if (el = $('#recaptcha_response_field', qr)).value