| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- /*!
- * jQuery UI Focusable 1.14.1
- * https://jqueryui.com
- *
- * Copyright OpenJS Foundation and other contributors
- * Released under the MIT license.
- * https://jquery.org/license
- */
- //>>label: :focusable Selector
- //>>group: Core
- //>>description: Selects elements which can be focused.
- //>>docs: https://api.jqueryui.com/focusable-selector/
- ( function( factory ) {
- "use strict";
- if ( typeof define === "function" && define.amd ) {
- // AMD. Register as an anonymous module.
- define( [ "jquery", "./version" ], factory );
- } else {
- // Browser globals
- factory( jQuery );
- }
- } )( function( $ ) {
- "use strict";
- // Selectors
- $.ui.focusable = function( element, hasTabindex ) {
- var map, mapName, img, focusableIfVisible, fieldset,
- nodeName = element.nodeName.toLowerCase();
- if ( "area" === nodeName ) {
- map = element.parentNode;
- mapName = map.name;
- if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
- return false;
- }
- img = $( "img[usemap='#" + mapName + "']" );
- return img.length > 0 && img.is( ":visible" );
- }
- if ( /^(input|select|textarea|button|object)$/.test( nodeName ) ) {
- focusableIfVisible = !element.disabled;
- if ( focusableIfVisible ) {
- // Form controls within a disabled fieldset are disabled.
- // However, controls within the fieldset's legend do not get disabled.
- // Since controls generally aren't placed inside legends, we skip
- // this portion of the check.
- fieldset = $( element ).closest( "fieldset" )[ 0 ];
- if ( fieldset ) {
- focusableIfVisible = !fieldset.disabled;
- }
- }
- } else if ( "a" === nodeName ) {
- focusableIfVisible = element.href || hasTabindex;
- } else {
- focusableIfVisible = hasTabindex;
- }
- return focusableIfVisible && $( element ).is( ":visible" ) &&
- $( element ).css( "visibility" ) === "visible";
- };
- $.extend( $.expr.pseudos, {
- focusable: function( element ) {
- return $.ui.focusable( element, $.attr( element, "tabindex" ) != null );
- }
- } );
- return $.ui.focusable;
- } );
|