Skip to content

Commit

Permalink
Format js
Browse files Browse the repository at this point in the history
  • Loading branch information
williambelle committed May 17, 2024
1 parent 8cb26bb commit 43a4675
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions assets/components/molecules/breadcrumb/breadcrumb.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
});
};

1 comment on commit 43a4675

@alinekeller
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merci pour les corrections !

Please sign in to comment.