1. 重新初始化

This commit is contained in:
ngfchl
2022-08-24 16:04:12 +08:00
commit 7cb8fd1ef3
381 changed files with 82960 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
/*global gettext*/
'use strict';
{
const inputTags = ['BUTTON', 'INPUT', 'SELECT', 'TEXTAREA'];
const modelName = document.getElementById('django-admin-form-add-constants').dataset.modelName;
let submitted = false;
if (modelName) {
const form = document.getElementById(modelName + '_form');
form.addEventListener('submit', (event) => {
event.preventDefault();
if (submitted) {
const answer = window.confirm(gettext('You have already submitted this form. Are you sure you want to submit it again?'));
if (!answer) {
return;
}
}
;
event.target.submit();
submitted = true;
});
for (const element of form.elements) {
// HTMLElement.offsetParent returns null when the element is not
// rendered.
if (inputTags.includes(element.tagName) && !element.disabled && element.offsetParent) {
element.focus();
break;
}
}
}
}