From 43a4675cc683631977abbf3242c050ba4162c1ab Mon Sep 17 00:00:00 2001 From: William Belle Date: Fri, 17 May 2024 13:30:43 +0200 Subject: [PATCH] Format js --- .../molecules/breadcrumb/breadcrumb.js | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/assets/components/molecules/breadcrumb/breadcrumb.js b/assets/components/molecules/breadcrumb/breadcrumb.js index d77cd54f..6b449618 100644 --- a/assets/components/molecules/breadcrumb/breadcrumb.js +++ b/assets/components/molecules/breadcrumb/breadcrumb.js @@ -5,23 +5,23 @@ export default () => { const breadcrumbDropToggle = $('.dropdown-toggle'); // add class 'has-expanded-links' - expandBreadcrumb.click(function(){ - $(".breadcrumb-wrapper .breadcrumb").addClass("has-expanded-links"); + expandBreadcrumb.on('click', () => { + $('.breadcrumb-wrapper .breadcrumb').addClass('has-expanded-links'); }); // improve dropdown position - breadcrumbDropToggle.click(function(){ - var btnPos = $(this).offset().left; - var documentWitdh = $(document).width(); - var dropdown = $(this).siblings(".dropdown-menu"); - var dropdownWidth = dropdown.width(); - var btnOffset = documentWitdh - btnPos; + breadcrumbDropToggle.on('click', (e) => { + const btnPos = $(e.currentTarget).offset().left; + const documentWitdh = $(document).width(); + const dropdown = $(e.currentTarget).siblings('.dropdown-menu'); + const dropdownWidth = dropdown.width(); + const btnOffset = documentWitdh - btnPos; // remove class 'open-left' from all .dropdown-menu elements - $(".dropdown-menu").removeClass("open-left"); + $('.dropdown-menu').removeClass('open-left'); // add the class back if the dropdown is too close to the right side of the window - if ( dropdownWidth > btnOffset ) { - dropdown.addClass("open-left"); + if (dropdownWidth > btnOffset) { + dropdown.addClass('open-left'); } }); };