2015-07-16 13:09:14 +00:00
|
|
|
/*!
|
|
|
|
* jQuery UI Focusable @VERSION
|
|
|
|
* http://jqueryui.com
|
|
|
|
*
|
|
|
|
* Copyright jQuery Foundation and other contributors
|
|
|
|
* Released under the MIT license.
|
|
|
|
* http://jquery.org/license
|
|
|
|
*/
|
|
|
|
|
|
|
|
//>>label: focusable
|
|
|
|
//>>group: Core
|
|
|
|
//>>description: Selects elements which can be focused.
|
|
|
|
//>>docs: http://api.jqueryui.com/focusable-selector/
|
|
|
|
|
|
|
|
( function( factory ) {
|
|
|
|
if ( typeof define === "function" && define.amd ) {
|
|
|
|
|
|
|
|
// AMD. Register as an anonymous module.
|
|
|
|
define( [ "jquery", "./version" ], factory );
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// Browser globals
|
|
|
|
factory( jQuery );
|
|
|
|
}
|
|
|
|
} ( function( $ ) {
|
|
|
|
|
2015-08-21 04:14:57 +00:00
|
|
|
// Selectors
|
2015-07-16 13:09:14 +00:00
|
|
|
$.ui.focusable = function( element, hasTabindex ) {
|
|
|
|
var map, mapName, img,
|
|
|
|
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 + "']" )[ 0 ];
|
|
|
|
return !!img && visible( img );
|
|
|
|
}
|
|
|
|
return ( /^(input|select|textarea|button|object)$/.test( nodeName ) ?
|
|
|
|
!element.disabled :
|
|
|
|
"a" === nodeName ?
|
|
|
|
element.href || hasTabindex :
|
|
|
|
hasTabindex ) &&
|
2015-08-21 04:14:57 +00:00
|
|
|
|
|
|
|
// The element and all of its ancestors must be visible
|
2015-07-16 13:09:14 +00:00
|
|
|
visible( element );
|
|
|
|
};
|
|
|
|
|
|
|
|
function visible( element ) {
|
|
|
|
return $.expr.filters.visible( element ) &&
|
|
|
|
!$( element ).parents().addBack().filter( function() {
|
|
|
|
return $.css( this, "visibility" ) === "hidden";
|
|
|
|
} ).length;
|
|
|
|
}
|
|
|
|
|
|
|
|
$.extend( $.expr[ ":" ], {
|
|
|
|
focusable: function( element ) {
|
|
|
|
return $.ui.focusable( element, $.attr( element, "tabindex" ) != null );
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
|
|
|
|
return $.ui.focusable;
|
|
|
|
|
|
|
|
} ) );
|