fixed breadcrumbs being undefined

This commit is contained in:
Phil Hughes 2017-08-17 14:00:50 +01:00
parent dae629e5e9
commit bec6ea20f6
No known key found for this signature in database
GPG Key ID: DB8CE4B3A3EE91AB
1 changed files with 11 additions and 8 deletions

View File

@ -8,14 +8,17 @@ export const addTooltipToEl = (el) => {
export default () => {
const breadcrumbs = document.querySelector('.breadcrumbs-list');
const topLevelLinks = breadcrumbs.querySelectorAll('.breadcrumbs-list > li > a');
const $expander = $('.js-breadcrumbs-collapsed-expander');
topLevelLinks.forEach(el => addTooltipToEl(el));
if (breadcrumbs) {
const topLevelLinks = breadcrumbs.querySelectorAll('.breadcrumbs-list > li > a');
const $expander = $('.js-breadcrumbs-collapsed-expander');
$expander.closest('.dropdown')
.on('show.bs.dropdown hide.bs.dropdown', (e) => {
$('.js-breadcrumbs-collapsed-expander', e.currentTarget).toggleClass('open')
.tooltip('hide');
});
topLevelLinks.forEach(el => addTooltipToEl(el));
$expander.closest('.dropdown')
.on('show.bs.dropdown hide.bs.dropdown', (e) => {
$('.js-breadcrumbs-collapsed-expander', e.currentTarget).toggleClass('open')
.tooltip('hide');
});
}
};