js function refactoring

This commit is contained in:
Burak Civan 2022-10-18 16:50:27 +03:00
parent 967ea50877
commit 3ab2129a35
4 changed files with 21 additions and 11 deletions

View File

@ -360,16 +360,14 @@ if (navigator.userAgent.search("Firefox") >= 0) {
//margue animation for truncated text //margue animation for truncated text
document.querySelectorAll('[data-truncate]').forEach((truncate) => { document.querySelectorAll('[data-truncate]').forEach((truncate) => {
let truncateText = truncate.innerText.split(" ").join("");
if (truncate.offsetWidth > truncate.parentElement.clientWidth || truncate.offsetWidth > truncate.parentElement.parentElement.clientWidth) { if (truncate.offsetWidth > truncate.parentElement.clientWidth || truncate.offsetWidth > truncate.parentElement.parentElement.clientWidth) {
truncate.addEventListener('mouseover', function () { truncate.addEventListener('mouseover', function () {
truncate.parentElement.style.animationPlayState = 'running'; truncate.parentElement.style.animationPlayState = 'running';
truncate.parentElement.classList.add('animate-marquee'); truncate.parentElement.classList.add('animate-marquee');
// if (truncate.parentElement.classList.contains('truncate')) { if (truncate.parentElement.classList.contains('truncate')) {
// truncate.parentElement.classList.remove('truncate'); truncate.parentElement.classList.remove('truncate');
// } }
}); });
truncate.addEventListener('mouseout', function () { truncate.addEventListener('mouseout', function () {

View File

@ -91,7 +91,7 @@
<x-index.disable text="{{ trans_choice('general.items', 1) }}" /> <x-index.disable text="{{ trans_choice('general.items', 1) }}" />
@endif @endif
</x-slot> </x-slot>
<x-slot name="second" class="font-normal truncate" override="class"> <x-slot name="second" class="font-normal" override="class">
{{ $item->description }} {{ $item->description }}
</x-slot> </x-slot>
</x-table.td> </x-table.td>

View File

@ -1,4 +1,4 @@
<td class="{{ $class }}" {{ $attributes }}> <td data-truncate-table class="{{ $class }}" {{ $attributes }}>
@if (!empty($first)) @if (!empty($first))
@php @php
$first_attributes = $first->attributes; $first_attributes = $first->attributes;

View File

@ -8,7 +8,11 @@
} }
@endphp @endphp
<div {{ $first_attributes }}> <div {{ $first_attributes }}>
{!! $first !!} <div>
<span data-truncate>
{!! $first !!}
</span>
</div>
</div> </div>
@endif @endif
@ -21,9 +25,17 @@
} }
@endphp @endphp
<div {{ $second_attributes }}> <div {{ $second_attributes }}>
{!! $second !!} <div>
<span data-truncate>
{!! $second !!}
</span>
</div>
</div> </div>
@endif @endif
{{ $slot }} <div>
<span data-truncate>
{{ $slot }}
</span>
</div>
</th> </th>