38 lines
959 B
Plaintext
38 lines
959 B
Plaintext
(function() {;
|
|
'use strict';
|
|
|
|
window.utils = window.utils || {};
|
|
|
|
// allows for multiple file uploads with separate inputs
|
|
window.utils.tooltip = function(tt) {
|
|
var handle = tt.querySelector('.tooltip__handle');
|
|
var content = tt.querySelector('.tooltip__content');
|
|
|
|
var left = false;
|
|
|
|
handle.addEventListener('mouseenter', function() {
|
|
left = false;
|
|
content.classList.toggle('to-left', handle.getBoundingClientRect().left + 300 > window.innerWidth);
|
|
content.classList.remove('hidden');
|
|
});
|
|
|
|
handle.addEventListener('mouseleave', function() {
|
|
left = true;
|
|
window.setTimeout(function() {
|
|
if (left) {
|
|
content.classList.add('hidden');
|
|
}
|
|
}, 250);
|
|
});
|
|
}
|
|
|
|
})();
|
|
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
|
|
// initialize tooltips
|
|
Array.from(document.querySelectorAll('.js-tooltip')).forEach(function(tt) {
|
|
window.utils.tooltip(tt);
|
|
});
|
|
});
|