From 6064a5e0487428d53bd694dcebce952730992c46 Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Wed, 15 Jul 2015 20:20:41 -0400 Subject: [PATCH] Core: Move tabbable into its own module Ref #9647 --- tests/unit/core/selector.js | 5 +++-- ui/core.js | 9 +-------- ui/dialog.js | 3 ++- ui/tabbable.js | 35 +++++++++++++++++++++++++++++++++++ 4 files changed, 41 insertions(+), 11 deletions(-) create mode 100644 ui/tabbable.js diff --git a/tests/unit/core/selector.js b/tests/unit/core/selector.js index dee24809e..e553e769d 100644 --- a/tests/unit/core/selector.js +++ b/tests/unit/core/selector.js @@ -1,8 +1,9 @@ define( [ "jquery", - "ui/core", "ui/data", - "ui/focusable" + "ui/escape-selector", + "ui/focusable", + "ui/tabbable" ], function( $ ) { module( "core - selectors" ); diff --git a/ui/core.js b/ui/core.js index 9e799a04c..d443346e8 100644 --- a/ui/core.js +++ b/ui/core.js @@ -31,6 +31,7 @@ "./plugin", "./safe-active-element", "./safe-blur", + "./tabbable", "./version" ], factory ); } else { @@ -78,12 +79,4 @@ $.fn.extend( { } } ); -$.extend( $.expr[ ":" ], { - tabbable: function( element ) { - var tabIndex = $.attr( element, "tabindex" ), - hasTabindex = tabIndex != null; - return ( !hasTabindex || tabIndex >= 0 ) && $.ui.focusable( element, hasTabindex ); - } -} ); - } ) ); diff --git a/ui/dialog.js b/ui/dialog.js index acb7814d1..16d650f97 100644 --- a/ui/dialog.js +++ b/ui/dialog.js @@ -32,7 +32,8 @@ "./position", "./resizable", "./safe-active-element", - "./safe-blur" + "./safe-blur", + "./tabbable" ], factory ); } else { diff --git a/ui/tabbable.js b/ui/tabbable.js new file mode 100644 index 000000000..86bebb77b --- /dev/null +++ b/ui/tabbable.js @@ -0,0 +1,35 @@ +/*! + * jQuery UI Tabbable @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 tabbed to. +//>>docs: http://api.jqueryui.com/tabbable-selector/ + +( function( factory ) { + if ( typeof define === "function" && define.amd ) { + + // AMD. Register as an anonymous module. + define( [ "jquery", "./version", "./focusable" ], factory ); + } else { + + // Browser globals + factory( jQuery ); + } +} ( function( $ ) { + +return $.extend( $.expr[ ":" ], { + tabbable: function( element ) { + var tabIndex = $.attr( element, "tabindex" ), + hasTabindex = tabIndex != null; + return ( !hasTabindex || tabIndex >= 0 ) && $.ui.focusable( element, hasTabindex ); + } +} ); + +} ) );