setup_report_forms.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. function init_report_resolution_form() {
  19. hidden_input_names = {
  20. 'takeaway':['take_away_privileges'],
  21. 'userban':['user_banned_until','why_user_was_banned'],
  22. 'sendmessage':['message_to_user']
  23. }
  24. init_user_banned_form();
  25. $('form#resolution_form').hide()
  26. $('#open_resolution_form').click(function() {
  27. $('form#resolution_form').toggle();
  28. $.each(hidden_input_names, function(key, list){
  29. $.each(list, function(index, name){
  30. $('label[for='+name+']').hide();
  31. $('#'+name).hide();
  32. });
  33. });
  34. });
  35. $('#action_to_resolve').change(function() {
  36. $('ul#action_to_resolve li input:checked').each(function() {
  37. $.each(hidden_input_names[$(this).val()], function(index, name){
  38. $('label[for='+name+']').show();
  39. $('#'+name).show();
  40. });
  41. });
  42. $('ul#action_to_resolve li input:not(:checked)').each(function() {
  43. $.each(hidden_input_names[$(this).val()], function(index, name){
  44. $('label[for='+name+']').hide();
  45. $('#'+name).hide();
  46. });
  47. });
  48. });
  49. $("#submit_this_report").click(function(){
  50. submit_user_banned_form()
  51. });
  52. }
  53. function submit_user_banned_form() {
  54. if ($("#user_banned_until").val() == 'YYYY-MM-DD'){
  55. $("#user_banned_until").val("");
  56. }
  57. }
  58. function init_user_banned_form() {
  59. $('#user_banned_until').val("YYYY-MM-DD")
  60. $("#user_banned_until").focus(function() {
  61. $(this).val("");
  62. $(this).unbind('focus');
  63. });
  64. }