You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.8 KiB

  1. window.addEventListener("load", function() {
  2. (function($) {
  3. $(function() {
  4. // selfbuy section
  5. var selectField_selfbuy = $('#id_selfbuy'),
  6. verified_selfbuy_div = $('#id_selfbuy_give_data').parent().parent(),
  7. verified_selfbuy = $('#id_selfbuy_give_data'),
  8. data_selfbuy_div = $('#id_selfbuy_data').parent().parent(),
  9. data_selfbuy = $('#id_selfbuy_data');
  10. // make checked to get through the required
  11. function toggleVerified_selfbuy(value) {
  12. if (value === "FALSE") {
  13. verified_selfbuy_div.show();
  14. data_selfbuy_div.show();
  15. data_selfbuy.val("");
  16. verified_selfbuy.prop("checked", false);
  17. } else {
  18. verified_selfbuy_div.hide();
  19. data_selfbuy_div.hide();
  20. data_selfbuy.val("NONE");
  21. verified_selfbuy.prop("checked", true);
  22. }
  23. }
  24. // show/hide on load based on existing value of selectField
  25. toggleVerified_selfbuy(selectField_selfbuy.val());
  26. // show/hide on change
  27. selectField_selfbuy.change(function() {
  28. toggleVerified_selfbuy($(this).val());
  29. });
  30. var selectField = $('#id_variant'),
  31. verified = $('#id_url_of_pic').parent().parent();
  32. function toggleVerified(value) {
  33. if (value === 'PIC') {
  34. verified.show();
  35. } else {
  36. verified.hide();
  37. }
  38. }
  39. // show/hide on load based on existing value of selectField
  40. toggleVerified(selectField.val());
  41. // show/hide on change
  42. selectField.change(function() {
  43. toggleVerified($(this).val());
  44. });
  45. });
  46. })(django.jQuery);
  47. });