[icinga-checkins] icinga.org: icingaweb2/feature/organize-headings-7976: Focus: Set the focus to the next usable element

git at icinga.org git at icinga.org
Fri Feb 13 11:40:16 CET 2015


Module: icingaweb2
Branch: feature/organize-headings-7976
Commit: bcc03f8160c2c849a7cd399070dc0396ab5eeaa6
URL:    https://git.icinga.org/?p=icingaweb2.git;a=commit;h=bcc03f8160c2c849a7cd399070dc0396ab5eeaa6

Author: Marius Hein <marius.hein at netways.de>
Date:   Fri Feb 13 11:39:28 2015 +0100

Focus: Set the focus to the next usable element

Fix copy and paste error and find h1 first.

refs #7976

---

 public/js/icinga/events.js |   20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/public/js/icinga/events.js b/public/js/icinga/events.js
index 57c3656..49c2343 100644
--- a/public/js/icinga/events.js
+++ b/public/js/icinga/events.js
@@ -337,21 +337,19 @@
         handleAnchor: function(query) {
             var $element = $(query);
             if ($element.length > 0) {
-                // Try to find the first header. It is more pleasant to users
-                // to select the header instead a container
-                var $header = $element.find(':header:first');
-                if ($header.length > 0) {
-                    $element = $header;
-                } else {
-                    var $input = $element.find(':header:first');
-                    if ($input.length > 0) {
-                        $element = $input
+                var focusQueries = ['h1:first', ':header:first', ':input:first'];
+                $.each(focusQueries, function(index,q) {
+                    var $item = $element.find(q);
+                    if ($item.length > 0) {
+                        $element = $item;
+                        return false;
                     }
-                }
+                });
+
                 // 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.prop('tabindex', '-1');
                 }
                 $element.focus();
             }



More information about the icinga-checkins mailing list