|
|
|
@ -5,6 +5,7 @@ define('flags', ['benchpress'], function (Benchpress) {
|
|
|
|
|
var Flag = {};
|
|
|
|
|
var flagModal;
|
|
|
|
|
var flagCommit;
|
|
|
|
|
var flagReason;
|
|
|
|
|
|
|
|
|
|
Flag.showFlagModal = function (data) {
|
|
|
|
|
parseModal(data, function (html) {
|
|
|
|
@ -15,15 +16,38 @@ define('flags', ['benchpress'], function (Benchpress) {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
flagCommit = flagModal.find('#flag-post-commit');
|
|
|
|
|
flagReason = flagModal.find('#flag-reason-custom');
|
|
|
|
|
|
|
|
|
|
// Quick-report buttons
|
|
|
|
|
flagModal.on('click', '.flag-reason', function () {
|
|
|
|
|
createFlag(data.type, data.id, $(this).text());
|
|
|
|
|
var reportText = $(this).text();
|
|
|
|
|
|
|
|
|
|
if (flagReason.length === 0) {
|
|
|
|
|
return createFlag(data.type, data.id, reportText);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 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());
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
flagModal.on('click', '.toggle-custom', function () {
|
|
|
|
|
flagReason.prop('disabled', false);
|
|
|
|
|
flagReason.focus();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
flagModal.modal('show');
|
|
|
|
|
|
|
|
|
|
flagModal.find('#flag-reason-custom').on('keyup blur change', checkFlagButtonEnable);
|
|
|
|
|