Comparing version 1.1.4 to 1.1.5
{ | ||
"name": "timbles", | ||
"version": "1.1.4", | ||
"version": "1.1.5", | ||
"description": "a p chill jQuery table plugin, made by people who literally did not invent tables", | ||
@@ -5,0 +5,0 @@ "main": "timbles", |
@@ -267,2 +267,3 @@ timbles.js | ||
## Changelog | ||
* 1.1.5 add initial inverse sort support | ||
* 1.1.4 prepare to plug in (a refactor for future features) | ||
@@ -269,0 +270,0 @@ * 1.1.3 pagination refactor, testing refactor, so much faster! |
@@ -9,3 +9,4 @@ [ | ||
"pets": "Gold fish", | ||
"sparse": "One" | ||
"sparse": "One", | ||
"inverse": "Macao" | ||
}, | ||
@@ -19,3 +20,4 @@ { | ||
"pets": "Crickets", | ||
"sparse": "One" | ||
"sparse": "One", | ||
"inverse": "Zimbabwe" | ||
}, | ||
@@ -29,3 +31,4 @@ { | ||
"pets": "Rabbit", | ||
"sparse": "" | ||
"sparse": "", | ||
"inverse": "" | ||
}, | ||
@@ -39,3 +42,4 @@ { | ||
"pets": "Dog", | ||
"sparse": "" | ||
"sparse": "", | ||
"inverse": "Brazil" | ||
}, | ||
@@ -49,4 +53,5 @@ { | ||
"pets": "Cat", | ||
"sparse": "Two" | ||
"sparse": "Two", | ||
"inverse": "Honduras" | ||
} | ||
] |
@@ -5,6 +5,5 @@ /* Test sorting of timblified tables */ | ||
function sortedColumnContent( columnIndex, order ) { | ||
/* Sorts by the given column and returns an array with the column contents | ||
function getColumnContent( columnIndex ) { | ||
/* Returns an array with the column contents | ||
*/ | ||
target.timbles( 'sortColumn', columnIndex, order || 'asc' ); | ||
return target.find( 'tbody tr' ).map( function() { | ||
@@ -15,2 +14,9 @@ return $( this ).children().eq( columnIndex ).text(); | ||
function sortedColumnContent( columnIndex, order ) { | ||
/* Sorts by the given column and returns an array with the column contents | ||
*/ | ||
target.timbles( 'sortColumn', columnIndex, order || 'asc' ); | ||
return getColumnContent( columnIndex ); | ||
} | ||
function sliceForPagination( elements ) { | ||
@@ -33,3 +39,3 @@ /* Returns the correct number of elements to compare when pagination is defined | ||
var sortHeaders = target.find( 'th.timbles-sort-header' ).length; | ||
assert.equal( sortHeaders, 6 ); | ||
assert.equal( sortHeaders, 7 ); | ||
} ); | ||
@@ -172,1 +178,16 @@ | ||
} ); | ||
QUnit.test( 'Sorting inverse-sorted columns', function( assert ) { | ||
var expected = [ 'Zimbabwe', 'Macao', 'Honduras', 'Brazil', '' ]; | ||
target.timbles( 'sortColumn', 7 ); | ||
assert.deepEqual( | ||
getColumnContent( 7 ), | ||
sliceForPagination( expected ), | ||
'Descending order' ); | ||
expected.reverse(); | ||
target.timbles( 'sortColumn', 7 ); | ||
assert.deepEqual( | ||
getColumnContent( 7 ), | ||
sliceForPagination( expected ), | ||
'Ascending order' ); | ||
} ); |
@@ -22,2 +22,3 @@ /** | ||
sortDESC: 'sorted-desc', | ||
inverseSort: 'inverse-sort', | ||
noSort: 'no-sort', | ||
@@ -97,6 +98,2 @@ navigationCurrentPage: 'pointer-this-page', | ||
methods.enableSorting.call( this ); | ||
if ( data.sorting.keyId ) { | ||
methods.sortColumn.call( this, data.sorting.keyId, data.sorting.order ); | ||
} | ||
} | ||
@@ -129,2 +126,3 @@ | ||
.addClass( value.noSorting ? data.classes.noSort : null ) | ||
.addClass( value.inverseSort ? data.classes.inverseSort : null ) | ||
.text( value.label ) | ||
@@ -166,2 +164,6 @@ .appendTo( $headerRow ); | ||
.on( 'click', methods.sortColumnEvent.bind( this ) ); | ||
if ( data.sorting && data.sorting.keyId ) { | ||
methods.sortColumn.call( this, data.sorting.keyId, data.sorting.order ); | ||
} | ||
}, | ||
@@ -190,3 +192,11 @@ | ||
if ( !order ) { | ||
order = $sortHeader.hasClass( data.classes.sortASC ) ? 'desc' : 'asc'; | ||
if ( $sortHeader.hasClass( data.classes.sortASC ) ) { | ||
order = 'desc'; | ||
} else if ( $sortHeader.hasClass( data.classes.sortDESC ) ) { | ||
order = 'asc'; | ||
} else if ( $sortHeader.hasClass( data.classes.inverseSort ) ) { | ||
order = 'desc'; | ||
} else { | ||
order = 'asc'; | ||
} | ||
} | ||
@@ -193,0 +203,0 @@ data.$headers |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
274506
4945
287