From 2ccf01194378ec42d587a5c87156a2bae3624ade Mon Sep 17 00:00:00 2001 From: MelissaCole Date: Fri, 13 Nov 2015 12:34:09 -0800 Subject: [PATCH] Subreddit rules: Fix `other_reason` input in report dialog The `other_reason` input needs to be enabled properly since `.report-action-form` isn't being used in the report dialog anymore. --- r2/r2/public/static/js/report.js | 18 ++++++++++++++++++ r2/r2/templates/reportform.html | 2 +- r2/r2/templates/subredditreportform.html | 2 +- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/r2/r2/public/static/js/report.js b/r2/r2/public/static/js/report.js index 9ff33aeda..ab0bcc1e1 100644 --- a/r2/r2/public/static/js/report.js +++ b/r2/r2/public/static/js/report.js @@ -5,6 +5,23 @@ $(function() { return false } + function toggleOther() { + var $reportForm = $(this).closest('.reportform'); + var $submit = $reportForm.find('[type="submit"]'); + var $reason = $reportForm.find('[name=reason]:checked'); + var $other = $reportForm.find('[name="other_reason"]'); + var isOther = $reason.val() === 'other'; + + $submit.removeAttr('disabled'); + + if (isOther) { + $other.removeAttr('disabled').focus(); + } else { + $other.attr('disabled', 'disabled'); + } + return false + } + function getReportAttrs($el) { return {thing: $el.thing_id()} } @@ -39,4 +56,5 @@ $(function() { $("div.content").on("click", ".tagline .reportbtn, .thing .reportbtn", openReportForm); $("div.content").on("click", ".btn.report-cancel", toggleReportForm); + $("div.content").on("change", "input[name='reason']", toggleOther); }); diff --git a/r2/r2/templates/reportform.html b/r2/r2/templates/reportform.html index 449ab2cbb..fe5f83d8e 100644 --- a/r2/r2/templates/reportform.html +++ b/r2/r2/templates/reportform.html @@ -61,7 +61,7 @@ -