From cb1ac3e789b47cb3d02af417ad1360d535704813 Mon Sep 17 00:00:00 2001 From: Burak Civan Date: Mon, 14 Nov 2022 11:59:16 +0300 Subject: [PATCH] added condition --- public/akaunting-js/generalAction.js | 52 +++++++++++++++------------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/public/akaunting-js/generalAction.js b/public/akaunting-js/generalAction.js index 1f8e516c1..ccfb0a75a 100644 --- a/public/akaunting-js/generalAction.js +++ b/public/akaunting-js/generalAction.js @@ -446,33 +446,35 @@ document.querySelectorAll('[data-page-title-first]').forEach((first) => { document.querySelectorAll('[data-page-title-second]').forEach((second) => { let title_truncate = first.querySelector('[data-title-truncate]'); - if (first.clientWidth < title_truncate.clientWidth) { - // added specific width styling for truncate text - title_truncate.style.width = first.clientWidth + 'px'; - let subtract = title_truncate.clientWidth - 40; - title_truncate.style.width = subtract + 'px'; - title_truncate.classList.add('truncate'); - // added specific width styling for truncate text - - // added specific width styling into the parent title element for truncate text - first.classList.add('w-full', 'sm:w-6/12'); - // added specific width styling into the parent title element for truncate text - - title_truncate.parentNode.classList.add('overflow-x-hidden', 'hide-scroll-bar'); + if (title_truncate !== null) { + if (first.clientWidth < title_truncate.clientWidth) { + // added specific width styling for truncate text + title_truncate.style.width = first.clientWidth + 'px'; + let subtract = title_truncate.clientWidth - 40; + title_truncate.style.width = subtract + 'px'; + title_truncate.classList.add('truncate'); + // added specific width styling for truncate text - // added truncate animation for truncated text - title_truncate.addEventListener('mouseover', function () { - this.classList.add('animate-marquee'); - this.classList.remove('truncate'); - this.style.animationPlayState = 'running'; - }); + // added specific width styling into the parent title element for truncate text + first.classList.add('w-full', 'sm:w-6/12'); + // added specific width styling into the parent title element for truncate text - title_truncate.addEventListener('mouseout', function () { - this.style.animationPlayState = 'paused'; - this.classList.remove('animate-marquee'); - this.classList.add('truncate'); - }); - // added truncate animation for truncated text + title_truncate.parentNode.classList.add('overflow-x-hidden', 'hide-scroll-bar'); + + // added truncate animation for truncated text + title_truncate.addEventListener('mouseover', function () { + this.classList.add('animate-marquee'); + this.classList.remove('truncate'); + this.style.animationPlayState = 'running'; + }); + + title_truncate.addEventListener('mouseout', function () { + this.style.animationPlayState = 'paused'; + this.classList.remove('animate-marquee'); + this.classList.add('truncate'); + }); + // added truncate animation for truncated text + } } // remove width class name for extend the right side