Adding a collation test to tablesorter, fixing var ref from r90630
authorLeo Koppelkamm <diebuche@users.mediawiki.org>
Thu, 23 Jun 2011 07:39:56 +0000 (07:39 +0000)
committerLeo Koppelkamm <diebuche@users.mediawiki.org>
Thu, 23 Jun 2011 07:39:56 +0000 (07:39 +0000)
resources/jquery/jquery.tablesorter.js
tests/qunit/index.html
tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js

index 3ce4c66..808cf6b 100644 (file)
                                                }
                                        }
                                        if (keys.length) {
-                                               ts.collationRegex = new RegExp( '[' + ts.collationRegex.join('') + ']', 'ig' );
+                                               ts.collationRegex = new RegExp( '[' + keys.join('') + ']', 'ig' );
                                        }
                                }
                        }
index 94fccbb..0e1a045 100644 (file)
@@ -60,7 +60,7 @@
        <script src="suites/resources/jquery/jquery.autoEllipsis.js"></script>
        <script src="suites/resources/jquery/jquery.colorUtil.js"></script>
        <script src="suites/resources/jquery/jquery.tabIndex.js"></script>
-       <script src="suites/resources/jquery/jquery.tablesorter.test.js"></script>
+       <script src="suites/resources/jquery/jquery.tablesorter.test.js" charset="UTF-8"></script>
        <script src="suites/resources/mediawiki/mediawiki.Title.js"></script>
 
        <!-- TestSwarm: If a test swarm is running this,
index 385d98a..e9c075b 100644 (file)
@@ -27,7 +27,7 @@ var tableCreate = function( header, data ) {
        $.each(header, function(i, str) {
                var $th = $('<th>');
                $th.text(str).appendTo($tr);
-       })
+       });
        $tr.appendTo($thead);
 
        for (var i = 0; i < data.length; i++) {
@@ -35,7 +35,7 @@ var tableCreate = function( header, data ) {
                $.each(data[i], function(j, str) {
                        var $td = $('<td>');
                        $td.text(str).appendTo($tr);
-               })
+               });
                $tr.appendTo($tbody);
        }
        return $table;
@@ -53,7 +53,7 @@ var tableExtract = function( $table ) {
                var row = [];
                $(tr).find('td,th').each(function(i, td) {
                        row.push($(td).text());
-               })
+               });
                data.push(row);
        });
        return data;
@@ -82,7 +82,7 @@ var tableTest = function( msg, header, data, expected, callback ) {
                // Table sorting is done synchronously; if it ever needs to change back
                // to asynchronous, we'll need a timeout or a callback here.
                var extracted = tableExtract( $table );
-               deepEqual( extracted, expected, msg )
+               deepEqual( extracted, expected, msg );
        });
 };
 
@@ -90,7 +90,7 @@ var reversed = function(arr) {
        var arr2 = arr.slice(0);
        arr2.reverse();
        return arr2;
-}
+};
 
 // Sample data set: some planets!
 var header = ['Planet', 'Radius (km)'],
@@ -255,4 +255,47 @@ tableTest(
        }
 );
 
+var umlautWords = [
+       // Some words with Umlauts
+       ['Günther'],
+       ['Peter'],
+       ['Björn'],
+       ['Bjorn'],
+       ['Apfel'],
+       ['Äpfel'],
+       ['Strasse'],
+       ['Sträßschen']
+];
+
+var umlautWordsSorted = [
+       // Some words with Umlauts
+       ['Äpfel'],
+       ['Apfel'],
+       ['Björn'],
+       ['Bjorn'],
+       ['Günther'],
+       ['Peter'],
+       ['Sträßschen'],
+       ['Strasse']
+];
+
+tableTest(
+       'Accented Characters with custom collation',
+       ['Name'],
+       umlautWords,
+       umlautWordsSorted,
+       function( $table ) {
+               mw.config.set('tableSorterCollation', {'ä':'ae', 'ö' : 'oe', 'ß': 'ss', 'ü':'ue'});
+               $table.tablesorter();
+               $table.find('.headerSort:eq(0)').click();
+               mw.config.set('tableSorterCollation', {});
+       }
+);
+
+
+
+
+
+
+
 })();