| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
;(function($) { |
| 8 |
'use strict'; |
| 9 |
|
| 10 |
var ts = $.tablesorter; |
| 11 |
|
| 12 |
|
| 13 |
ts.ignoreArticles = { |
| 14 |
'en' : 'the, a, an', |
| 15 |
'de' : 'der, die, das, des, dem, den, ein, eine, einer, eines, einem, einen', |
| 16 |
'nl' : 'de, het, de, een', |
| 17 |
'es' : 'el, la, lo, los, las, un, una, unos, unas', |
| 18 |
'pt' : 'o, a, os, as, um, uma, uns, umas', |
| 19 |
'fr' : 'le, la, l\'_, les, un, une, des', |
| 20 |
'it' : 'il, lo, la, l\'_, i, gli, le, un\', uno, una, un', |
| 21 |
'hu' : 'a, az, egy' |
| 22 |
}; |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
ts.addParser({ |
| 30 |
id: 'ignoreArticles', |
| 31 |
is: function() { |
| 32 |
return false; |
| 33 |
}, |
| 34 |
format: function(s, table, cell, cellIndex) { |
| 35 |
var art, ignore, lang, |
| 36 |
c = table.config, |
| 37 |
str = s || ''; |
| 38 |
if ( !(c.headers && c.headers[cellIndex] && c.headers[cellIndex].ignoreArticlesRegex) ) { |
| 39 |
|
| 40 |
if (!c.headers) { c.headers = {}; } |
| 41 |
if (!c.headers[cellIndex]) { c.headers[cellIndex] = {}; } |
| 42 |
lang = ts.getData( c.$headers.eq(cellIndex), ts.getColumnData( table, c.headers, cellIndex ), 'ignoreArticles' ); |
| 43 |
art = (ts.ignoreArticles[lang] || 'the, a, an' ) + ''; |
| 44 |
c.headers[cellIndex].ignoreArticlesRegex = new RegExp('^(' + $.trim( art.split(/\s*\,\s*/).join('\\s|') + '\\s' ).replace('_\\s', '') + ')', 'i'); |
| 45 |
|
| 46 |
ignore = ts.getData( c.$headers.eq(cellIndex), ts.getColumnData( table, c.headers, cellIndex ), 'ignoreArticlesExcept' ); |
| 47 |
c.headers[cellIndex].ignoreArticlesRegex2 = ignore !== '' ? new RegExp('^(' + ignore.replace(/\s/g, '\\s') + ')', 'i') : ''; |
| 48 |
} |
| 49 |
art = c.headers[cellIndex].ignoreArticlesRegex; |
| 50 |
if (art.test(str)) { |
| 51 |
ignore = c.headers[cellIndex].ignoreArticlesRegex2; |
| 52 |
if ( !(ignore && ignore.test(str)) ) { |
| 53 |
return str.replace(art, ''); |
| 54 |
} |
| 55 |
} |
| 56 |
return str; |
| 57 |
}, |
| 58 |
type: 'text' |
| 59 |
}); |
| 60 |
|
| 61 |
})(jQuery); |