Fixes where User id in API would return url rather than host
[mediagoblin.git] / mediagoblin / static / js / setup_report_forms.js
CommitLineData
dc31cd1b 1/**
2 * GNU MediaGoblin -- federated, autonomous media hosting
3 * Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS.
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Affero General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Affero General Public License for more details.
14 *
15 * You should have received a copy of the GNU Affero General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19function init_report_resolution_form() {
20 hidden_input_names = {
21 'takeaway':['take_away_privileges'],
22 'userban':['user_banned_until','why_user_was_banned'],
23 'sendmessage':['message_to_user']
24}
25 init_user_banned_form();
26 $('form#resolution_form').hide()
27 $('#open_resolution_form').click(function() {
28 $('form#resolution_form').toggle();
29 $.each(hidden_input_names, function(key, list){
30 $.each(list, function(index, name){
31 $('label[for='+name+']').hide();
32 $('#'+name).hide();
33 });
34 });
35 });
36 $('#action_to_resolve').change(function() {
37 $('ul#action_to_resolve li input:checked').each(function() {
38 $.each(hidden_input_names[$(this).val()], function(index, name){
39 $('label[for='+name+']').show();
40 $('#'+name).show();
41 });
42 });
43 $('ul#action_to_resolve li input:not(:checked)').each(function() {
44 $.each(hidden_input_names[$(this).val()], function(index, name){
45 $('label[for='+name+']').hide();
46 $('#'+name).hide();
47 });
48 });
49 });
50 $("#submit_this_report").click(function(){
51 submit_user_banned_form()
52 });
53}
54
55function submit_user_banned_form() {
56 if ($("#user_banned_until").val() == 'YYYY-MM-DD'){
57 $("#user_banned_until").val("");
58 }
59}
60
61function init_user_banned_form() {
62 $('#user_banned_until').val("YYYY-MM-DD")
63 $("#user_banned_until").focus(function() {
64 $(this).val("");
65 $(this).unbind('focus');
66 });
67}