Fix @rails/ujs imports

This commit is contained in:
Claire
2023-10-24 20:23:31 +02:00
parent 4b0fb764c3
commit 8a131fb7bc
5 changed files with 30 additions and 30 deletions

View File

@@ -1,9 +1,9 @@
// This file will be loaded on settings pages, regardless of theme.
import 'packs/public-path';
import delegate from '@rails/ujs';
import Rails from '@rails/ujs';
delegate(document, '#edit_profile input[type=file]', 'change', ({ target }) => {
Rails.delegate(document, '#edit_profile input[type=file]', 'change', ({ target }) => {
const avatar = document.getElementById(target.id + '-preview');
const [file] = target.files || [];
const url = file ? URL.createObjectURL(file) : avatar.dataset.originalSrc;
@@ -11,13 +11,13 @@ delegate(document, '#edit_profile input[type=file]', 'change', ({ target }) => {
avatar.src = url;
});
delegate(document, '.input-copy input', 'click', ({ target }) => {
Rails.delegate(document, '.input-copy input', 'click', ({ target }) => {
target.focus();
target.select();
target.setSelectionRange(0, target.value.length);
});
delegate(document, '.input-copy button', 'click', ({ target }) => {
Rails.delegate(document, '.input-copy button', 'click', ({ target }) => {
const input = target.parentNode.querySelector('.input-copy__wrapper input');
const oldReadOnly = input.readonly;