2018-05-09 12:01:36 +05:30
|
|
|
import $ from 'jquery';
|
2021-01-03 14:25:43 +05:30
|
|
|
import { hide } from '~/tooltips';
|
2018-05-09 12:01:36 +05:30
|
|
|
|
2021-03-08 18:12:59 +05:30
|
|
|
export const addTooltipToEl = (el) => {
|
2018-03-17 18:26:18 +05:30
|
|
|
const textEl = el.querySelector('.js-breadcrumb-item-text');
|
|
|
|
|
|
|
|
if (textEl && textEl.scrollWidth > textEl.offsetWidth) {
|
|
|
|
el.setAttribute('title', el.textContent);
|
|
|
|
el.setAttribute('data-container', 'body');
|
|
|
|
el.classList.add('has-tooltip');
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
export default () => {
|
|
|
|
const breadcrumbs = document.querySelector('.js-breadcrumbs-list');
|
|
|
|
|
|
|
|
if (breadcrumbs) {
|
2018-12-13 13:39:08 +05:30
|
|
|
const topLevelLinks = [...breadcrumbs.children]
|
2021-03-08 18:12:59 +05:30
|
|
|
.filter((el) => !el.classList.contains('dropdown'))
|
|
|
|
.map((el) => el.querySelector('a'))
|
|
|
|
.filter((el) => el);
|
2018-03-17 18:26:18 +05:30
|
|
|
const $expander = $('.js-breadcrumbs-collapsed-expander');
|
|
|
|
|
2021-03-08 18:12:59 +05:30
|
|
|
topLevelLinks.forEach((el) => addTooltipToEl(el));
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2021-03-08 18:12:59 +05:30
|
|
|
$expander.closest('.dropdown').on('show.bs.dropdown hide.bs.dropdown', (e) => {
|
2021-01-03 14:25:43 +05:30
|
|
|
const $el = $('.js-breadcrumbs-collapsed-expander', e.currentTarget);
|
|
|
|
|
|
|
|
$el.toggleClass('open');
|
|
|
|
|
|
|
|
hide($el);
|
2018-12-13 13:39:08 +05:30
|
|
|
});
|
2018-03-17 18:26:18 +05:30
|
|
|
}
|
|
|
|
};
|