File diff c6b329f0cff0 → 530890f6ad9d
www/conservancy/templates/assignment/assignment_form.html
Show inline comments
...
 
@@ -10,11 +10,34 @@
 

	
 
    <p>If you have any questions about assigning your copyright to Conservancy, please don't hesitate to email us at <a href="mailto:info@sfconservancy.org">info@sfconservancy.org</a>.</p>
 

	
 
    <form action="." method="post" class="mw7">
 
    <form id="assignment-form" action="." method="post" class="mw7">
 
      {% csrf_token %}
 
      {{ form.as_p }}
 

	
 
      <p><button type="submit" class="ph3 pv2">Next</button></p>
 
      <p><button type="submit" class="ph3 pv2">Submit</button></p>
 
    </form>
 
  </div>
 

	
 
  <script>
 
   'use strict';
 

	
 
   // End date field should be shown only when "a specific past date" is selected.
 
   const form = document.querySelector('#assignment-form');
 
   const past_date_label = document.querySelector('label[for=id_period_ends]');
 
   const past_date_field = document.querySelector('#assignment-form > p:nth-child(11)');
 
   form.addEventListener('change', togglePastDate);
 
   togglePastDate();  // Run change handler once to initialise form.
 

	
 
   // Text "(if applicable)" isn't relevant with JS enabled.
 
   past_date_label.innerHTML = past_date_label.innerHTML.replace(' (if applicable)', '');
 

	
 
   function togglePastDate() {
 
       if (form['period_end_type'].value === 'all future contributions') {
 
           past_date_field.style.display = 'none';
 
       }
 
       else {
 
           past_date_field.style.display = '';
 
       }
 
   }
 
  </script>
 
{% endblock %}