| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
( function( factory ) { |
| 16 |
"use strict"; |
| 17 |
|
| 18 |
if ( typeof define === "function" && define.amd ) { |
| 19 |
|
| 20 |
|
| 21 |
define( [ "jquery", "./version" ], factory ); |
| 22 |
} else { |
| 23 |
|
| 24 |
|
| 25 |
factory( jQuery ); |
| 26 |
} |
| 27 |
} )( function( $ ) { |
| 28 |
"use strict"; |
| 29 |
|
| 30 |
|
| 31 |
$.ui.focusable = function( element, hasTabindex ) { |
| 32 |
var map, mapName, img, focusableIfVisible, fieldset, |
| 33 |
nodeName = element.nodeName.toLowerCase(); |
| 34 |
|
| 35 |
if ( "area" === nodeName ) { |
| 36 |
map = element.parentNode; |
| 37 |
mapName = map.name; |
| 38 |
if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) { |
| 39 |
return false; |
| 40 |
} |
| 41 |
img = $( "img[usemap='#" + mapName + "']" ); |
| 42 |
return img.length > 0 && img.is( ":visible" ); |
| 43 |
} |
| 44 |
|
| 45 |
if ( /^(input|select|textarea|button|object)$/.test( nodeName ) ) { |
| 46 |
focusableIfVisible = !element.disabled; |
| 47 |
|
| 48 |
if ( focusableIfVisible ) { |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
fieldset = $( element ).closest( "fieldset" )[ 0 ]; |
| 55 |
if ( fieldset ) { |
| 56 |
focusableIfVisible = !fieldset.disabled; |
| 57 |
} |
| 58 |
} |
| 59 |
} else if ( "a" === nodeName ) { |
| 60 |
focusableIfVisible = element.href || hasTabindex; |
| 61 |
} else { |
| 62 |
focusableIfVisible = hasTabindex; |
| 63 |
} |
| 64 |
|
| 65 |
return focusableIfVisible && $( element ).is( ":visible" ) && |
| 66 |
$( element ).css( "visibility" ) === "visible"; |
| 67 |
}; |
| 68 |
|
| 69 |
$.extend( $.expr.pseudos, { |
| 70 |
focusable: function( element ) { |
| 71 |
return $.ui.focusable( element, $.attr( element, "tabindex" ) != null ); |
| 72 |
} |
| 73 |
} ); |
| 74 |
|
| 75 |
return $.ui.focusable; |
| 76 |
|
| 77 |
} ); |