forked from leftypol/leftypol
quick-reply.js: move recaptcha rendering to function
This commit is contained in:
parent
4f61026842
commit
fccd0a16dd
1 changed files with 45 additions and 41 deletions
|
@ -136,38 +136,7 @@
|
||||||
$dummyStuff = $('<div class="nonsense"></div>').appendTo($postForm);
|
$dummyStuff = $('<div class="nonsense"></div>').appendTo($postForm);
|
||||||
|
|
||||||
$postForm.find('table tr').each(function() {
|
$postForm.find('table tr').each(function() {
|
||||||
var $th = $(this).children('th:first');
|
function build_recaptcha() {
|
||||||
var $td = $(this).children('td:first');
|
|
||||||
if ($th.length && $td.length) {
|
|
||||||
$td.attr('colspan', 2);
|
|
||||||
|
|
||||||
if ($td.find('input[type="text"]').length) {
|
|
||||||
// Replace <th> with input placeholders
|
|
||||||
$td.find('input[type="text"]')
|
|
||||||
.removeAttr('size')
|
|
||||||
.attr('placeholder', $th.clone().children().remove().end().text());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Move anti-spam nonsense and remove <th>
|
|
||||||
$th.contents().filter(function() {
|
|
||||||
return this.nodeType == 3; // Node.TEXT_NODE
|
|
||||||
}).remove();
|
|
||||||
$th.contents().appendTo($dummyStuff);
|
|
||||||
$th.remove();
|
|
||||||
|
|
||||||
if ($td.find('input[name="password"]').length) {
|
|
||||||
// Hide password field
|
|
||||||
$(this).hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fix submit button
|
|
||||||
if ($td.find('input[type="submit"]').length) {
|
|
||||||
$td.removeAttr('colspan');
|
|
||||||
$('<td class="submit"></td>').append($td.find('input[type="submit"]')).insertAfter($td);
|
|
||||||
}
|
|
||||||
|
|
||||||
// reCAPTCHA
|
|
||||||
if ($td.find('#recaptcha_widget_div').length) {
|
|
||||||
// Just show the image, and have it interact with the real form.
|
// Just show the image, and have it interact with the real form.
|
||||||
var $captchaimg = $td.find('#recaptcha_image img');
|
var $captchaimg = $td.find('#recaptcha_image img');
|
||||||
|
|
||||||
|
@ -211,6 +180,41 @@
|
||||||
$newRow.insertAfter(this);
|
$newRow.insertAfter(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var $th = $(this).children('th:first');
|
||||||
|
var $td = $(this).children('td:first');
|
||||||
|
if ($th.length && $td.length) {
|
||||||
|
$td.attr('colspan', 2);
|
||||||
|
|
||||||
|
if ($td.find('input[type="text"]').length) {
|
||||||
|
// Replace <th> with input placeholders
|
||||||
|
$td.find('input[type="text"]')
|
||||||
|
.removeAttr('size')
|
||||||
|
.attr('placeholder', $th.clone().children().remove().end().text());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Move anti-spam nonsense and remove <th>
|
||||||
|
$th.contents().filter(function() {
|
||||||
|
return this.nodeType == 3; // Node.TEXT_NODE
|
||||||
|
}).remove();
|
||||||
|
$th.contents().appendTo($dummyStuff);
|
||||||
|
$th.remove();
|
||||||
|
|
||||||
|
if ($td.find('input[name="password"]').length) {
|
||||||
|
// Hide password field
|
||||||
|
$(this).hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fix submit button
|
||||||
|
if ($td.find('input[type="submit"]').length) {
|
||||||
|
$td.removeAttr('colspan');
|
||||||
|
$('<td class="submit"></td>').append($td.find('input[type="submit"]')).insertAfter($td);
|
||||||
|
}
|
||||||
|
|
||||||
|
// reCAPTCHA
|
||||||
|
if ($td.find('#recaptcha_widget_div').length) {
|
||||||
|
build_recaptcha();
|
||||||
|
}
|
||||||
|
|
||||||
// Upload section
|
// Upload section
|
||||||
if ($td.find('input[type="file"]').length) {
|
if ($td.find('input[type="file"]').length) {
|
||||||
if ($td.find('input[name="file_url"]').length) {
|
if ($td.find('input[name="file_url"]').length) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue