From 5079d52ccedf588cd39632839c20b4c0a4bc08b9 Mon Sep 17 00:00:00 2001 From: Burak Civan Date: Tue, 7 Jun 2022 15:23:37 +0300 Subject: [PATCH] table click event controlled for responsive --- public/akaunting-js/generalAction.js | 34 +++++++++++++++------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/public/akaunting-js/generalAction.js b/public/akaunting-js/generalAction.js index f3912a3f5..deb36a43b 100644 --- a/public/akaunting-js/generalAction.js +++ b/public/akaunting-js/generalAction.js @@ -11,27 +11,29 @@ document.querySelectorAll("[data-table-list]").forEach((row) => { //redirect edit or show page for table row click document.querySelectorAll("[data-table-body]").forEach((table) => { - let rows = table.querySelectorAll("tr"); + if (document.body.clientWidth >= 991) { + let rows = table.querySelectorAll("tr"); - rows.forEach((row) => { - let row_href = row.getAttribute("href"); + rows.forEach((row) => { + let row_href = row.getAttribute("href"); - if (! row_href) { - return; - } + if (!row_href) { + return; + } - let td = row.getElementsByTagName("td"); - let first_selector = row.querySelector('[data-bulkaction]') && row.querySelector('[data-bulkaction]') !== null ? 1 : 0; + let td = row.getElementsByTagName("td"); + let first_selector = row.querySelector("[data-bulkaction]") && row.querySelector("[data-bulkaction]") !== null ? 1 : 0; - if (row_href) { - for (let i=first_selector; i { - window.location.href = row_href; - }); - } + if (row_href) { + for (let i = first_selector; i < td.length - 1; i++) { + let td_item = td[i]; + td_item.addEventListener("click", () => { + window.location.href = row_href; + }); + } + } + }); } - }); }); //redirect edit or show page for table row click