1/*! 2 * jQuery UI Focusable 1.13.2 3 * http://jqueryui.com 4 * 5 * Copyright jQuery Foundation and other contributors 6 * Released under the MIT license. 7 * http://jquery.org/license 8 */ 9 10//>>label: :focusable Selector 11//>>group: Core 12//>>description: Selects elements which can be focused. 13//>>docs: http://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" ) && visible( $( element ) ); 66 }; 67 68// Support: IE 8 only 69// IE 8 doesn't resolve inherit to visible/hidden for computed values 70 function visible( element ) { 71 var visibility = element.css( "visibility" ); 72 while ( visibility === "inherit" ) { 73 element = element.parent(); 74 visibility = element.css( "visibility" ); 75 } 76 return visibility === "visible"; 77 } 78 79 $.extend( $.expr.pseudos, { 80 focusable: function( element ) { 81 return $.ui.focusable( element, $.attr( element, "tabindex" ) != null ); 82 } 83 } ); 84 85 return $.ui.focusable; 86 87} );
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.