/*! Parser: ignoreArticles - updated 9/15/2014 (v2.17.8) */ /* * 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/ */ /*jshint browser: true, jquery:true, unused:false */ !function(a){"use strict";var b=a.tablesorter; // basic list from http://en.wikipedia.org/wiki/Article_%28grammar%29 b.ignoreArticles={en:"the, a, an",de:"der, die, das, des, dem, den, ein, eine, einer, eines, einem, einen",nl:"de, het, de, een",es:"el, la, lo, los, las, un, una, unos, unas",pt:"o, a, os, as, um, uma, uns, umas",fr:"le, la, l'_, les, un, une, des",it:"il, lo, la, l'_, i, gli, le, un', uno, una, un",hu:"a, az, egy"}, // To add a custom parser, define: // $.tablesorter.ignoreArticles['xx'] = 'A, B, C'; // and then set the language id 'xx' in the headers option // ignoreArticles : 'xx' b.addParser({id:"ignoreArticles",is:function(){return!1},format:function(c,d,e,f){var g,h,i,j=d.config,k=c||"";return j.headers&&j.headers[f]&&j.headers[f].ignoreArticlesRegex||( // initialize - save regex in c.headers[cellIndex].ignoreArticlesRegex j.headers||(j.headers={}),j.headers[f]||(j.headers[f]={}),i=b.getData(j.$headers.eq(f),b.getColumnData(d,j.headers,f),"ignoreArticles"),g=(b.ignoreArticles[i]||"the, a, an")+"",j.headers[f].ignoreArticlesRegex=new RegExp("^("+a.trim(g.split(/\s*\,\s*/).join("\\s|")+"\\s").replace("_\\s","")+")","i"),h=b.getData(j.$headers.eq(f),b.getColumnData(d,j.headers,f),"ignoreArticlesExcept"),j.headers[f].ignoreArticlesRegex2=""!==h?new RegExp("^("+h.replace(/\s/g,"\\s")+")","i"):""),g=j.headers[f].ignoreArticlesRegex,!g.test(k)||(h=j.headers[f].ignoreArticlesRegex2,h&&h.test(k))?k:k.replace(g,"")},type:"text"})}(jQuery);