diff --git a/js/utils.js b/js/utils.js index 617721a..7fc8bab 100644 --- a/js/utils.js +++ b/js/utils.js @@ -160,18 +160,18 @@ Utils.arrayToSqlVal = function (arr) { return val; }; -Utils.sortResultsTable = function (table) { +Utils.sortResultsTable = function (table, targetTable) { var cols1st = $(table).find("thead th"); var cols = []; var first = null; - var count = 1; + var count = 0; $.each(cols1st, function (key, value) { count++; if (first != null) { var col = { key: $(value).text(), cell: value, - cells: $(table).find("td:nth-child(" + count + ")").get() + cells: $(table).find("tbody tr:nth-child(" + count + ")").siblings().andSelf().find("td:nth-child(" + (key+1)+ ")").clone( true ) }; // console.log(col ); cols.push(col); @@ -182,11 +182,12 @@ Utils.sortResultsTable = function (table) { }); cols = _.sortBy(cols, "key"); cols.unshift({ - key: " ", - cell: first, - cells: $(table).find("th:nth-child(1)").get()} + key: " ", + cell: first, + cells:$(table).find("tbody tr:nth-child(1)").siblings().andSelf().find("th:nth-child(1)").clone( true ) + } ); - $(table).empty(); + $(targetTable).empty(); var noRows = 0; var currentRow = 0; var noCols = cols.length; @@ -194,11 +195,11 @@ Utils.sortResultsTable = function (table) { var trh = $(""); for (i = 0; i < noCols; i++) { var col = cols[i]; - $(trh).append(col.cell); - noRows = col.cells.length; + $(trh).append($(col.cell).clone( true )); + noRows = col.cells.length + 1; } $(thead).append(trh); - $(table).append(thead); + $(targetTable).append(thead); var tbody = $(""); for (k = 0; k < noRows; k++) { var tr = $(""); @@ -209,10 +210,10 @@ Utils.sortResultsTable = function (table) { if($(cell).text().trim().length<1) { $(cell).text("-"); } - $(tr).append(cell); + $(tr).append($(cell).clone( true )); } $(tbody).append(tr); } - $(table).append(tbody); + $(targetTable).append(tbody); } diff --git a/tests/test-sort-table.html b/tests/test-sort-table.html new file mode 100644 index 0000000..137fa73 --- /dev/null +++ b/tests/test-sort-table.html @@ -0,0 +1,237 @@ + + + + + + + + + + + + + +
+
+
+ +
+
+

Details for Technique H30
Creating a logical tab order through links, form controls, and objects

+
+ +
+

Test cases covering this technique:

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
In the columns, you can find browser versions.
The rows show assistive technologies.
 Internet Explorer 10Firefox 25Internet Explorer 11Firefox 27Firefox 28
Jaws 15 + 1/1 + Not tested + 1/1 + Not tested + 1/1 +
Cobra 10 + 1/1 + Not testedNot testedNot tested + 1/1 +
NVDA 2013.2Not tested + 1/1 + Not testedNot testedNot tested
NVDA 2013.3Not testedNot tested + 1/1 + Not testedNot tested
Window-Eyes 8.4Not testedNot tested + 1/1 + + 1/1 + Not tested
Jaws 14Not testedNot tested + 1/1 + Not testedNot tested
+
+ + +
+ + + +
+
+
+
+
+ + + + + + + + \ No newline at end of file diff --git a/tests/test-sort-table.js b/tests/test-sort-table.js new file mode 100644 index 0000000..c34fb9c --- /dev/null +++ b/tests/test-sort-table.js @@ -0,0 +1,7 @@ +test( "Table sort", function() { + var table = $('#TestResultsFullViewByTechnique_table'); + var targetTable = $('#TestResultsFullViewByTechnique_table_target'); + Utils.sortResultsTable(table,targetTable); + ok( $(table).find("thead th").length === $(targetTable).find("thead th").length, "no of headers are ok" ); + ok( $(table).find("thead td").length === $(targetTable).find("thead td").length, "no of headers are ok" ); +}); \ No newline at end of file