|
|
@@ -1,3 +1,4 @@
|
|
|
+@unless($scriptOnly ?? false)
|
|
|
<div class="row">
|
|
|
<div class="@if(!($right ?? null)) offset-md-{{ $offset ?? 4 }} col-md-{{ (isset($offset)) ? 12 - $offset : 8 }} @endif buttons d-flex flex-wrap gap-1">
|
|
|
<button type="submit" class="btn btn-sm mb-1 btn-primary text-white" @disabled($disabled ?? false)>{{ $name ?? 'Сохранить' }}</button>
|
|
|
@@ -20,14 +21,51 @@
|
|
|
}, 'Подтверждение удаления');
|
|
|
});
|
|
|
|
|
|
- $('.buttons .btn').on('click', function (){
|
|
|
- $('.buttons').addClass('d-none');
|
|
|
-
|
|
|
-
|
|
|
- setTimeout(function () {
|
|
|
- $('.buttons').removeClass('d-none');
|
|
|
- },
|
|
|
- 2000);
|
|
|
- });
|
|
|
</script>
|
|
|
@endpush
|
|
|
+@endunless
|
|
|
+
|
|
|
+@once
|
|
|
+ @push('scripts')
|
|
|
+ <script type="module">
|
|
|
+ const submitLockDuration = 3000;
|
|
|
+
|
|
|
+ document.addEventListener('submit', function (event) {
|
|
|
+ const form = event.target;
|
|
|
+
|
|
|
+ if (!(form instanceof HTMLFormElement)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (form.dataset.submitLocked === '1') {
|
|
|
+ event.preventDefault();
|
|
|
+ event.stopImmediatePropagation();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ form.dataset.submitLocked = '1';
|
|
|
+
|
|
|
+ const submitButtons = Array.from(document.querySelectorAll('button[type="submit"], input[type="submit"]'))
|
|
|
+ .filter((button) => button.form === form);
|
|
|
+
|
|
|
+ submitButtons.forEach((button) => {
|
|
|
+ if (!button.disabled) {
|
|
|
+ button.dataset.submitLockDisabled = '1';
|
|
|
+ button.disabled = true;
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ setTimeout(function () {
|
|
|
+ delete form.dataset.submitLocked;
|
|
|
+
|
|
|
+ submitButtons.forEach((button) => {
|
|
|
+ if (button.dataset.submitLockDisabled === '1') {
|
|
|
+ button.disabled = false;
|
|
|
+ delete button.dataset.submitLockDisabled;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }, submitLockDuration);
|
|
|
+ }, true);
|
|
|
+ </script>
|
|
|
+ @endpush
|
|
|
+@endonce
|