Debian Codegraph @

ui/focusable.js

raw symbols SCIP
1 /*!
2 * jQuery UI Focusable 1.14.2
3 * https://jqueryui.com
4 *
5 * Copyright OpenJS Foundation and other contributors
6 * Released under the MIT license.
7 * https://jquery.org/license
8 */
9
10 //>>label: :focusable Selector
11 //>>group: Core
12 //>>description: Selects elements which can be focused.
13 //>>docs: https://api.jqueryui.com/focusable-selector/
14
15 ( function( factory ) {
16 "use strict";
17
18 if ( typeof define === "function" && define.amd ) {
19
20 // AMD. Register as an anonymous module.
21 define( [ "jquery", "./version" ], factory );
22 } else {
23
24 // Browser globals
25 factory( jQuery );
26 }
27 } )( function( $ ) {
28 "use strict";
29
30 // Selectors
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 // Form controls within a disabled fieldset are disabled.
51 // However, controls within the fieldset's legend do not get disabled.
52 // Since controls generally aren't placed inside legends, we skip
53 // this portion of the check.
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 } );