1/* Set the defaults for DataTables initialisation */ 2$.extend(true, $.fn.dataTable.defaults, { 3 "dom": "<'row'<'col-md-6 col-sm-6'l><'col-md-6 col-sm-6'f>r><'table-scrollable't><'row'<'col-md-5 col-sm-5'i><'col-md-7 col-sm-7'p>>", // default layout with horizobtal scrollable datatable 4 //"dom": "<'row'<'col-md-6 col-sm-12'l><'col-md-6 col-sm-12'f>r>t<'row'<'col-md-5 col-sm-12'i><'col-md-7 col-sm-12'p>>", // datatable layout without horizobtal scroll(used when bootstrap dropdowns used in the datatable cells) 5 "language": { 6 "lengthMenu": " _MENU_ records ", 7 "paginate": { 8 "previous": 'Prev', 9 "next": 'Next', 10 "page": "Page", 11 "pageOf": "of" 12 } 13 }, 14 "pagingType": "bootstrap_number" 15}); 16 17/* Default class modification */ 18$.extend($.fn.dataTableExt.oStdClasses, { 19 "sWrapper": "dataTables_wrapper", 20 "sFilterInput": "form-control input-sm input-small input-inline", 21 "sLengthSelect": "form-control input-sm input-xsmall input-inline" 22}); 23 24// In 1.10 we use the pagination renderers to draw the Bootstrap paging, 25// rather than custom plug-in 26$.fn.dataTable.defaults.renderer = 'bootstrap'; 27$.fn.dataTable.ext.renderer.pageButton.bootstrap = function (settings, host, idx, buttons, page, pages) { 28 var api = new $.fn.dataTable.Api(settings); 29 var classes = settings.oClasses; 30 var lang = settings.oLanguage.oPaginate; 31 var btnDisplay, btnClass; 32 33 var attach = function (container, buttons) { 34 var i, ien, node, button; 35 var clickHandler = function (e) { 36 e.preventDefault(); 37 if (e.data.action !== 'ellipsis') { 38 api.page(e.data.action).draw(false); 39 } 40 }; 41 42 for (i = 0, ien = buttons.length; i < ien; i++) { 43 button = buttons[i]; 44 45 if ($.isArray(button)) { 46 attach(container, button); 47 } else { 48 btnDisplay = ''; 49 btnClass = ''; 50 51 switch (button) { 52 case 'ellipsis': 53 btnDisplay = '…'; 54 btnClass = 'disabled'; 55 break; 56 57 case 'first': 58 btnDisplay = lang.sFirst; 59 btnClass = button + (page > 0 ? 60 '' : ' disabled'); 61 break; 62 63 case 'previous': 64 btnDisplay = lang.sPrevious; 65 btnClass = button + (page > 0 ? 66 '' : ' disabled'); 67 break; 68 69 case 'next': 70 btnDisplay = lang.sNext; 71 btnClass = button + (page < pages - 1 ? 72 '' : ' disabled'); 73 break; 74 75 case 'last': 76 btnDisplay = lang.sLast; 77 btnClass = button + (page < pages - 1 ? 78 '' : ' disabled'); 79 break; 80 81 default: 82 btnDisplay = button + 1; 83 btnClass = page === button ? 84 'active' : ''; 85 break; 86 } 87 88 if (btnDisplay) { 89 node = $('<li>', { 90 'class': classes.sPageButton + ' ' + btnClass, 91 'aria-controls': settings.sTableId, 92 'tabindex': settings.iTabIndex, 93 'id': idx === 0 && typeof button === 'string' ? 94 settings.sTableId + '_' + button : null 95 }) 96 .append($('<a>', { 97 'href': '#' 98 }) 99 .html(btnDisplay) 100 ) 101 .appendTo(container); 102 103 settings.oApi._fnBindAction( 104 node, { 105 action: button 106 }, clickHandler 107 ); 108 } 109 } 110 } 111 }; 112 113 attach( 114 $(host).empty().html('<ul class="pagination"/>').children('ul'), 115 buttons 116 ); 117} 118 119/*** 120Custom Pagination 121***/ 122 123/* API method to get paging information */ 124$.fn.dataTableExt.oApi.fnPagingInfo = function (oSettings) { 125 return { 126 "iStart": oSettings._iDisplayStart, 127 "iEnd": oSettings.fnDisplayEnd(), 128 "iLength": oSettings._iDisplayLength, 129 "iTotal": oSettings.fnRecordsTotal(), 130 "iFilteredTotal": oSettings.fnRecordsDisplay(), 131 "iPage": oSettings._iDisplayLength === -1 ? 132 0 : Math.ceil(oSettings._iDisplayStart / oSettings._iDisplayLength), 133 "iTotalPages": oSettings._iDisplayLength === -1 ? 134 0 : Math.ceil(oSettings.fnRecordsDisplay() / oSettings._iDisplayLength) 135 }; 136};
137 138/* Bootstrap style full number pagination control */ 139$.extend($.fn.dataTableExt.oPagination, { 140 "bootstrap_full_number": { 141 "fnInit": function (oSettings, nPaging, fnDraw) { 142 var oLang = oSettings.oLanguage.oPaginate; 143 var fnClickHandler = function (e) { 144 e.preventDefault(); 145 if (oSettings.oApi._fnPageChange(oSettings, e.data.action)) { 146 fnDraw(oSettings); 147 } 148 }; 149 150 $(nPaging).append( 151 '<ul class="pagination">' + 152 '<li class="prev disabled"><a href="#" title="' + oLang.sFirst + '"><i class="fa fa-angle-double-left"></i></a></li>' + 153 '<li class="prev disabled"><a href="#" title="' + oLang.sPrevious + '"><i class="fa fa-angle-left"></i></a></li>' + 154 '<li class="next disabled"><a href="#" title="' + oLang.sNext + '"><i class="fa fa-angle-right"></i></a></li>' + 155 '<li class="next disabled"><a href="#" title="' + oLang.sLast + '"><i class="fa fa-angle-double-right"></i></a></li>' + 156 '</ul>' 157 ); 158 var els = $('a', nPaging); 159 $(els[0]).bind('click.DT', { 160 action: "first" 161 }, fnClickHandler); 162 $(els[1]).bind('click.DT', { 163 action: "previous" 164 }, fnClickHandler); 165 $(els[2]).bind('click.DT', { 166 action: "next" 167 }, fnClickHandler); 168 $(els[3]).bind('click.DT', { 169 action: "last" 170 }, fnClickHandler); 171 }, 172 173 "fnUpdate": function (oSettings, fnDraw) { 174 var iListLength = 5; 175 var oPaging = oSettings.oInstance.fnPagingInfo(); 176 var an = oSettings.aanFeatures.p; 177 var i, j, sClass, iStart, iEnd, iHalf = Math.floor(iListLength / 2); 178 179 if (oPaging.iTotalPages < iListLength) { 180 iStart = 1; 181 iEnd = oPaging.iTotalPages; 182 } else if (oPaging.iPage <= iHalf) { 183 iStart = 1; 184 iEnd = iListLength; 185 } else if (oPaging.iPage >= (oPaging.iTotalPages - iHalf)) { 186 iStart = oPaging.iTotalPages - iListLength + 1; 187 iEnd = oPaging.iTotalPages; 188 } else { 189 iStart = oPaging.iPage - iHalf + 1; 190 iEnd = iStart + iListLength - 1; 191 } 192 193 194 195 for (i = 0, iLen = an.length; i < iLen; i++) { 196 if (oPaging.iTotalPages <= 0) { 197 $('.pagination', an[i]).css('visibility', 'hidden'); 198 } else { 199 $('.pagination', an[i]).css('visibility', 'visible'); 200 } 201 202 // Remove the middle elements 203 $('li:gt(1)', an[i]).filter(':not(.next)').remove(); 204 205 // Add the new list items and their event handlers 206 for (j = iStart; j <= iEnd; j++) { 207 sClass = (j == oPaging.iPage + 1) ? 'class="active"' : ''; 208 $('<li ' + sClass + '><a href="#">' + j + '</a></li>') 209 .insertBefore($('li.next:first', an[i])[0]) 210 .bind('click', function (e) { 211 e.preventDefault(); 212 oSettings._iDisplayStart = (parseInt($('a', this).text(), 10) - 1) * oPaging.iLength; 213 fnDraw(oSettings); 214 }); 215 } 216 217 // Add / remove disabled classes from the static elements 218 if (oPaging.iPage === 0) { 219 $('li.prev', an[i]).addClass('disabled'); 220 } else { 221 $('li.prev', an[i]).removeClass('disabled'); 222 } 223 224 if (oPaging.iPage === oPaging.iTotalPages - 1 || oPaging.iTotalPages === 0) { 225 $('li.next', an[i]).addClass('disabled'); 226 } else { 227 $('li.next', an[i]).removeClass('disabled'); 228 } 229 } 230 } 231 } 232}); 233 234$.extend($.fn.dataTableExt.oPagination, { 235 "bootstrap_number": { 236 "fnInit": function (oSettings, nPaging, fnDraw) { 237 var oLang = oSettings.oLanguage.oPaginate; 238 var fnClickHandler = function (e) { 239 e.preventDefault(); 240 if (oSettings.oApi._fnPageChange(oSettings, e.data.action)) { 241 fnDraw(oSettings); 242 } 243 }; 244 245 $(nPaging).append( 246 '<ul class="pagination">' + 247 '<li class="prev disabled"><a href="#" title="' + oLang.sPrevious + '"><i class="fa fa-angle-left"></i></a></li>' + 248 '<li class="next disabled"><a href="#" title="' + oLang.sNext + '"><i class="fa fa-angle-right"></i></a></li>' + 249 '</ul>' 250 ); 251 var els = $('a', nPaging); 252 $(els[0]).bind('click.DT', { 253 action: "previous" 254 }, fnClickHandler); 255 $(els[1]).bind('click.DT', { 256 action: "next" 257 }, fnClickHandler); 258 }, 259 260 "fnUpdate": function (oSettings, fnDraw) { 261 var iListLength = 5; 262 var oPaging = oSettings.oInstance.fnPagingInfo(); 263 var an = oSettings.aanFeatures.p; 264 var i, j, sClass, iStart, iEnd, iHalf = Math.floor(iListLength / 2); 265 266 if (oPaging.iTotalPages < iListLength) { 267 iStart = 1; 268 iEnd = oPaging.iTotalPages; 269 } else if (oPaging.iPage <= iHalf) { 270 iStart = 1; 271 iEnd = iListLength; 272 } else if (oPaging.iPage >= (oPaging.iTotalPages - iHalf)) { 273 iStart = oPaging.iTotalPages - iListLength + 1; 274 iEnd = oPaging.iTotalPages; 275 } else { 276 iStart = oPaging.iPage - iHalf + 1; 277 iEnd = iStart + iListLength - 1; 278 } 279 280 for (i = 0, iLen = an.length; i < iLen; i++) { 281 if (oPaging.iTotalPages <= 0) { 282 $('.pagination', an[i]).css('visibility', 'hidden'); 283 } else { 284 $('.pagination', an[i]).css('visibility', 'visible'); 285 } 286 287 // Remove the middle elements 288 $('li:gt(0)', an[i]).filter(':not(.next)').remove(); 289 290 // Add the new list items and their event handlers 291 for (j = iStart; j <= iEnd; j++) { 292 sClass = (j == oPaging.iPage + 1) ? 'class="active"' : ''; 293 $('<li ' + sClass + '><a href="#">
293' + j + '</a></li>') 294 .insertBefore($('li.next:first', an[i])[0]) 295 .bind('click', function (e) { 296 e.preventDefault(); 297 oSettings._iDisplayStart = (parseInt($('a', this).text(), 10) - 1) * oPaging.iLength; 298 fnDraw(oSettings); 299 }); 300 } 301 302 // Add / remove disabled classes from the static elements 303 if (oPaging.iPage === 0) { 304 $('li.prev', an[i]).addClass('disabled'); 305 } else { 306 $('li.prev', an[i]).removeClass('disabled'); 307 } 308 309 if (oPaging.iPage === oPaging.iTotalPages - 1 || oPaging.iTotalPages === 0) { 310 $('li.next', an[i]).addClass('disabled'); 311 } else { 312 $('li.next', an[i]).removeClass('disabled'); 313 } 314 } 315 } 316 } 317}); 318 319 320/* Bootstrap style full number pagination control */ 321$.extend($.fn.dataTableExt.oPagination, { 322 "bootstrap_extended": { 323 "fnInit": function (oSettings, nPaging, fnDraw) { 324 var oLang = oSettings.oLanguage.oPaginate; 325 var oPaging = oSettings.oInstance.fnPagingInfo(); 326 327 var fnClickHandler = function (e) { 328 e.preventDefault(); 329 if (oSettings.oApi._fnPageChange(oSettings, e.data.action)) { 330 fnDraw(oSettings); 331 } 332 }; 333 334 $(nPaging).append( 335 '<div class="pagination-panel"> ' + (oLang.page ? oLang.page : '') + ' ' + 336 '<a href="#" class="btn btn-sm default prev disabled"><i class="fa fa-angle-left"></i></a>' + 337 '<input type="text" class="pagination-panel-input form-control input-sm input-inline input-mini" maxlenght="5" style="text-align:center; margin: 0 5px;">' + 338 '<a href="#" class="btn btn-sm default next disabled"><i class="fa fa-angle-right"></i></a> ' + 339 (oLang.pageOf ? oLang.pageOf + ' <span class="pagination-panel-total"></span>': '') + 340 '</div>' 341 ); 342 343 var els = $('a', nPaging); 344 345 $(els[0]).bind('click.DT', { 346 action: "previous" 347 }, fnClickHandler); 348 $(els[1]).bind('click.DT', { 349 action: "next" 350 }, fnClickHandler); 351 352 $('.pagination-panel-input', nPaging).bind('change.DT', function (e) { 353 var oPaging = oSettings.oInstance.fnPagingInfo(); 354 e.preventDefault(); 355 var page = parseInt($(this).val()); 356 if (page > 0 && page <= oPaging.iTotalPages) { 357 if (oSettings.oApi._fnPageChange(oSettings, page - 1)) { 358 fnDraw(oSettings); 359 } 360 } else { 361 $(this).val(oPaging.iPage + 1); 362 } 363 }); 364 365 $('.pagination-panel-input', nPaging).bind('keypress.DT', function (e) { 366 var oPaging = oSettings.oInstance.fnPagingInfo(); 367 if (e.which == 13) { 368 var page = parseInt($(this).val()); 369 if (page > 0 && page <= oSettings.oInstance.fnPagingInfo().iTotalPages) { 370 if (oSettings.oApi._fnPageChange(oSettings, page - 1)) { 371 fnDraw(oSettings); 372 } 373 } else { 374 $(this).val(oPaging.iPage + 1); 375 } 376 e.preventDefault(); 377 } 378 }); 379 }, 380 381 "fnUpdate": function (oSettings, fnDraw) { 382 var iListLength = 5; 383 var oPaging = oSettings.oInstance.fnPagingInfo(); 384 var an = oSettings.aanFeatures.p; 385 var i, j, sClass, iStart, iEnd, iHalf = Math.floor(iListLength / 2); 386 387 if (oPaging.iTotalPages < iListLength) { 388 iStart = 1; 389 iEnd = oPaging.iTotalPages; 390 } else if (oPaging.iPage <= iHalf) { 391 iStart = 1; 392 iEnd = iListLength; 393 } else if (oPaging.iPage >= (oPaging.iTotalPages - iHalf)) { 394 iStart = oPaging.iTotalPages - iListLength + 1; 395 iEnd = oPaging.iTotalPages; 396 } else { 397 iStart = oPaging.iPage - iHalf + 1; 398 iEnd = iStart + iListLength - 1; 399 } 400 401 for (i = 0, iLen = an.length; i < iLen; i++) { 402 var wrapper = $(an[i]).parents(".dataTables_wrapper"); 403 404 if (oPaging.iTotal <= 0) { 405 $('.dataTables_paginate, .dataTables_length', wrapper).hide(); 406 } else { 407 $('.dataTables_paginate, .dataTables_length', wrapper).show(); 408 } 409 410 if (oPaging.iTotalPages <= 0) { 411 $('.dataTables_paginate, .dataTables_length .seperator', wrapper).hide(); 412 } else { 413 $('.dataTables_paginate, .dataTables_length .seperator', wrapper).show(); 414 } 415 416 $('.pagination-panel-total', an[i]).html(oPaging.iTotalPages); 417 $('.pagination-panel-input', an[i]).val(oPaging.iPage + 1); 418 419 // Remove the middle elements 420 $('li:gt(1)', an[i]).filter(':not(.next)').remove(); 421 422 // Add the new list items and their event handlers 423 for (j = iStart; j <= iEnd; j++) { 424 sClass = (j == oPaging.iPage + 1) ? 'class="active"' : ''; 425 $('<li ' + sClass + '><a href="#">
425' + j + '</a></li>') 426 .insertBefore($('li.next:first', an[i])[0]) 427 .bind('click', function (e) { 428 e.preventDefault(); 429 oSettings._iDisplayStart = (parseInt($('a', this).text(), 10) - 1) * oPaging.iLength; 430 fnDraw(oSettings); 431 }); 432 } 433 434 // Add / remove disabled classes from the static elements 435 if (oPaging.iPage === 0) { 436 $('a.prev', an[i]).addClass('disabled'); 437 } else { 438 $('a.prev', an[i]).removeClass('disabled'); 439 } 440 441 if (oPaging.iPage === oPaging.iTotalPages - 1 || oPaging.iTotalPages === 0) { 442 $('a.next', an[i]).addClass('disabled'); 443 } else { 444 $('a.next', an[i]).removeClass('disabled'); 445 } 446 } 447 } 448 } 449});
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.