From 53818f50c6da773d006074b1de92b9f525ab61cf Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Thu, 12 Feb 2015 13:08:08 +0100 Subject: [PATCH] Skip Links: Add anchor handlint to events refs #7933 --- application/views/scripts/layout/menu.phtml | 1 + public/js/icinga/events.js | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/application/views/scripts/layout/menu.phtml b/application/views/scripts/layout/menu.phtml index d169ec8fc..e4e89bf25 100644 --- a/application/views/scripts/layout/menu.phtml +++ b/application/views/scripts/layout/menu.phtml @@ -10,5 +10,6 @@ use Icinga\Web\Widget\SearchDashboard; /> +

diff --git a/public/js/icinga/events.js b/public/js/icinga/events.js index 16b6fb0f5..cae835351 100644 --- a/public/js/icinga/events.js +++ b/public/js/icinga/events.js @@ -334,6 +334,17 @@ return false; }, + handleAnchor: function(query) { + var element = $(query); + if (element.length > 0) { + // If we want to focus an element which has no tabindex + // add one that we can focus is + if (element.prop('tabindex') < 0) { + element.prop('tabindex', 0); + } + element.focus(); + } + }, /** * Someone clicked a link or tr[href] @@ -383,7 +394,6 @@ return; } - // ignore multiselect table row clicks if ($a.is('tr') && $a.closest('table.multiselect').length > 0) { return; @@ -393,6 +403,12 @@ event.stopPropagation(); event.preventDefault(); + // This is an anchor only + if (href.substr(0, 1) === '#' && href.substr(1, 1) !== '!') { + self.handleAnchor(href); + return; + } + // If link has hash tag... if (href.match(/#/)) { if (href === '#') {