annotate DataTables-1.9.4/media/src/ext/ext.paging.js @ 1:440f4aa3db97 draft

Added option to dowload iReports
author saskia-hiltemann
date Wed, 30 Jul 2014 07:03:43 -0400
parents ac5f9272033b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2 * Variable: oPagination
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3 * Purpose:
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4 * Scope: jQuery.fn.dataTableExt
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6 $.extend( DataTable.ext.oPagination, {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8 * Variable: two_button
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9 * Purpose: Standard two button (forward/back) pagination
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10 * Scope: jQuery.fn.dataTableExt.oPagination
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12 "two_button": {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
13 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
14 * Function: oPagination.two_button.fnInit
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
15 * Purpose: Initialise dom elements required for pagination with forward/back buttons only
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
16 * Returns: -
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
17 * Inputs: object:oSettings - dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
18 * node:nPaging - the DIV which contains this pagination control
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
19 * function:fnCallbackDraw - draw function which must be called on update
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
20 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
21 "fnInit": function ( oSettings, nPaging, fnCallbackDraw )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
22 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
23 var oLang = oSettings.oLanguage.oPaginate;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
24 var oClasses = oSettings.oClasses;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
25 var fnClickHandler = function ( e ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
26 if ( oSettings.oApi._fnPageChange( oSettings, e.data.action ) )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
27 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
28 fnCallbackDraw( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
29 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
30 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
31
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
32 var sAppend = (!oSettings.bJUI) ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
33 '<a class="'+oSettings.oClasses.sPagePrevDisabled+'" tabindex="'+oSettings.iTabIndex+'" role="button">'+oLang.sPrevious+'</a>'+
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
34 '<a class="'+oSettings.oClasses.sPageNextDisabled+'" tabindex="'+oSettings.iTabIndex+'" role="button">'+oLang.sNext+'</a>'
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
35 :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
36 '<a class="'+oSettings.oClasses.sPagePrevDisabled+'" tabindex="'+oSettings.iTabIndex+'" role="button"><span class="'+oSettings.oClasses.sPageJUIPrev+'"></span></a>'+
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
37 '<a class="'+oSettings.oClasses.sPageNextDisabled+'" tabindex="'+oSettings.iTabIndex+'" role="button"><span class="'+oSettings.oClasses.sPageJUINext+'"></span></a>';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
38 $(nPaging).append( sAppend );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
39
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
40 var els = $('a', nPaging);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
41 var nPrevious = els[0],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
42 nNext = els[1];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
43
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
44 oSettings.oApi._fnBindAction( nPrevious, {action: "previous"}, fnClickHandler );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
45 oSettings.oApi._fnBindAction( nNext, {action: "next"}, fnClickHandler );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
46
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
47 /* ID the first elements only */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
48 if ( !oSettings.aanFeatures.p )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
49 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
50 nPaging.id = oSettings.sTableId+'_paginate';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
51 nPrevious.id = oSettings.sTableId+'_previous';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
52 nNext.id = oSettings.sTableId+'_next';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
53
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
54 nPrevious.setAttribute('aria-controls', oSettings.sTableId);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
55 nNext.setAttribute('aria-controls', oSettings.sTableId);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
56 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
57 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
58
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
59 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
60 * Function: oPagination.two_button.fnUpdate
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
61 * Purpose: Update the two button pagination at the end of the draw
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
62 * Returns: -
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
63 * Inputs: object:oSettings - dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
64 * function:fnCallbackDraw - draw function to call on page change
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
65 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
66 "fnUpdate": function ( oSettings, fnCallbackDraw )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
67 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
68 if ( !oSettings.aanFeatures.p )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
69 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
70 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
71 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
72
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
73 var oClasses = oSettings.oClasses;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
74 var an = oSettings.aanFeatures.p;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
75 var nNode;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
76
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
77 /* Loop over each instance of the pager */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
78 for ( var i=0, iLen=an.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
79 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
80 nNode = an[i].firstChild;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
81 if ( nNode )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
82 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
83 /* Previous page */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
84 nNode.className = ( oSettings._iDisplayStart === 0 ) ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
85 oClasses.sPagePrevDisabled : oClasses.sPagePrevEnabled;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
86
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
87 /* Next page */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
88 nNode = nNode.nextSibling;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
89 nNode.className = ( oSettings.fnDisplayEnd() == oSettings.fnRecordsDisplay() ) ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
90 oClasses.sPageNextDisabled : oClasses.sPageNextEnabled;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
91 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
92 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
93 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
94 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
95
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
96
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
97 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
98 * Variable: iFullNumbersShowPages
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
99 * Purpose: Change the number of pages which can be seen
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
100 * Scope: jQuery.fn.dataTableExt.oPagination
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
101 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
102 "iFullNumbersShowPages": 5,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
103
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
104 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
105 * Variable: full_numbers
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
106 * Purpose: Full numbers pagination
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
107 * Scope: jQuery.fn.dataTableExt.oPagination
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
108 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
109 "full_numbers": {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
110 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
111 * Function: oPagination.full_numbers.fnInit
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
112 * Purpose: Initialise dom elements required for pagination with a list of the pages
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
113 * Returns: -
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
114 * Inputs: object:oSettings - dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
115 * node:nPaging - the DIV which contains this pagination control
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
116 * function:fnCallbackDraw - draw function which must be called on update
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
117 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
118 "fnInit": function ( oSettings, nPaging, fnCallbackDraw )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
119 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
120 var oLang = oSettings.oLanguage.oPaginate;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
121 var oClasses = oSettings.oClasses;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
122 var fnClickHandler = function ( e ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
123 if ( oSettings.oApi._fnPageChange( oSettings, e.data.action ) )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
124 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
125 fnCallbackDraw( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
126 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
127 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
128
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
129 $(nPaging).append(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
130 '<a tabindex="'+oSettings.iTabIndex+'" class="'+oClasses.sPageButton+" "+oClasses.sPageFirst+'">'+oLang.sFirst+'</a>'+
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
131 '<a tabindex="'+oSettings.iTabIndex+'" class="'+oClasses.sPageButton+" "+oClasses.sPagePrevious+'">'+oLang.sPrevious+'</a>'+
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
132 '<span></span>'+
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
133 '<a tabindex="'+oSettings.iTabIndex+'" class="'+oClasses.sPageButton+" "+oClasses.sPageNext+'">'+oLang.sNext+'</a>'+
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
134 '<a tabindex="'+oSettings.iTabIndex+'" class="'+oClasses.sPageButton+" "+oClasses.sPageLast+'">'+oLang.sLast+'</a>'
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
135 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
136 var els = $('a', nPaging);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
137 var nFirst = els[0],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
138 nPrev = els[1],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
139 nNext = els[2],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
140 nLast = els[3];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
141
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
142 oSettings.oApi._fnBindAction( nFirst, {action: "first"}, fnClickHandler );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
143 oSettings.oApi._fnBindAction( nPrev, {action: "previous"}, fnClickHandler );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
144 oSettings.oApi._fnBindAction( nNext, {action: "next"}, fnClickHandler );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
145 oSettings.oApi._fnBindAction( nLast, {action: "last"}, fnClickHandler );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
146
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
147 /* ID the first elements only */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
148 if ( !oSettings.aanFeatures.p )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
149 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
150 nPaging.id = oSettings.sTableId+'_paginate';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
151 nFirst.id =oSettings.sTableId+'_first';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
152 nPrev.id =oSettings.sTableId+'_previous';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
153 nNext.id =oSettings.sTableId+'_next';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
154 nLast.id =oSettings.sTableId+'_last';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
155 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
156 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
157
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
158 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
159 * Function: oPagination.full_numbers.fnUpdate
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
160 * Purpose: Update the list of page buttons shows
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
161 * Returns: -
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
162 * Inputs: object:oSettings - dataTables settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
163 * function:fnCallbackDraw - draw function to call on page change
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
164 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
165 "fnUpdate": function ( oSettings, fnCallbackDraw )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
166 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
167 if ( !oSettings.aanFeatures.p )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
168 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
169 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
170 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
171
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
172 var iPageCount = DataTable.ext.oPagination.iFullNumbersShowPages;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
173 var iPageCountHalf = Math.floor(iPageCount / 2);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
174 var iPages = Math.ceil((oSettings.fnRecordsDisplay()) / oSettings._iDisplayLength);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
175 var iCurrentPage = Math.ceil(oSettings._iDisplayStart / oSettings._iDisplayLength) + 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
176 var sList = "";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
177 var iStartButton, iEndButton, i, iLen;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
178 var oClasses = oSettings.oClasses;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
179 var anButtons, anStatic, nPaginateList, nNode;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
180 var an = oSettings.aanFeatures.p;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
181 var fnBind = function (j) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
182 oSettings.oApi._fnBindAction( this, {"page": j+iStartButton-1}, function(e) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
183 /* Use the information in the element to jump to the required page */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
184 oSettings.oApi._fnPageChange( oSettings, e.data.page );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
185 fnCallbackDraw( oSettings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
186 e.preventDefault();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
187 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
188 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
189
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
190 /* Pages calculation */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
191 if ( oSettings._iDisplayLength === -1 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
192 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
193 iStartButton = 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
194 iEndButton = 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
195 iCurrentPage = 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
196 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
197 else if (iPages < iPageCount)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
198 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
199 iStartButton = 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
200 iEndButton = iPages;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
201 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
202 else if (iCurrentPage <= iPageCountHalf)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
203 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
204 iStartButton = 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
205 iEndButton = iPageCount;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
206 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
207 else if (iCurrentPage >= (iPages - iPageCountHalf))
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
208 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
209 iStartButton = iPages - iPageCount + 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
210 iEndButton = iPages;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
211 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
212 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
213 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
214 iStartButton = iCurrentPage - Math.ceil(iPageCount / 2) + 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
215 iEndButton = iStartButton + iPageCount - 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
216 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
217
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
218
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
219 /* Build the dynamic list */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
220 for ( i=iStartButton ; i<=iEndButton ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
221 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
222 sList += (iCurrentPage !== i) ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
223 '<a tabindex="'+oSettings.iTabIndex+'" class="'+oClasses.sPageButton+'">'+oSettings.fnFormatNumber(i)+'</a>' :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
224 '<a tabindex="'+oSettings.iTabIndex+'" class="'+oClasses.sPageButtonActive+'">'+oSettings.fnFormatNumber(i)+'</a>';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
225 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
226
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
227 /* Loop over each instance of the pager */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
228 for ( i=0, iLen=an.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
229 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
230 nNode = an[i];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
231 if ( !nNode.hasChildNodes() )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
232 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
233 continue;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
234 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
235
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
236 /* Build up the dynamic list first - html and listeners */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
237 $('span:eq(0)', nNode)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
238 .html( sList )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
239 .children('a').each( fnBind );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
240
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
241 /* Update the permanent button's classes */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
242 anButtons = nNode.getElementsByTagName('a');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
243 anStatic = [
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
244 anButtons[0], anButtons[1],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
245 anButtons[anButtons.length-2], anButtons[anButtons.length-1]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
246 ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
247
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
248 $(anStatic).removeClass( oClasses.sPageButton+" "+oClasses.sPageButtonActive+" "+oClasses.sPageButtonStaticDisabled );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
249 $([anStatic[0], anStatic[1]]).addClass(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
250 (iCurrentPage==1) ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
251 oClasses.sPageButtonStaticDisabled :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
252 oClasses.sPageButton
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
253 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
254 $([anStatic[2], anStatic[3]]).addClass(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
255 (iPages===0 || iCurrentPage===iPages || oSettings._iDisplayLength===-1) ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
256 oClasses.sPageButtonStaticDisabled :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
257 oClasses.sPageButton
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
258 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
259 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
260 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
261 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
262 } );