From dc2f1d6bd3a2f300065d2c73ea3bea36fb4cfbde Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Mon, 3 Jun 2019 08:30:24 -0400 Subject: [PATCH 1/2] Add global Javascript Element.matches polyfill --- view/js/main.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/view/js/main.js b/view/js/main.js index cd09de0143..a2e2698a82 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -1,4 +1,21 @@ // @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPLv3-or-later + +// https://developer.mozilla.org/en-US/docs/Web/API/Element/matches#Polyfill +if (!Element.prototype.matches) { + Element.prototype.matches = + Element.prototype.matchesSelector || + Element.prototype.mozMatchesSelector || + Element.prototype.msMatchesSelector || + Element.prototype.oMatchesSelector || + Element.prototype.webkitMatchesSelector || + function(s) { + var matches = (this.document || this.ownerDocument).querySelectorAll(s), + i = matches.length; + while (--i >= 0 && matches.item(i) !== this) {} + return i > -1; + }; +} + function resizeIframe(obj) { _resizeIframe(obj, 0); } From 9ac7d20df3916acf9f9d0042180601d51fe59857 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Mon, 3 Jun 2019 08:31:43 -0400 Subject: [PATCH 2/2] [frio] Add .add-to-modal delegated event on anchors - Improve hovercard button accessibility --- view/templates/hovercard.tpl | 4 ++-- view/theme/frio/js/modal.js | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/view/templates/hovercard.tpl b/view/templates/hovercard.tpl index a688f57b20..017e096afc 100644 --- a/view/templates/hovercard.tpl +++ b/view/templates/hovercard.tpl @@ -21,8 +21,8 @@ {{* here are the differnt actions like privat message, poke, delete and so on *}} {{* @todo we have two different photo menus one for contacts and one for items at the network stream. We currently use the contact photo menu, so the items options are missing We need to move them *}}
- {{if $profile.actions.pm}}{{/if}} - {{if $profile.actions.poke}}{{/if}} + {{if $profile.actions.pm}}{{$profile.actions.pm.0}}{{/if}} + {{if $profile.actions.poke}}{{$profile.actions.poke.0}}{{/if}}
{{if $profile.actions.network}}{{/if}} diff --git a/view/theme/frio/js/modal.js b/view/theme/frio/js/modal.js index ab263bc2ab..9bca427779 100644 --- a/view/theme/frio/js/modal.js +++ b/view/theme/frio/js/modal.js @@ -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.