import $ from 'jquery';
export function findClosestElement(box, className) {
const regex = new RegExp(`(^|\\s)${className}(\\s|$)`, 'gi');
while (!regex.test(box.className)) {
box = box.parentNode;
if (!box) {
return null;
}
}
return box;
}
export function toggleBoxCollapse(box, boxBody, icon) {
if (box.className.indexOf('collapsed-box') !== -1) {
icon.className = icon.className.replace(/fa-plus/g, 'fa-minus');
$(boxBody).slideDown(500, 'swing', () => {
box.classList.remove('collapsed-box');
}
);
} else {
icon.className = icon.className.replace(/fa-minus/g, 'fa-plus');
$(boxBody).slideUp(500, 'swing', () => {
box.classList.add('collapsed-box');
}
);
}
}
export function removeBox(box) {
$(box).slideUp(500, 'swing');
}
export function initialate() {
function bootstrapTooltips(selector) {
$('body').tooltip({ selector });
}
return { bootstrapTooltips };
}
export function toggleDropdown(selector, classes) {
selector.classList.toggle(classes);
}
|