Skip to content

Commit

Permalink
Remove dependency on jQuery.inArray.
Browse files Browse the repository at this point in the history
  • Loading branch information
tobie committed Jun 13, 2010
1 parent ea9bfff commit e4ec223
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions jquery.glob.js
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,18 @@ function isArray(obj) {
return toString.call(obj) === "[object Array]";
}

function arrayIndexOf( array, item ) {
if ( array.indexOf ) {
return array.indexOf( item );
}
for ( var i = 0, length = array.length; i < length; i++ ) {
if ( array[ i ] === item ) {
return i;
}
}
return -1;
}

// *************************************** Numbers ***************************************

function expandNumber(number, precision, formatInfo) {
Expand Down Expand Up @@ -697,13 +709,13 @@ function getDayIndex(cal, value, abbr) {
}
value = toUpper( value );
if ( abbr ) {
ret = $.inArray( value, upperDays[ 1 ] );
ret = arrayIndexOf( upperDays[ 1 ], value );
if ( ret === -1 ) {
ret = $.inArray( value, upperDays[ 2 ] );
ret = arrayIndexOf( upperDays[ 2 ], value );
}
}
else {
ret = $.inArray( value, upperDays[ 0 ] );
ret = arrayIndexOf( upperDays[ 0 ], value );
}
return ret;
}
Expand All @@ -724,9 +736,9 @@ function getMonthIndex(cal, value, abbr) {
];
}
value = toUpper( value );
var i = $.inArray( value, abbr ? upperMonths[ 1 ] : upperMonths[ 0 ] );
var i = arrayIndexOf( abbr ? upperMonths[ 1 ] : upperMonths[ 0 ], value );
if ( i < 0 ) {
i = $.inArray( value, abbr ? upperMonthsGen[ 1 ] : upperMonthsGen[ 0 ] );
i = arrayIndexOf( abbr ? upperMonthsGen[ 1 ] : upperMonthsGen[ 0 ], value );
}
return i;
}
Expand Down

0 comments on commit e4ec223

Please sign in to comment.