| 2 |
lars |
1 |
/**
|
|
|
2 |
* The built-in pagination functions provide either two buttons (forward / back)
|
|
|
3 |
* or lots of buttons (forward, back, first, last and individual pages). This
|
|
|
4 |
* plug-in meets the two in the middle providing navigation controls for
|
|
|
5 |
* forward, back, first and last.
|
|
|
6 |
*
|
|
|
7 |
* DataTables has this ability built in using the `dt-string full` option of
|
|
|
8 |
* the `dt-init pagingType` initialisation option. As such, this plug-in is
|
|
|
9 |
* marked as deprecated.
|
|
|
10 |
*
|
|
|
11 |
* @name Four button navigation
|
|
|
12 |
* @summary Display forward, back, first and last buttons.
|
|
|
13 |
* @deprecated
|
|
|
14 |
* @author [Allan Jardine](http://sprymedia.co.uk)
|
|
|
15 |
*
|
|
|
16 |
* @example
|
|
|
17 |
* $(document).ready(function() {
|
|
|
18 |
* $('#example').dataTable( {
|
|
|
19 |
* "sPaginationType": "four_button"
|
|
|
20 |
* } );
|
|
|
21 |
* } );
|
|
|
22 |
*/
|
|
|
23 |
|
|
|
24 |
$.fn.dataTableExt.oPagination.four_button = {
|
|
|
25 |
"fnInit": function ( oSettings, nPaging, fnCallbackDraw )
|
|
|
26 |
{
|
|
|
27 |
var nFirst = document.createElement( 'span' );
|
|
|
28 |
var nPrevious = document.createElement( 'span' );
|
|
|
29 |
var nNext = document.createElement( 'span' );
|
|
|
30 |
var nLast = document.createElement( 'span' );
|
|
|
31 |
|
|
|
32 |
nFirst.appendChild( document.createTextNode( oSettings.oLanguage.oPaginate.sFirst ) );
|
|
|
33 |
nPrevious.appendChild( document.createTextNode( oSettings.oLanguage.oPaginate.sPrevious ) );
|
|
|
34 |
nNext.appendChild( document.createTextNode( oSettings.oLanguage.oPaginate.sNext ) );
|
|
|
35 |
nLast.appendChild( document.createTextNode( oSettings.oLanguage.oPaginate.sLast ) );
|
|
|
36 |
|
|
|
37 |
nFirst.className = "paginate_button first";
|
|
|
38 |
nPrevious.className = "paginate_button previous";
|
|
|
39 |
nNext.className="paginate_button next";
|
|
|
40 |
nLast.className = "paginate_button last";
|
|
|
41 |
|
|
|
42 |
nPaging.appendChild( nFirst );
|
|
|
43 |
nPaging.appendChild( nPrevious );
|
|
|
44 |
nPaging.appendChild( nNext );
|
|
|
45 |
nPaging.appendChild( nLast );
|
|
|
46 |
|
|
|
47 |
$(nFirst).click( function () {
|
|
|
48 |
oSettings.oApi._fnPageChange( oSettings, "first" );
|
|
|
49 |
fnCallbackDraw( oSettings );
|
|
|
50 |
} );
|
|
|
51 |
|
|
|
52 |
$(nPrevious).click( function() {
|
|
|
53 |
oSettings.oApi._fnPageChange( oSettings, "previous" );
|
|
|
54 |
fnCallbackDraw( oSettings );
|
|
|
55 |
} );
|
|
|
56 |
|
|
|
57 |
$(nNext).click( function() {
|
|
|
58 |
oSettings.oApi._fnPageChange( oSettings, "next" );
|
|
|
59 |
fnCallbackDraw( oSettings );
|
|
|
60 |
} );
|
|
|
61 |
|
|
|
62 |
$(nLast).click( function() {
|
|
|
63 |
oSettings.oApi._fnPageChange( oSettings, "last" );
|
|
|
64 |
fnCallbackDraw( oSettings );
|
|
|
65 |
} );
|
|
|
66 |
|
|
|
67 |
/* Disallow text selection */
|
|
|
68 |
$(nFirst).bind( 'selectstart', function () { return false; } );
|
|
|
69 |
$(nPrevious).bind( 'selectstart', function () { return false; } );
|
|
|
70 |
$(nNext).bind( 'selectstart', function () { return false; } );
|
|
|
71 |
$(nLast).bind( 'selectstart', function () { return false; } );
|
|
|
72 |
},
|
|
|
73 |
|
|
|
74 |
|
|
|
75 |
"fnUpdate": function ( oSettings, fnCallbackDraw )
|
|
|
76 |
{
|
|
|
77 |
if ( !oSettings.aanFeatures.p )
|
|
|
78 |
{
|
|
|
79 |
return;
|
|
|
80 |
}
|
|
|
81 |
|
|
|
82 |
/* Loop over each instance of the pager */
|
|
|
83 |
var an = oSettings.aanFeatures.p;
|
|
|
84 |
for ( var i=0, iLen=an.length ; i<iLen ; i++ )
|
|
|
85 |
{
|
|
|
86 |
var buttons = an[i].getElementsByTagName('span');
|
|
|
87 |
if ( oSettings._iDisplayStart === 0 )
|
|
|
88 |
{
|
|
|
89 |
buttons[0].className = "paginate_disabled_previous";
|
|
|
90 |
buttons[1].className = "paginate_disabled_previous";
|
|
|
91 |
}
|
|
|
92 |
else
|
|
|
93 |
{
|
|
|
94 |
buttons[0].className = "paginate_enabled_previous";
|
|
|
95 |
buttons[1].className = "paginate_enabled_previous";
|
|
|
96 |
}
|
|
|
97 |
|
|
|
98 |
if ( oSettings.fnDisplayEnd() == oSettings.fnRecordsDisplay() )
|
|
|
99 |
{
|
|
|
100 |
buttons[2].className = "paginate_disabled_next";
|
|
|
101 |
buttons[3].className = "paginate_disabled_next";
|
|
|
102 |
}
|
|
|
103 |
else
|
|
|
104 |
{
|
|
|
105 |
buttons[2].className = "paginate_enabled_next";
|
|
|
106 |
buttons[3].className = "paginate_enabled_next";
|
|
|
107 |
}
|
|
|
108 |
}
|
|
|
109 |
}
|
|
|
110 |
};
|