blob: 53277d9d9e8871a9de193422804bf107166addfc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
function toggle_original ($input, revert) {
$input.prop('disabled', revert);
if (revert) {
$input.data('currentValue', $input.val());
}
$input.val($input.data(revert ? 'originalValue' : 'currentValue'));
}
function setup_moderation (elem, word) {
elem.each( function () {
var $elem = $(this);
$elem.find('.moderate').click( function () {
$elem.find('.moderate-display').hide();
$elem.find('.moderate-edit').show();
});
$elem.find('.revert-title').change( function () {
toggle_original($elem.find('input[name=problem_title]'), $(this).prop('checked'));
});
$elem.find('.revert-textarea').change( function () {
toggle_original($elem.find('textarea'), $(this).prop('checked'));
});
var hide_document = $elem.find('.hide-document');
hide_document.change( function () {
$elem.find('input[name=problem_title]').prop('disabled', $(this).prop('checked'));
$elem.find('textarea').prop('disabled', $(this).prop('checked'));
$elem.find('input[type=checkbox]').prop('disabled', $(this).prop('checked'));
$(this).prop('disabled', false); // in case disabled above
});
$elem.find('.cancel').click( function () {
$elem.find('.moderate-display').show();
$elem.find('.moderate-edit').hide();
});
$elem.find('form').submit( function () {
if (hide_document.prop('checked')) {
return confirm('This will hide the ' + word + ' completely! (You will not be able to undo this without contacting support.)');
}
return true;
});
});
}
$(function () {
setup_moderation( $('.problem-header'), 'problem' );
setup_moderation( $('.item-list__item--updates'), 'update' );
});
|