aboutsummaryrefslogtreecommitdiffstats
path: root/ui/core.js
diff options
context:
space:
mode:
authorAlexander Schmitz <arschmitz@gmail.com>2015-07-16 09:09:14 -0400
committerAlexander Schmitz <arschmitz@gmail.com>2015-08-08 00:29:36 -0400
commit475ccefd97ec24d76cfa6767c007501c14934ba6 (patch)
tree075cd4a1a518cac8e801e9ed5c0c6e6bc1f37cb4 /ui/core.js
parent4916487440b0c087e6e5996522cf478af26df591 (diff)
downloadjquery-ui-475ccefd97ec24d76cfa6767c007501c14934ba6.tar.gz
jquery-ui-475ccefd97ec24d76cfa6767c007501c14934ba6.zip
Core: Move focusable into its own module
Ref #9647
Diffstat (limited to 'ui/core.js')
-rw-r--r--ui/core.js36
1 files changed, 2 insertions, 34 deletions
diff --git a/ui/core.js b/ui/core.js
index 1072e89f1..a0931dffa 100644
--- a/ui/core.js
+++ b/ui/core.js
@@ -22,6 +22,7 @@
"jquery",
"./data",
"./disable-selection",
+ "./focusable",
"./version"
], factory );
} else {
@@ -180,44 +181,11 @@ $.fn.extend( {
}
} );
-// selectors
-function focusable( 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 ) &&
- // the element and all of its ancestors must be visible
- 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 focusable( element, $.attr( element, "tabindex" ) != null );
- },
-
tabbable: function( element ) {
var tabIndex = $.attr( element, "tabindex" ),
hasTabindex = tabIndex != null;
- return ( !hasTabindex || tabIndex >= 0 ) && focusable( element, hasTabindex );
+ return ( !hasTabindex || tabIndex >= 0 ) && $.ui.focusable( element, hasTabindex );
}
} );