1/* Set the defaults for DataTables initialisation */ 2$.extend( true, $.fn.dataTable.defaults, { 3 "sDom": "<'row'<'col-sm-12'<'pull-right'f><'pull-left'l>r<'clearfix'>>>t<'row'<'col-sm-12'<'pull-left'i><'pull-right'p><'clearfix'>>>", 4 "sPaginationType": "bootstrap", 5 "oLanguage": { 6 "sLengthMenu": "Show _MENU_ Rows", 7 "sSearch": "" 8 } 9} ); 10/* Default class modification */ 11$.extend( $.fn.dataTableExt.oStdClasses, { 12 "sWrapper": "dataTables_wrapper form-inline" 13} ); 14 15 16/* API method to get paging information */ 17$.fn.dataTableExt.oApi.fnPagingInfo = function ( oSettings ) 18{ 19 return { 20 "iStart": oSettings._iDisplayStart, 21 "iEnd": oSettings.fnDisplayEnd(), 22 "iLength": oSettings._iDisplayLength, 23 "iTotal": oSettings.fnRecordsTotal(), 24 "iFilteredTotal": oSettings.fnRecordsDisplay(), 25 "iPage": oSettings._iDisplayLength === -1 ? 26 0 : Math.ceil( oSettings._iDisplayStart / oSettings._iDisplayLength ), 27 "iTotalPages": oSettings._iDisplayLength === -1 ? 28 0 : Math.ceil( oSettings.fnRecordsDisplay() / oSettings._iDisplayLength ) 29 }; 30}; 31 32 33/* Bootstrap style pagination control */ 34$.extend( $.fn.dataTableExt.oPagination, { 35 "bootstrap": { 36 "fnInit": function( oSettings, nPaging, fnDraw ) { 37 var oLang = oSettings.oLanguage.oPaginate; 38 var fnClickHandler = function ( e ) { 39 e.preventDefault(); 40 if ( oSettings.oApi._fnPageChange(oSettings, e.data.action) ) { 41 fnDraw( oSettings ); 42 } 43 }; 44 45 $(nPaging).append( 46 '<ul class="pagination pagination-sm">'+ 47 '<li class="prev disabled"><a href="#"><i class="icon-double-angle-left"></i> '+oLang.sPrevious+'</a></li>'+ 48 '<li class="next disabled"><a href="#">'+oLang.sNext+' <i class="icon-double-angle-right"></i></a></li>'+ 49 '</ul>' 50 ); 51 var els = $('a', nPaging); 52 $(els[0]).bind( 'click.DT', { action: "previous" }, fnClickHandler ); 53 $(els[1]).bind( 'click.DT', { action: "next" }, fnClickHandler ); 54 }, 55 56 "fnUpdate": function ( oSettings, fnDraw ) { 57 var iListLength = 5; 58 var oPaging = oSettings.oInstance.fnPagingInfo(); 59 var an = oSettings.aanFeatures.p; 60 var i, ien, j, sClass, iStart, iEnd, iHalf=Math.floor(iListLength/2); 61 62 if ( oPaging.iTotalPages < iListLength) { 63 iStart = 1; 64 iEnd = oPaging.iTotalPages; 65 } 66 else if ( oPaging.iPage <= iHalf ) { 67 iStart = 1; 68 iEnd = iListLength; 69 } else if ( oPaging.iPage >= (oPaging.iTotalPages-iHalf) ) { 70 iStart = oPaging.iTotalPages - iListLength + 1; 71 iEnd = oPaging.iTotalPages; 72 } else { 73 iStart = oPaging.iPage - iHalf + 1; 74 iEnd = iStart + iListLength - 1; 75 } 76 77 for ( i=0, ien=an.length ; i<ien ; i++ ) { 78 // Remove the middle elements 79 $('li:gt(0)', an[i]).filter(':not(:last)').remove(); 80 81 // Add the new list items and their event handlers 82 for ( j=iStart ; j<=iEnd ; j++ ) { 83 sClass = (j==oPaging.iPage+1) ? 'class="active"' : ''; 84 $('<li '+sClass+'><a href="#">'+j+'</a></li>') 85 .insertBefore( $('li:last', an[i])[0] ) 86 .bind('click', function (e) { 87 e.preventDefault(); 88 oSettings._iDisplayStart = (parseInt($('a', this).text(),10)-1) * oPaging.iLength; 89 fnDraw( oSettings ); 90 } ); 91 } 92 93 // Add / remove disabled classes from the static elements 94 if ( oPaging.iPage === 0 ) { 95 $('li:first', an[i]).addClass('disabled'); 96 } else { 97 $('li:first', an[i]).removeClass('disabled'); 98 } 99 100 if ( oPaging.iPage === oPaging.iTotalPages-1 || oPaging.iTotalPages === 0 ) { 101 $('li:last', an[i]).addClass('disabled'); 102 } else { 103 $('li:last', an[i]).removeClass('disabled'); 104 } 105 } 106 } 107 } 108} ); 109 110 111/* 112 * TableTools Bootstrap compatibility 113 * Required TableTools 2.1+ 114 */ 115if ( $.fn.DataTable.TableTools ) { 116 // Set the classes that TableTools uses to something suitable for Bootstrap 117 $.extend( true, $.fn.DataTable.TableTools.classes, { 118 "container": "DTTT btn-group", 119 "buttons": { 120 "normal": "btn", 121 "disabled": "disabled" 122 }, 123 "collection": { 124 "container": "DTTT_dropdown dropdown-menu", 125 "buttons": { 126 "normal": "", 127 "disabled": "disabled" 128 } 129 }, 130 "print": { 131 "info": "DTTT_print_info modal" 132 }, 133 "select": { 134 "row": "active" 135 } 136 } ); 137 138 // Have the collection use a bootstrap compatible dropdown 139 $.extend( true, $.fn.DataTable.TableTools.DEFAULTS.oTags, { 140 "collection": { 141 "container": "ul", 142 "button": "li", 143 "liner": "a" 144 } 145 } ); 146} 147
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.