From 50f91222f23c52d104f9121da4fd1e6e35581202 Mon Sep 17 00:00:00 2001 From: Denis Peplin Date: Wed, 29 Oct 2014 08:23:17 +0300 Subject: [PATCH] Take new plugin version from datatables bootstrap examples. --- .../2/jquery.dataTables.bootstrap.js | 65 +++++++++++++++++-- 1 file changed, 59 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/dataTables/bootstrap/2/jquery.dataTables.bootstrap.js b/app/assets/javascripts/dataTables/bootstrap/2/jquery.dataTables.bootstrap.js index 497638f..7c552e0 100755 --- a/app/assets/javascripts/dataTables/bootstrap/2/jquery.dataTables.bootstrap.js +++ b/app/assets/javascripts/dataTables/bootstrap/2/jquery.dataTables.bootstrap.js @@ -1,8 +1,19 @@ +/* Set the defaults for DataTables initialisation */ +$.extend( true, $.fn.dataTable.defaults, { + "sDom": "<'row-fluid'<'span6'l><'span6'f>r>t<'row-fluid'<'span6'i><'span6'p>>", + "sPaginationType": "bootstrap", + "oLanguage": { + "sLengthMenu": "_MENU_ records per page" + } +} ); + + /* Default class modification */ $.extend( $.fn.dataTableExt.oStdClasses, { "sWrapper": "dataTables_wrapper form-inline" } ); + /* API method to get paging information */ $.fn.dataTableExt.oApi.fnPagingInfo = function ( oSettings ) { @@ -12,10 +23,13 @@ $.fn.dataTableExt.oApi.fnPagingInfo = function ( oSettings ) "iLength": oSettings._iDisplayLength, "iTotal": oSettings.fnRecordsTotal(), "iFilteredTotal": oSettings.fnRecordsDisplay(), - "iPage": Math.ceil( oSettings._iDisplayStart / oSettings._iDisplayLength ), - "iTotalPages": Math.ceil( oSettings.fnRecordsDisplay() / oSettings._iDisplayLength ) + "iPage": oSettings._iDisplayLength === -1 ? + 0 : Math.ceil( oSettings._iDisplayStart / oSettings._iDisplayLength ), + "iTotalPages": oSettings._iDisplayLength === -1 ? + 0 : Math.ceil( oSettings.fnRecordsDisplay() / oSettings._iDisplayLength ) }; -} +}; + /* Bootstrap style pagination control */ $.extend( $.fn.dataTableExt.oPagination, { @@ -41,10 +55,10 @@ $.extend( $.fn.dataTableExt.oPagination, { }, "fnUpdate": function ( oSettings, fnDraw ) { - var iListLength = jQuery.fn.dataTableExt.oPagination.iFullNumbersShowPages; + var iListLength = 5; var oPaging = oSettings.oInstance.fnPagingInfo(); var an = oSettings.aanFeatures.p; - var i, j, sClass, iStart, iEnd, iHalf=Math.floor(iListLength/2); + var i, ien, j, sClass, iStart, iEnd, iHalf=Math.floor(iListLength/2); if ( oPaging.iTotalPages < iListLength) { iStart = 1; @@ -61,7 +75,7 @@ $.extend( $.fn.dataTableExt.oPagination, { iEnd = iStart + iListLength - 1; } - for ( i=0, iLen=an.length ; i