214 } |
214 } |
215 } |
215 } |
216 } |
216 } |
217 } |
217 } |
218 } ); |
218 } ); |
|
219 |
|
220 |
|
221 /** |
|
222 * Bootstrap style pagination control with only previous/next buttons |
|
223 */ |
|
224 $.extend($.fn.dataTableExt.oPagination, { |
|
225 "bootstrap_prevnext": { |
|
226 "fnInit": function(oSettings, nPaging, fnDraw) { |
|
227 var oLang = oSettings.oLanguage.oPaginate; |
|
228 var fnClickHandler = function (e) { |
|
229 e.preventDefault(); |
|
230 if (oSettings.oApi._fnPageChange(oSettings, e.data.action)) |
|
231 fnDraw(oSettings); |
|
232 }; |
|
233 |
|
234 $(nPaging).append( |
|
235 '<ul class="pagination">' + |
|
236 '<li class="first disabled"><a href="#"><i class="fa fa-fw fa-fast-backward"></i></a></li>' + |
|
237 '<li class="prev disabled"><a href="#"><i class="fa fa-fw fa-step-backward"></i></a></li>' + |
|
238 '<li class="next disabled"><a href="#"><i class="fa fa-fw fa-step-forward"></i></a></li>' + |
|
239 '<li class="last disabled"><a href="#"><i class="fa fa-fw fa-fast-forward"></i></a></li>' + |
|
240 '</ul>' |
|
241 ); |
|
242 var els = $('a', nPaging); |
|
243 $(els[0]).on('click.DT', { action: "first" }, fnClickHandler); |
|
244 $(els[1]).on('click.DT', { action: "previous" }, fnClickHandler); |
|
245 $(els[2]).on('click.DT', { action: "next" }, fnClickHandler); |
|
246 $(els[3]).on('click.DT', { action: "last" }, fnClickHandler); |
|
247 }, |
|
248 |
|
249 "fnUpdate": function (oSettings, fnDraw) { |
|
250 var iListLength = 5; |
|
251 var oPaging = oSettings.oInstance.fnPagingInfo(); |
|
252 var an = oSettings.aanFeatures.p; |
|
253 var i, |
|
254 j, |
|
255 sClass, |
|
256 iStart, |
|
257 iEnd, |
|
258 iLen, |
|
259 iHalf=Math.floor(iListLength/2); |
|
260 |
|
261 if (oPaging.iTotalPages < iListLength) { |
|
262 iStart = 1; |
|
263 iEnd = oPaging.iTotalPages; |
|
264 } else if (oPaging.iPage <= iHalf) { |
|
265 iStart = 1; |
|
266 iEnd = iListLength; |
|
267 } else if (oPaging.iPage >= (oPaging.iTotalPages-iHalf)) { |
|
268 iStart = oPaging.iTotalPages - iListLength + 1; |
|
269 iEnd = oPaging.iTotalPages; |
|
270 } else { |
|
271 iStart = oPaging.iPage - iHalf + 1; |
|
272 iEnd = iStart + iListLength - 1; |
|
273 } |
|
274 |
|
275 for (i=0, iLen=an.length ; i<iLen ; i++) { |
|
276 // Add / remove disabled classes from the static elements |
|
277 if (oPaging.iPage === 0) { |
|
278 $('li.first', an[i]).addClass('disabled'); |
|
279 $('li.prev', an[i]).addClass('disabled'); |
|
280 } else { |
|
281 $('li.prev', an[i]).removeClass('disabled'); |
|
282 $('li.first', an[i]).removeClass('disabled'); |
|
283 } |
|
284 |
|
285 if (oPaging.iPage === oPaging.iTotalPages-1 || oPaging.iTotalPages === 0) { |
|
286 $('li.last', an[i]).addClass('disabled'); |
|
287 $('li.next', an[i]).addClass('disabled'); |
|
288 } else { |
|
289 $('li.next', an[i]).removeClass('disabled'); |
|
290 $('li.last', an[i]).removeClass('disabled'); |
|
291 } |
|
292 } |
|
293 } |
|
294 } |
|
295 }); |
219 |
296 |
220 |
297 |
221 /* |
298 /* |
222 * TableTools Bootstrap compatibility |
299 * TableTools Bootstrap compatibility |
223 * Required TableTools 2.1+ |
300 * Required TableTools 2.1+ |