Skip Links: Select a more useful object
Skip links can select a container and find a usable element inside. Adapt project jquery variable style. refs #7976
This commit is contained in:
parent
fdcad4928e
commit
f586714f02
|
@ -298,5 +298,8 @@ a:focus {
|
|||
}
|
||||
}
|
||||
.skip-links-inline {
|
||||
margin-top: -3.5em;
|
||||
margin-top: -4em;
|
||||
ul > li > a {
|
||||
width: 16em;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -335,14 +335,25 @@
|
|||
},
|
||||
|
||||
handleAnchor: function(query) {
|
||||
var element = $(query);
|
||||
if (element.length > 0) {
|
||||
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
|
||||
}
|
||||
}
|
||||
// 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);
|
||||
if ($element.prop('tabindex') < 0) {
|
||||
$element.prop('tabindex', 0);
|
||||
}
|
||||
element.focus();
|
||||
$element.focus();
|
||||
}
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in New Issue