Skip to content

Commit

Permalink
Refactor the choicejs code to single js file
Browse files Browse the repository at this point in the history
  • Loading branch information
sandeepsajan0 committed Jan 7, 2025
1 parent d58bac7 commit d657275
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 104 deletions.
15 changes: 2 additions & 13 deletions hypha/apply/funds/templates/funds/application_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,6 @@ <h3>{% blocktrans %}Sorry this {{ page|verbose_name }} is not accepting applicat
{% endif %}
<script src="{% static 'js/multi-input-fields.js' %}"></script>

<script type="module">
import Choices from "{% static 'js/esm/choices.js-10-2-0.js' %}";

const selectElements = document.querySelectorAll('.js-choices');

selectElements.forEach(selectElement => {
new Choices(selectElement, {
shouldSort: false,
allowHTML: true,
removeItemButton: true,
});
});
</script>
<script src="{% static 'js/vendor/choices.min.js' %}"></script>
<script src="{% static 'js/choices-select.js' %}"></script>
{% endblock %}
15 changes: 2 additions & 13 deletions hypha/apply/funds/templates/funds/applicationsubmission_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,6 @@
<script src="{% static 'js/form-group-toggle.js' %}"></script>
{% endif %}

<script type="module">
import Choices from "{% static 'js/esm/choices.js-10-2-0.js' %}";

const selectElements = document.querySelectorAll('.js-choices');

selectElements.forEach(selectElement => {
new Choices(selectElement, {
shouldSort: false,
allowHTML: true,
removeItemButton: true,
});
});
</script>
<script src="{% static 'js/vendor/choices.min.js' %}"></script>
<script src="{% static 'js/choices-select.js' %}"></script>
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,6 @@
{{ filter.form.media.js }}
<script src="{% static 'js/submission-filters.js' %}"></script>
<script src="{% static 'js/batch-actions.js' %}"></script>
<script type="module">
import Choices from "{% static 'js/esm/choices.js-10-2-0.js' %}";

const selectElements = document.querySelectorAll('.js-choices');

selectElements.forEach(selectElement => {
new Choices(selectElement, {
shouldSort: false,
allowHTML: true,
removeItemButton: true,
});
});
</script>
<script src="{% static 'js/vendor/choices.min.js' %}"></script>
<script src="{% static 'js/choices-select.js' %}"></script>
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,6 @@ <h5>{% trans "Proposal attachments" %}</h5>
<script src="{% static 'js/form-group-toggle.js' %}"></script>
{% endif %}

<script type="module">
import Choices from "{% static 'js/esm/choices.js-10-2-0.js' %}";

const selectElements = document.querySelectorAll('.js-choices');

selectElements.forEach(selectElement => {
new Choices(selectElement, {
shouldSort: false,
allowHTML: true,
removeItemButton: true,
});
});
</script>
<script src="{% static 'js/vendor/choices.min.js' %}"></script>
<script src="{% static 'js/choices-select.js' %}"></script>
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,6 @@
{% block extra_js %}
{{ filter.form.media.js }}
<script src="{% static 'js/submission-filters.js' %}"></script>
<script type="module">
import Choices from "{% static 'js/esm/choices.js-10-2-0.js' %}";

const selectElements = document.querySelectorAll('.js-choices');

selectElements.forEach(selectElement => {
new Choices(selectElement, {
shouldSort: false,
allowHTML: true,
removeItemButton: true,
});
});
</script>
<script src="{% static 'js/vendor/choices.min.js' %}"></script>
<script src="{% static 'js/choices-select.js' %}"></script>
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,6 @@ <h5>{% trans "Proposal attachments" %}</h5>
<script src="{% static 'js/form-group-toggle.js' %}"></script>
{% endif %}

<script type="module">
import Choices from "{% static 'js/esm/choices.js-10-2-0.js' %}";

const selectElements = document.querySelectorAll('.js-choices');

selectElements.forEach(selectElement => {
new Choices(selectElement, {
shouldSort: false,
allowHTML: true,
removeItemButton: true,
});
});
</script>
<script src="{% static 'js/vendor/choices.min.js' %}"></script>
<script src="{% static 'js/choices-select.js' %}"></script>
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,6 @@

{% block extra_js %}
<script src="{% static 'js/multi-input-fields.js' %}"></script>
<script type="module">
import Choices from "{% static 'js/esm/choices.js-10-2-0.js' %}";

const selectElements = document.querySelectorAll('.js-choices');

selectElements.forEach(selectElement => {
new Choices(selectElement, {
shouldSort: false,
allowHTML: true,
removeItemButton: true,
});
});
</script>
<script src="{% static 'js/vendor/choices.min.js' %}"></script>
<script src="{% static 'js/choices-select.js' %}"></script>
{% endblock %}
15 changes: 2 additions & 13 deletions hypha/apply/projects/templates/application_projects/reporting.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,6 @@
{% block extra_js %}
{{ filter.form.media.js }}
<script src="{% static 'js/submission-filters.js' %}"></script>
<script type="module">
import Choices from "{% static 'js/esm/choices.js-10-2-0.js' %}";

const selectElements = document.querySelectorAll('.js-choices');

selectElements.forEach(selectElement => {
new Choices(selectElement, {
shouldSort: false,
allowHTML: true,
removeItemButton: true,
});
});
</script>
<script src="{% static 'js/vendor/choices.min.js' %}"></script>
<script src="{% static 'js/choices-select.js' %}"></script>
{% endblock %}
10 changes: 10 additions & 0 deletions hypha/static_src/javascript/choices-select.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const selectElements = document.querySelectorAll('.js-choices');

selectElements.forEach(selectElement => {
// eslint-disable-next-line no-undef
new Choices(selectElement, {
shouldSort: false,
allowHTML: true,
removeItemButton: true,
});
});
2 changes: 2 additions & 0 deletions hypha/static_src/javascript/vendor/choices.min.js

Large diffs are not rendered by default.

0 comments on commit d657275

Please sign in to comment.