1/* API method to get paging information */ 2$.fn.dataTableExt.oApi.fnPagingInfo = function ( oSettings ) 3{ 4 return { 5 "iStart": oSettings._iDisplayStart, 6 "iEnd": oSettings.fnDisplayEnd(), 7 "iLength": oSettings._iDisplayLength, 8 "iTotal": oSettings.fnRecordsTotal(), 9 "iFilteredTotal": oSettings.fnRecordsDisplay(), 10 "iPage": oSettings._iDisplayLength === -1 ? 11 0 : Math.ceil( oSettings._iDisplayStart / oSettings._iDisplayLength ), 12 "iTotalPages": oSettings._iDisplayLength === -1 ? 13 0 : Math.ceil( oSettings.fnRecordsDisplay() / oSettings._iDisplayLength ) 14 }; 15}; 16 17 18/* Bootstrap style pagination control */ 19$.extend( $.fn.dataTableExt.oPagination, { 20 "bootstrap": { 21 "fnInit": function( oSettings, nPaging, fnDraw ) { 22 var oLang = oSettings.oLanguage.oPaginate; 23 var fnClickHandler = function ( e ) { 24 e.preventDefault(); 25 if ( oSettings.oApi._fnPageChange(oSettings, e.data.action) ) { 26 fnDraw( oSettings ); 27 } 28 }; 29 30 $(nPaging).append( 31 '<div class"pagination"> <ul class="pagination">'+ 32 '<li class="prev disabled"><a href="#">← '+$_lang.previous+'</a></li>'+ 33 '<li class="next disabled"><a href="#">'+$_lang.next+' → </a></li>'+ 34 '</ul></div>' 35 ); 36 var els = $('a', nPaging); 37 $(els[0]).bind( 'click.DT', { action: "previous" }, fnClickHandler ); 38 $(els[1]).bind( 'click.DT', { action: "next" }, fnClickHandler ); 39 }, 40 41 "fnUpdate": function ( oSettings, fnDraw ) { 42 var iListLength = 5; 43 var oPaging = oSettings.oInstance.fnPagingInfo(); 44 var an = oSettings.aanFeatures.p; 45 var i, ien, j, sClass, iStart, iEnd, iHalf=Math.floor(iListLength/2); 46 47 if ( oPaging.iTotalPages < iListLength) { 48 iStart = 1; 49 iEnd = oPaging.iTotalPages; 50 } 51 else if ( oPaging.iPage <= iHalf ) { 52 iStart = 1; 53 iEnd = iListLength; 54 } else if ( oPaging.iPage >= (oPaging.iTotalPages-iHalf) ) { 55 iStart = oPaging.iTotalPages - iListLength + 1; 56 iEnd = oPaging.iTotalPages; 57 } else { 58 iStart = oPaging.iPage - iHalf + 1; 59 iEnd = iStart + iListLength - 1; 60 } 61 62 for ( i=0, ien=an.length ; i<ien ; i++ ) { 63 // Remove the middle elements 64 $('li:gt(0)', an[i]).filter(':not(:last)').remove(); 65 66 // Add the new list items and their event handlers 67 for ( j=iStart ; j<=iEnd ; j++ ) { 68 sClass = (j==oPaging.iPage+1) ? 'class="active"' : ''; 69 $('<li '+sClass+'><a href="#">'+j+'</a></li>') 70 .insertBefore( $('li:last', an[i])[0] ) 71 .bind('click', function (e) { 72 e.preventDefault(); 73 oSettings._iDisplayStart = (parseInt($('a', this).text(),10)-1) * oPaging.iLength; 74 fnDraw( oSettings ); 75 } ); 76 } 77 78 // Add / remove disabled classes from the static elements 79 if ( oPaging.iPage === 0 ) { 80 $('li:first', an[i]).addClass('disabled'); 81 } else { 82 $('li:first', an[i]).removeClass('disabled'); 83 } 84 85 if ( oPaging.iPage === oPaging.iTotalPages-1 || oPaging.iTotalPages === 0 ) { 86 $('li:last', an[i]).addClass('disabled'); 87 } else { 88 $('li:last', an[i]).removeClass('disabled'); 89 } 90 } 91 } 92 } 93} );
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.