From a544d84e9a9b0ac5cc72184d0702337058c73887 Mon Sep 17 00:00:00 2001 From: Farrel Augusta Dinata Date: Tue, 26 Nov 2024 15:31:25 +0700 Subject: [PATCH] refactor: move accordion js logic in the separate js file --- app/views/index.php | 6 +++++- app/views/templates/header.php | 30 ++---------------------------- public/assets/js/index.js | 20 ++++++++++++++++++++ public/assets/js/js.js | 0 4 files changed, 27 insertions(+), 29 deletions(-) create mode 100644 public/assets/js/index.js delete mode 100644 public/assets/js/js.js diff --git a/app/views/index.php b/app/views/index.php index 2025c64..4338969 100644 --- a/app/views/index.php +++ b/app/views/index.php @@ -159,4 +159,8 @@ - \ No newline at end of file + + + + + \ No newline at end of file diff --git a/app/views/templates/header.php b/app/views/templates/header.php index 8ad22ee..998115e 100644 --- a/app/views/templates/header.php +++ b/app/views/templates/header.php @@ -13,32 +13,6 @@ font-family: 'Reddit Sans'; } - - - - - - - - \ No newline at end of file + \ No newline at end of file diff --git a/public/assets/js/index.js b/public/assets/js/index.js new file mode 100644 index 0000000..e62ef15 --- /dev/null +++ b/public/assets/js/index.js @@ -0,0 +1,20 @@ +$(function () { + $("#jacord").accordion({ + collapsible: true, + active: false, + heightStyle: "content", + beforeActivate: function (event, ui) { + var items = $(this).find('> li'); + + if (ui.newHeader.length > 0) { + items.each(function () { + if (this !== ui.newHeader[0].parentElement) { + $(this).hide(); + } + }); + } else { + items.show(); + } + } + }); +}); \ No newline at end of file diff --git a/public/assets/js/js.js b/public/assets/js/js.js deleted file mode 100644 index e69de29..0000000