2020-10-24 02:58:05 +00:00
|
|
|
'use strict';
|
|
|
|
{
|
|
|
|
const inputTags = ['BUTTON', 'INPUT', 'SELECT', 'TEXTAREA'];
|
|
|
|
const modelName = document.getElementById('django-admin-form-add-constants').dataset.modelName;
|
|
|
|
if (modelName) {
|
|
|
|
const form = document.getElementById(modelName + '_form');
|
|
|
|
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;
|
2018-10-12 03:11:57 +00:00
|
|
|
}
|
|
|
|
}
|
2020-10-24 02:58:05 +00:00
|
|
|
}
|
|
|
|
}
|