tablesorter/js/parsers/parser-ignore-leads.js

24 lines
561 B
JavaScript
Raw Normal View History

2013-03-26 21:16:13 +00:00
/*! Title parser
* This parser will remove "The", "A" and "An" from the beginning of a book
* or movie title, so it sorts by the second word or number
* Demo: http://jsfiddle.net/Mottie/abkNM/5/
*/
/*global jQuery: false */
;(function($){
"use strict";
$.tablesorter.addParser({
id: 'ignoreLeads',
is: function() {
return false;
},
format: function(s) {
2013-03-27 23:13:44 +00:00
// Add more lead words inside the parentheses below
2013-03-26 21:16:13 +00:00
// separated by a vertical bar (shift + \)
return (s || '').replace(/^(The|A|An)\s/i, '');
},
type: 'text'
});
})(jQuery);