diff --git a/media/src/api/api.row.js b/media/src/api/api.row.js index c8258352..ae9a6c51 100644 --- a/media/src/api/api.row.js +++ b/media/src/api/api.row.js @@ -45,8 +45,14 @@ _api.register( 'row().data()', function ( data ) { // return undefined; // @todo - Set operator + ctx[0].aoData[ this[0] ]._aData = data; + + // Invalidate the row } ); +// Should row object have an invalidated flag? Scan the array before doing +// anything with the data? or better to update at the invalidation point + _api.register( 'row().index()', function () { return this.length ? this[0] : undefined; diff --git a/media/src/core/core.sort.js b/media/src/core/core.sort.js index d913723b..6ea0ee0c 100644 --- a/media/src/core/core.sort.js +++ b/media/src/core/core.sort.js @@ -1,3 +1,37 @@ + + +function _fnSortFlatten ( settings ) +{ + var + i, iLen, k, kLen, + aSort = [], + aiOrig = [], + aoColumns = settings.aoColumns, + aDataSort, iCol, sType, + nestedSort = settings.aaSortingFixed.concat( settings.aaSorting ); + + for ( i=0 ; iy ? 1 : 0; - if ( test !== 0 ) - { + if ( test !== 0 ) { return sort.dir === 'asc' ? test : -test; } } - + x = aiOrig[a]; y = aiOrig[b]; return xy ? 1 : 0; @@ -162,34 +129,32 @@ function _fnSort ( oSettings, bApplyClasses ) // Depreciated - remove in 1.11 (providing a plug-in option) // Not all sort types have formatting methods, so we have to call their sorting // methods. - oSettings.aiDisplayMaster.sort( function ( a, b ) { + displayMaster.sort( function ( a, b ) { var x, y, k, l, test, sort, len=aSort.length, dataA = aoData[a]._aSortData, dataB = aoData[b]._aSortData; - for ( k=0 ; ky ? 1 : 0; } ); } } - + /* Alter the sorting classes to take account of the changes */ if ( (bApplyClasses === undefined || bApplyClasses) && !oSettings.oFeatures.bDeferRender ) { @@ -202,14 +167,14 @@ function _fnSort ( oSettings, bApplyClasses ) nTh = aoColumns[i].nTh; nTh.removeAttribute('aria-sort'); nTh.removeAttribute('aria-label'); - + /* In ARIA only the first sorting column can be marked as sorting - no multi-sort option */ if ( aoColumns[i].bSortable ) { if ( aSort.length > 0 && aSort[0].col == i ) { nTh.setAttribute('aria-sort', aSort[0].dir=="asc" ? "ascending" : "descending" ); - + var nextSort = (aoColumns[i].asSorting[ aSort[0].index+1 ]) ? aoColumns[i].asSorting[ aSort[0].index+1 ] : aoColumns[i].asSorting[0]; nTh.setAttribute('aria-label', sTitle+ @@ -226,7 +191,7 @@ function _fnSort ( oSettings, bApplyClasses ) nTh.setAttribute('aria-label', sTitle); } } - + /* Tell the draw function that we have sorted the data */ oSettings.bSorted = true; $(oSettings.oInstance).trigger('sort', oSettings); @@ -374,14 +339,7 @@ function _fnSortingClasses( oSettings ) } } - if ( oSettings.aaSortingFixed !== null ) - { - aaSort = oSettings.aaSortingFixed.concat( oSettings.aaSorting ); - } - else - { - aaSort = oSettings.aaSorting.slice(); - } + aaSort = _fnSortFlatten( oSettings ); /* Apply the required classes to the header */ for ( i=0 ; i