2011-01-31 19:33:16 +00:00
|
|
|
/**
|
|
|
|
|
* jQuery tabIndex
|
|
|
|
|
*/
|
|
|
|
|
( function( $ ) {
|
2010-09-04 04:00:09 +00:00
|
|
|
/**
|
2010-09-15 02:03:24 +00:00
|
|
|
* Finds the lowerst tabindex in use within a selection
|
|
|
|
|
*
|
2011-01-10 05:33:03 +00:00
|
|
|
* @return number Lowest tabindex on the page
|
2010-09-15 02:03:24 +00:00
|
|
|
*/
|
2011-01-10 05:33:03 +00:00
|
|
|
$.fn.firstTabIndex = function() {
|
2011-05-22 23:52:16 +00:00
|
|
|
var minTabIndex = null;
|
|
|
|
|
$(this).find( '[tabindex]' ).each( function( i ) {
|
2011-02-01 02:28:10 +00:00
|
|
|
var tabIndex = parseInt( $(this).attr( 'tabindex' ), 10 );
|
2011-06-06 20:57:28 +00:00
|
|
|
// In IE6/IE7 the above jQuery selector returns all elements,
|
|
|
|
|
// becuase it has a default value for tabIndex in IE6/IE7 of 0
|
|
|
|
|
// (rather than null/undefined). Therefore check "> 0" as well
|
2011-06-06 21:43:03 +00:00
|
|
|
if ( tabIndex > 0 ) {
|
|
|
|
|
if ( i === 0 ) {
|
|
|
|
|
minTabIndex = tabIndex;
|
|
|
|
|
} else if ( tabIndex < minTabIndex ) {
|
|
|
|
|
minTabIndex = tabIndex;
|
|
|
|
|
}
|
2010-09-15 02:03:24 +00:00
|
|
|
}
|
|
|
|
|
} );
|
|
|
|
|
return minTabIndex;
|
|
|
|
|
};
|
2011-01-10 05:33:03 +00:00
|
|
|
|
2010-09-15 02:03:24 +00:00
|
|
|
/**
|
|
|
|
|
* Finds the highest tabindex in use within a selection
|
2010-09-04 04:00:09 +00:00
|
|
|
*
|
2011-01-10 05:33:03 +00:00
|
|
|
* @return number Highest tabindex on the page
|
2010-09-04 04:00:09 +00:00
|
|
|
*/
|
2011-01-10 05:33:03 +00:00
|
|
|
$.fn.lastTabIndex = function() {
|
2011-05-22 23:52:16 +00:00
|
|
|
var maxTabIndex = null;
|
|
|
|
|
$(this).find( '[tabindex]' ).each( function( i ) {
|
2011-02-01 02:28:10 +00:00
|
|
|
var tabIndex = parseInt( $(this).attr( 'tabindex' ), 10 );
|
2011-05-22 23:52:16 +00:00
|
|
|
if ( i === 0 ) {
|
|
|
|
|
maxTabIndex = tabIndex;
|
|
|
|
|
} else if ( tabIndex > maxTabIndex ) {
|
2010-09-04 04:00:09 +00:00
|
|
|
maxTabIndex = tabIndex;
|
|
|
|
|
}
|
|
|
|
|
} );
|
|
|
|
|
return maxTabIndex;
|
2011-01-31 19:33:16 +00:00
|
|
|
};
|
2011-05-22 23:52:16 +00:00
|
|
|
} )( jQuery );
|