diff --git a/media/src/DataTables.js b/media/src/DataTables.js index e026eff4..491db585 100644 --- a/media/src/DataTables.js +++ b/media/src/DataTables.js @@ -179,6 +179,7 @@ require('ext.sorting.js'); require('ext.types.js'); require('ext.filter.js'); + require('ext.renderer.js'); // jQuery aliases $.fn.dataTable = DataTable; diff --git a/media/src/core/core.constructor.js b/media/src/core/core.constructor.js index 5100de6d..1a165aed 100644 --- a/media/src/core/core.constructor.js +++ b/media/src/core/core.constructor.js @@ -179,6 +179,13 @@ if ( oInit.bJQueryUI ) /* Set the DOM to use a layout suitable for jQuery UI's theming */ oSettings.sDom = '<"H"lfr>t<"F"ip>'; } + + if ( ! oSettings.renderer ) { + oSettings.renderer = 'jqueryui'; + } + else if ( $.isPlainObject( oSettings.renderer ) && ! oSettings.renderer.header ) { + oSettings.renderer.header = 'jqueryui'; + } } else { diff --git a/media/src/core/core.draw.js b/media/src/core/core.draw.js index 5b86a93c..cd6e6d85 100644 --- a/media/src/core/core.draw.js +++ b/media/src/core/core.draw.js @@ -130,30 +130,16 @@ function _fnBuildHead( oSettings ) if ( column.sTitle != cell.html() ) { cell.html( column.sTitle ); } + + _fnRenderer( oSettings, 'header' )( + oSettings, cell, column, i, classes + ); } if ( createHeader ) { _fnDetectHeader( oSettings.aoHeader, thead ); } - /* Add the extra markup needed by jQuery UI's themes */ - if ( oSettings.bJUI ) - { - for ( i=0, ien=columns.length ; itr').attr('role', 'row'); @@ -511,7 +497,7 @@ function _fnAddOptionsHtml ( oSettings ) j++; } - /* Replace jQuery UI constants */ + /* Replace jQuery UI constants @todo depreciated */ if ( sAttr == "H" ) { sAttr = oSettings.oClasses.sJUIHeader; diff --git a/media/src/core/core.page.js b/media/src/core/core.page.js index 0a3f0ef5..5e7cb252 100644 --- a/media/src/core/core.page.js +++ b/media/src/core/core.page.js @@ -68,27 +68,6 @@ function _fnFeatureHtmlPaginate ( settings ) } -function _fnRenderer( settings, type ) -{ - var renderer = settings.renderer; - var host = DataTable.ext.renderer[type]; - - if ( $.isPlainObject( renderer ) && renderer[type] ) { - // Specific renderer for this type. If available use it, otherwise use - // the default. - return host[renderer[type]] || host._; - } - else if ( typeof renderer === 'string' ) { - // Common renderer - if there is one available for this type use it, - // otherwise use the default - return host[renderer] || host._; - } - - // Use the default - return host._; -} - - /** * Alter the display settings to change the page * @param {object} settings DataTables settings object diff --git a/media/src/core/core.sort.js b/media/src/core/core.sort.js index c161d441..1e2efc8c 100644 --- a/media/src/core/core.sort.js +++ b/media/src/core/core.sort.js @@ -42,7 +42,7 @@ function _fnSortFlatten ( settings ) function _fnSort ( oSettings, bApplyClasses ) { var - i, ien, iLen, j, jLen, k, kLen, + i, ien, iLen, j, jLen, k, kLen, sortedColumns={}, sDataType, nTh, aSort = [], aiOrig = [], @@ -59,6 +59,7 @@ function _fnSort ( oSettings, bApplyClasses ) for ( i=0, ien=aSort.length ; i') + .addClass( classes.sSortJUIWrapper ) + .append( cell.contents() ) + .append( $('') + .addClass( classes.sSortIcon+' '+column.sSortingClassJUI ) + ) + .appendTo( cell ); + + // Attach a sort listener to update on sort + $(settings.nTable).on( 'sort', function ( e, settings, sorting, columns ) { + cell + .removeClass( classes.sSortAsc +" "+classes.sSortDesc ) + .addClass( columns[ idx ] == 'asc' ? + classes.sSortAsc : columns[ idx ] == 'desc' ? + classes.sSortDesc : + column.sSortingClass + ); + + cell + .find( 'span' ) + .removeClass( + classes.sSortJUIAsc +" "+ + classes.sSortJUIDesc +" "+ + classes.sSortJUI +" "+ + classes.sSortJUIAscAllowed +" "+ + classes.sSortJUIDescAllowed + ) + .addClass( columns[ idx ] == 'asc' ? + classes.sSortJUIAsc : columns[ idx ] == 'desc' ? + classes.sSortJUIDesc : + column.sSortingClassJUI + ); + } ); + } + } +} ); +