Import: Handle uploads with sha1 starting with 0 properly
[mediawiki.git] / resources / src / jquery / jquery.tabIndex.js
blobed37aa1ea3c9b56fb34891692ffdfd6c7fa8e461
1 /**
2  * @class jQuery.plugin.tabIndex
3  */
4 ( function ( $ ) {
6         /**
7          * Find the lowest 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          * Find 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         /**
53          * @class jQuery
54          * @mixins jQuery.plugin.tabIndex
55          */
57 }( jQuery ) );