@ -33,8 +33,8 @@ $.fn.dataTableExt.oPagination.input = {
nNext . innerHTML = oSettings . oLanguage . oPaginate . sNext ;
nNext . innerHTML = oSettings . oLanguage . oPaginate . sNext ;
nLast . innerHTML = oSettings . oLanguage . oPaginate . sLast ;
nLast . innerHTML = oSettings . oLanguage . oPaginate . sLast ;
nFirst . className = "paginate_button first ";
nFirst . className = "paginate_button first disabled ";
nPrevious . className = "paginate_button previous ";
nPrevious . className = "paginate_button previous disabled ";
nNext . className = "paginate_button next" ;
nNext . className = "paginate_button next" ;
nLast . className = "paginate_button last" ;
nLast . className = "paginate_button last" ;
nOf . className = "paginate_of" ;
nOf . className = "paginate_of" ;
@ -61,54 +61,66 @@ $.fn.dataTableExt.oPagination.input = {
nPaging . appendChild ( nNext ) ;
nPaging . appendChild ( nNext ) ;
nPaging . appendChild ( nLast ) ;
nPaging . appendChild ( nLast ) ;
$ ( nFirst ) . click ( function ( ) {
$ ( nFirst ) . click ( function ( )
{
var iCurrentPage = Math . ceil ( oSettings . _iDisplayStart / oSettings . _iDisplayLength ) + 1 ;
if ( iCurrentPage != 1 )
{
oSettings . oApi . _fnPageChange ( oSettings , "first" ) ;
oSettings . oApi . _fnPageChange ( oSettings , "first" ) ;
fnCallbackDraw ( oSettings ) ;
fnCallbackDraw ( oSettings ) ;
$ ( nFirst ) . addClass ( 'disabled' ) ;
$ ( nFirst ) . addClass ( 'disabled' ) ;
$ ( nPrevious ) . addClass ( 'disabled' ) ;
$ ( nPrevious ) . addClass ( 'disabled' ) ;
$ ( nNext ) . removeClass ( 'disabled' ) ;
$ ( nNext ) . removeClass ( 'disabled' ) ;
$ ( nLast ) . removeClass ( 'disabled' ) ;
$ ( nLast ) . removeClass ( 'disabled' ) ;
}
} ) ;
} ) ;
$ ( nPrevious ) . click ( function ( ) {
$ ( nPrevious ) . click ( function ( )
{
var iCurrentPage = Math . ceil ( oSettings . _iDisplayStart / oSettings . _iDisplayLength ) + 1 ;
if ( iCurrentPage != 1 )
{
oSettings . oApi . _fnPageChange ( oSettings , "previous" ) ;
oSettings . oApi . _fnPageChange ( oSettings , "previous" ) ;
fnCallbackDraw ( oSettings ) ;
fnCallbackDraw ( oSettings ) ;
var iCurrentPage = Math . ceil ( oSettings . _iDisplayStart / oSettings . _iDisplayLength ) + 1 ;
if ( iCurrentPage == 2 )
if ( iCurrentPage == 1 )
{
{
$ ( nFirst ) . addClass ( 'disabled' ) ;
$ ( nFirst ) . addClass ( 'disabled' ) ;
$ ( nPrevious ) . addClass ( 'disabled' ) ;
$ ( nPrevious ) . addClass ( 'disabled' ) ;
}
}
else
{
$ ( nNext ) . removeClass ( 'disabled' ) ;
$ ( nNext ) . removeClass ( 'disabled' ) ;
$ ( nLast ) . removeClass ( 'disabled' ) ;
$ ( nLast ) . removeClass ( 'disabled' ) ;
}
}
} ) ;
} ) ;
$ ( nNext ) . click ( function ( ) {
$ ( nNext ) . click ( function ( )
{
var iCurrentPage = Math . ceil ( oSettings . _iDisplayStart / oSettings . _iDisplayLength ) + 1 ;
if ( iCurrentPage != ( Math . ceil ( ( oSettings . fnRecordsDisplay ( ) - 1 ) / oSettings . _iDisplayLength ) ) )
{
oSettings . oApi . _fnPageChange ( oSettings , "next" ) ;
oSettings . oApi . _fnPageChange ( oSettings , "next" ) ;
fnCallbackDraw ( oSettings ) ;
fnCallbackDraw ( oSettings ) ;
var iCurrentPage = Math . ceil ( oSettings . _iDisplayStart / oSettings . _iDisplayLength ) + 1 ;
if ( iCurrentPage == ( Math . ceil ( ( oSettings . fnRecordsDisplay ( ) - 1 ) / oSettings . _iDisplayLength ) - 1 ) )
if ( iCurrentPage == ( Math . ceil ( ( oSettings . fnRecordsDisplay ( ) - 1 ) / oSettings . _iDisplayLength ) ) )
{
{
$ ( nNext ) . addClass ( 'disabled' ) ;
$ ( nNext ) . addClass ( 'disabled' ) ;
$ ( nLast ) . addClass ( 'disabled' ) ;
$ ( nLast ) . addClass ( 'disabled' ) ;
}
}
else
{
$ ( nFirst ) . removeClass ( 'disabled' ) ;
$ ( nFirst ) . removeClass ( 'disabled' ) ;
$ ( nPrevious ) . removeClass ( 'disabled' ) ;
$ ( nPrevious ) . removeClass ( 'disabled' ) ;
}
}
} ) ;
} ) ;
$ ( nLast ) . click ( function ( ) {
$ ( nLast ) . click ( function ( )
{
var iCurrentPage = Math . ceil ( oSettings . _iDisplayStart / oSettings . _iDisplayLength ) + 1 ;
if ( iCurrentPage != ( Math . ceil ( ( oSettings . fnRecordsDisplay ( ) - 1 ) / oSettings . _iDisplayLength ) ) )
{
oSettings . oApi . _fnPageChange ( oSettings , "last" ) ;
oSettings . oApi . _fnPageChange ( oSettings , "last" ) ;
fnCallbackDraw ( oSettings ) ;
fnCallbackDraw ( oSettings ) ;
$ ( nFirst ) . removeClass ( 'disabled' ) ;
$ ( nFirst ) . removeClass ( 'disabled' ) ;
$ ( nPrevious ) . removeClass ( 'disabled' ) ;
$ ( nPrevious ) . removeClass ( 'disabled' ) ;
$ ( nNext ) . addClass ( 'disabled' ) ;
$ ( nNext ) . addClass ( 'disabled' ) ;
$ ( nLast ) . addClass ( 'disabled' ) ;
$ ( nLast ) . addClass ( 'disabled' ) ;
}
} ) ;
} ) ;
$ ( nInput ) . keyup ( function ( e ) {
$ ( nInput ) . keyup ( function ( e ) {
@ -126,29 +138,33 @@ $.fn.dataTableExt.oPagination.input = {
if ( this . value === "" || this . value . match ( /[^0-9]/ ) )
if ( this . value === "" || this . value . match ( /[^0-9]/ ) )
{
{
/* Nothing entered or non-numeric character */
/* Nothing entered or non-numeric character */
this . value = this . value . replace ( /[^\d]/g , '' ) ; // don't even allow anything but digits
return ;
return ;
}
}
var iNewStart = oSettings . _iDisplayLength * ( this . value - 1 ) ;
var iNewStart = oSettings . _iDisplayLength * ( this . value - 1 ) ;
var iEndPosition = ( Math . ceil ( ( oSettings . fnRecordsDisplay ( ) - 1 ) / oSettings . _iDisplayLength ) - 1 ) * oSettings . _iDisplayLength ;
if ( iNewStart < 0 )
if ( iNewStart < 0 )
{
{
iNewStart = 0 ;
iNewStart = 0 ;
}
}
if ( iNewStart > oSettings . fnRecordsDisplay ( ) )
if ( iNewStart > oSettings . fnRecordsDisplay ( ) )
{
{
iNewStart = iEndPosition ;
iNewStart = ( Math . ceil ( ( oSettings . fnRecordsDisplay ( ) - 1 ) / oSettings . _iDisplayLength ) - 1 ) * oSettings . _iDisplayLength ;
}
}
if ( iNewStart == 0 )
if ( iNewStart == 0 )
{
{
$ ( nFirst ) . addClass ( 'disabled' ) ;
$ ( nFirst ) . addClass ( 'disabled' ) ;
$ ( nPrevious ) . addClass ( 'disabled' ) ;
$ ( nPrevious ) . addClass ( 'disabled' ) ;
$ ( nNext ) . removeClass ( 'disabled' ) ;
$ ( nLast ) . removeClass ( 'disabled' ) ;
}
}
else if ( iNewStart == iEndPosition )
else if ( iNewStart == ( ( Math . ceil ( ( oSettings . fnRecordsDisplay ( ) - 1 ) / oSettings . _iDisplayLength ) - 1 ) * oSettings . _iDisplayLength ) )
{
{
$ ( nNext ) . addClass ( 'disabled' ) ;
$ ( nNext ) . addClass ( 'disabled' ) ;
$ ( nLast ) . addClass ( 'disabled' ) ;
$ ( nLast ) . addClass ( 'disabled' ) ;
$ ( nFirst ) . removeClass ( 'disabled' ) ;
$ ( nPrevious ) . removeClass ( 'disabled' ) ;
}
}
else
else
{
{
@ -165,6 +181,13 @@ $.fn.dataTableExt.oPagination.input = {
/* Take the brutal approach to cancelling text selection */
/* Take the brutal approach to cancelling text selection */
$ ( 'span' , nPaging ) . bind ( 'mousedown' , function ( ) { return false ; } ) ;
$ ( 'span' , nPaging ) . bind ( 'mousedown' , function ( ) { return false ; } ) ;
$ ( 'span' , nPaging ) . bind ( 'selectstart' , function ( ) { return false ; } ) ;
$ ( 'span' , nPaging ) . bind ( 'selectstart' , function ( ) { return false ; } ) ;
// If we can't page anyway, might as well not show it
var iPages = Math . ceil ( ( oSettings . fnRecordsDisplay ( ) ) / oSettings . _iDisplayLength ) ;
if ( iPages <= 1 )
{
$ ( nPaging ) . hide ( ) ;
}
} ,
} ,
@ -177,8 +200,14 @@ $.fn.dataTableExt.oPagination.input = {
var iPages = Math . ceil ( ( oSettings . fnRecordsDisplay ( ) ) / oSettings . _iDisplayLength ) ;
var iPages = Math . ceil ( ( oSettings . fnRecordsDisplay ( ) ) / oSettings . _iDisplayLength ) ;
var iCurrentPage = Math . ceil ( oSettings . _iDisplayStart / oSettings . _iDisplayLength ) + 1 ;
var iCurrentPage = Math . ceil ( oSettings . _iDisplayStart / oSettings . _iDisplayLength ) + 1 ;
/* Loop over each instance of the pager */
var an = oSettings . aanFeatures . p ;
var an = oSettings . aanFeatures . p ;
if ( iPages <= 1 ) // hide paging when we can't page
{
$ ( an ) . hide ( ) ;
}
else
{
/* Loop over each instance of the pager */
for ( var i = 0 , iLen = an . length ; i < iLen ; i ++ )
for ( var i = 0 , iLen = an . length ; i < iLen ; i ++ )
{
{
var spans = an [ i ] . getElementsByTagName ( 'span' ) ;
var spans = an [ i ] . getElementsByTagName ( 'span' ) ;
@ -187,4 +216,5 @@ $.fn.dataTableExt.oPagination.input = {
inputs [ 0 ] . value = iCurrentPage ;
inputs [ 0 ] . value = iCurrentPage ;
}
}
}
}
}
} ;
} ;