Skip to content

Node.js based forum software built for the modern web

feat: #9705, use radio buttons for flag reasons

Barış Soner Uşaklı382a4c278518
diff --git a/public/language/en-GB/flags.json b/public/language/en-GB/flags.json
index bec69fc1a8..5bd46b6b1d 100644
--- a/public/language/en-GB/flags.json
+++ b/public/language/en-GB/flags.json
@@ -77,9 +77,6 @@
"modal-reason-custom": "Reason for reporting this content...",
"modal-submit": "Submit Report",
"modal-submit-success": "Content has been flagged for moderation.",
- "modal-submit-confirm": "Confirm Submission",
- "modal-submit-confirm-text": "You have a custom reason specified already. Are you sure you wish to submit via quick-report?",
- "modal-submit-confirm-text-help": "Submitting a quick report will overwrite any custom reasons defined.",
"bulk-actions": "Bulk Actions",
"bulk-resolve": "Resolve Flag(s)",
diff --git a/public/src/modules/flags.js b/public/src/modules/flags.js
index 244589a3a2..fb6a171d9a 100644
--- a/public/src/modules/flags.js
+++ b/public/src/modules/flags.js
@@ -17,33 +17,28 @@ define('flags', ['hooks', 'components', 'api'], function (hooks, components, api
flagCommit = flagModal.find('#flag-post-commit');
flagReason = flagModal.find('#flag-reason-custom');
- // Quick-report buttons
- flagModal.on('click', '.flag-reason', function () {
- var reportText = $(this).text();
-
- if (flagReason.val().length === 0) {
- return createFlag(data.type, data.id, reportText);
+ flagModal.on('click', 'input[name="flag-reason"]', function () {
+ if ($(this).attr('id') === 'flag-reason-other') {
+ flagReason.removeAttr('disabled');
+ if (!flagReason.val().length) {
+ flagCommit.attr('disabled', true);
+ }
+ } else {
+ flagReason.attr('disabled', true);
+ flagCommit.removeAttr('disabled');
}
-
- // Custom reason has text, confirm submission
- bootbox.confirm({
- title: '[[flags:modal-submit-confirm]]',
- message: '<p>[[flags:modal-submit-confirm-text]]</p><p class="help-block">[[flags:modal-submit-confirm-text-help]]</p>',
- callback: function (result) {
- if (result) {
- createFlag(data.type, data.id, reportText);
- }
- },
- });
});
- // Custom reason report submission
flagCommit.on('click', function () {
- createFlag(data.type, data.id, flagModal.find('#flag-reason-custom').val());
+ var selected = $('input[name="flag-reason"]:checked');
+ var reason = selected.val();
+ if (selected.attr('id') === 'flag-reason-other') {
+ reason = flagReason.val();
+ }
+ createFlag(data.type, data.id, reason);
});
- flagModal.on('click', '.toggle-custom', function () {
- flagReason.prop('disabled', false);
+ flagModal.on('click', '#flag-reason-other', function () {
flagReason.focus();
});