Localisation updates from http://translatewiki.net.
[mediawiki.git] / resources / jquery / jquery.tabIndex.js
blobcdae0badc913f5af6b0258e738272399f10e1e32
1 /**
2  * jQuery tabIndex
3  */
4 ( function ( $ ) {
6         /**
7          * Finds the lowerst tabindex in use within a selection
8          *
9          * @return number Lowest tabindex on the page
10          */
11         $.fn.firstTabIndex = function () {
12                 var minTabIndex = null;
13                 $(this).find( '[tabindex]' ).each( function () {
14                         var tabIndex = parseInt( $(this).prop( 'tabindex' ), 10 );
15                         // In IE6/IE7 the above jQuery selector returns all elements,
16                         // becuase it has a default value for tabIndex in IE6/IE7 of 0
17                         // (rather than null/undefined). Therefore check "> 0" as well.
18                         // Under IE7 under Windows NT 5.2 is also capable of returning NaN.
19                         if ( tabIndex > 0 && !isNaN( tabIndex ) ) {
20                                 // Initial value
21                                 if ( minTabIndex === null ) {
22                                         minTabIndex = tabIndex;
23                                 } else if ( tabIndex < minTabIndex ) {
24                                         minTabIndex = tabIndex;
25                                 }
26                         }
27                 } );
28                 return minTabIndex;
29         };
31         /**
32          * Finds the highest tabindex in use within a selection
33          *
34          * @return number Highest tabindex on the page
35          */
36         $.fn.lastTabIndex = function () {
37                 var maxTabIndex = null;
38                 $(this).find( '[tabindex]' ).each( function () {
39                         var tabIndex = parseInt( $(this).prop( 'tabindex' ), 10 );
40                         if ( tabIndex > 0 && !isNaN( tabIndex ) ) {
41                                 // Initial value
42                                 if ( maxTabIndex === null ) {
43                                         maxTabIndex = tabIndex;
44                                 } else if ( tabIndex > maxTabIndex ) {
45                                         maxTabIndex = tabIndex;
46                                 }
47                         }
48                 } );
49                 return maxTabIndex;
50         };
52 }( jQuery ) );