mirror of
https://github.com/DataTables/DataTables.git
synced 2024-12-01 13:24:10 +01:00
DRY for the four event handlers
This commit is contained in:
parent
437ac29048
commit
ba02adc6e9
38
media/js/jquery.dataTables.js
vendored
38
media/js/jquery.dataTables.js
vendored
@ -403,6 +403,13 @@
|
||||
*/
|
||||
"fnInit": function ( oSettings, nPaging, fnCallbackDraw )
|
||||
{
|
||||
function fnClickHandler ( e ) {
|
||||
if ( oSettings.oApi._fnPageChange( oSettings, e.data.action ) )
|
||||
{
|
||||
fnCallbackDraw( oSettings );
|
||||
}
|
||||
}
|
||||
|
||||
var nFirst = document.createElement( 'span' );
|
||||
var nPrevious = document.createElement( 'span' );
|
||||
var nList = document.createElement( 'span' );
|
||||
@ -426,33 +433,10 @@
|
||||
nPaging.appendChild( nNext );
|
||||
nPaging.appendChild( nLast );
|
||||
|
||||
$(nFirst).bind( 'click.DT', function () {
|
||||
if ( oSettings.oApi._fnPageChange( oSettings, "first" ) )
|
||||
{
|
||||
fnCallbackDraw( oSettings );
|
||||
}
|
||||
} );
|
||||
|
||||
$(nPrevious).bind( 'click.DT', function() {
|
||||
if ( oSettings.oApi._fnPageChange( oSettings, "previous" ) )
|
||||
{
|
||||
fnCallbackDraw( oSettings );
|
||||
}
|
||||
} );
|
||||
|
||||
$(nNext).bind( 'click.DT', function() {
|
||||
if ( oSettings.oApi._fnPageChange( oSettings, "next" ) )
|
||||
{
|
||||
fnCallbackDraw( oSettings );
|
||||
}
|
||||
} );
|
||||
|
||||
$(nLast).bind( 'click.DT', function() {
|
||||
if ( oSettings.oApi._fnPageChange( oSettings, "last" ) )
|
||||
{
|
||||
fnCallbackDraw( oSettings );
|
||||
}
|
||||
} );
|
||||
$(nFirst).bind( 'click.DT', { action: "first" }, fnClickHandler );
|
||||
$(nPrevious).bind( 'click.DT', { action: "previous" }, fnClickHandler );
|
||||
$(nNext).bind( 'click.DT', { action: "next" }, fnClickHandler );
|
||||
$(nLast).bind( 'click.DT', { action: "last" }, fnClickHandler );
|
||||
|
||||
/* Take the brutal approach to cancelling text selection */
|
||||
$('span', nPaging)
|
||||
|
Loading…
Reference in New Issue
Block a user