All Downloads are FREE. Search and download functionalities are using the official Maven repository.

bootstrap.datatables.bootstrap3-datatables.js Maven / Gradle / Ivy

There is a newer version: 2.0.2
Show newest version
/* Source: https://github.com/DataTables/Plugins/tree/master/integration/bootstrap/3 */

/* Default class modification */
$.extend( $.fn.dataTableExt.oStdClasses, {
  "sWrapper": "dataTables_wrapper form-inline",
  "sFilterInput": "form-control input-sm",
  "sLengthSelect": "form-control input-sm",
  /* [ph] added button class */
  "sPageButton" : "btn"
} );

//In 1.10 we use the pagination renderers to draw the Bootstrap paging,
//rather than  custom plug-in
if ( $.fn.dataTable.Api ) {
  $.fn.dataTable.defaults.renderer = 'bootstrap';
  $.fn.dataTable.ext.renderer.pageButton.bootstrap = function ( settings, host, idx, buttons, page, pages ) {
   var api = new $.fn.dataTable.Api( settings );
   var classes = settings.oClasses;
   var lang = settings.oLanguage.oPaginate;
   var btnDisplay, btnClass;
  
   var attach = function( container, buttons ) {
     var i, ien, node, button;
     var clickHandler = function ( e ) {
       e.preventDefault();
       if ( e.data.action !== 'ellipsis' ) {
         api.page( e.data.action ).draw( false );
       }
     };
  
     for ( i=0, ien=buttons.length ; i 0 ?
               '' : ' disabled');
             break;
  
           case 'previous':
             btnDisplay = lang.sPrevious;
             btnClass = button + ' btn-default' + (page > 0 ?
               '' : ' disabled');
             break;
  
           case 'next':
             btnDisplay = lang.sNext;
             btnClass = button + ' btn-default' + (page < pages-1 ?
               '' : ' disabled');
             break;
  
           case 'last':
             btnDisplay = lang.sLast;
             btnClass = button + ' btn-default' + (page < pages-1 ?
               '' : ' disabled');
             break;
  
           default:
             /** [ph] all buttons are btn-default except for the active one which is btn-primary */ 
             btnDisplay = button + 1;
             btnClass = page === button ?
               'btn-primary active' : 'btn-default';
             break;
         }
  
         if ( btnDisplay ) {
           /** [ph] using only a single  element for a button */
           node = $('', {
               'href': '#',
               'class': classes.sPageButton+' '+btnClass,
               'aria-controls': settings.sTableId,
               'tabindex': settings.iTabIndex,
               'id': idx === 0 && typeof button === 'string' ?
                 settings.sTableId +'_'+ button :
                 null
             } )
             .html( btnDisplay )
             .appendTo( container );
  
           settings.oApi._fnBindAction(
             node, {action: button}, clickHandler
           );
         }
       }
     }
   };
  
   attach(
     /** ph added btn-group */
     $(host).empty().html('