-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'maintenance/clean-up-js-files' into test
- Loading branch information
Showing
17 changed files
with
25 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,7 +47,3 @@ | |
</div> | ||
</div> | ||
{% endblock %} | ||
|
||
{% block extra_js %} | ||
{{ form.media.js }} | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,3 @@ | |
</div> | ||
</div> | ||
{% endblock %} | ||
|
||
{% block extra_js %} | ||
{{ form.media.js }} | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,30 @@ | ||
jQuery(function ($) { | ||
// We use htmx.onLoad() so it will initilise file uploads in htmx dialogs. | ||
htmx.onLoad(function () { | ||
// Initialize django-file-form | ||
$("form") | ||
.get() | ||
.forEach(function (form) { | ||
// Prevent initialising it multiple times and run it for forms | ||
// that have a `form_id` field added by django-file-form. | ||
if (!form.initUploadFieldsDone && form.querySelector("[name=form_id]")) { | ||
init(form); | ||
form.initUploadFieldsDone = true; | ||
} | ||
}); | ||
document.querySelectorAll("form").forEach(function (form) { | ||
// Prevent initializing it multiple times and run it for forms | ||
// that have a `form_id` field added by django-file-form. | ||
if (!form.initUploadFieldsDone && form.querySelector("[name=form_id]")) { | ||
init(form); | ||
form.initUploadFieldsDone = true; | ||
} | ||
}); | ||
|
||
/** | ||
* Initialize django-file-form for a form. | ||
* @param {object} form The form to initialize. | ||
*/ | ||
function init(form) { | ||
if ($(".form__group--file").length) { | ||
if (document.querySelectorAll(".form__group--file").length) { | ||
window.initUploadFields(form); | ||
|
||
// Hide wrapper elements for hidden inputs added by django-file-form | ||
$("input[type=hidden]").closest(".form__group").hide(); | ||
document.querySelectorAll("input[type=hidden]").forEach(function (input) { | ||
const closestFormGroup = input.closest(".form__group"); | ||
if (closestFormGroup) { | ||
closestFormGroup.style.display = "none"; | ||
} | ||
}); | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters