[frio] Add .add-to-modal delegated event on anchors

- Improve hovercard button accessibility
This commit is contained in:
Hypolite Petovan 2019-06-03 08:31:43 -04:00
parent dc2f1d6bd3
commit 9ac7d20df3
2 changed files with 17 additions and 2 deletions

View file

@ -93,6 +93,21 @@ $(document).ready(function(){
input.val(img);
});
// Generic delegated event to open an anchor URL in a modal.
// Used in the hovercard.
document.getElementsByTagName('body')[0].addEventListener('click', function(e) {
var target = e.target;
while (target) {
if (target.matches && target.matches('a.add-to-modal')) {
addToModal(target.href);
e.preventDefault();
return false;
}
target = target.parentNode || null;
}
});
});
// Overwrite Dialog.show from main js to load the filebrowser into a bs modal.