Focus: Set the focus to the next usable element
Fix copy and paste error and find h1 first. refs #7976
This commit is contained in:
parent
ce3a564de7
commit
bcc03f8160
|
@ -337,21 +337,19 @@
|
||||||
handleAnchor: function(query) {
|
handleAnchor: function(query) {
|
||||||
var $element = $(query);
|
var $element = $(query);
|
||||||
if ($element.length > 0) {
|
if ($element.length > 0) {
|
||||||
// Try to find the first header. It is more pleasant to users
|
var focusQueries = ['h1:first', ':header:first', ':input:first'];
|
||||||
// to select the header instead a container
|
$.each(focusQueries, function(index,q) {
|
||||||
var $header = $element.find(':header:first');
|
var $item = $element.find(q);
|
||||||
if ($header.length > 0) {
|
if ($item.length > 0) {
|
||||||
$element = $header;
|
$element = $item;
|
||||||
} else {
|
return false;
|
||||||
var $input = $element.find(':header:first');
|
|
||||||
if ($input.length > 0) {
|
|
||||||
$element = $input
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
// If we want to focus an element which has no tabindex
|
// If we want to focus an element which has no tabindex
|
||||||
// add one that we can focus is
|
// add one that we can focus is
|
||||||
if ($element.prop('tabindex') < 0) {
|
if ($element.prop('tabindex') < 0) {
|
||||||
$element.prop('tabindex', 0);
|
$element.prop('tabindex', '-1');
|
||||||
}
|
}
|
||||||
$element.focus();
|
$element.focus();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue