tablesorter/dist/js/widgets/widget-mark.min.js
2016-08-02 14:56:10 -05:00

2 lines
2.0 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*! Widget: mark.js - updated 8/1/2016 (v2.27.2) */
!function(a){"use strict";var b=a.tablesorter;b.mark={init:function(c){if("function"==typeof a.fn.mark){var d,e=c.widgetOptions.mark_tsUpdate;c.$table.on("filterEnd.tsmark"+(e?" "+e:""),function(a,d){b.mark.update(c,"filterEnd"===a.type?"":d)}),d="(?:<|=|>|\\||\"|\\'|\\s+(?:&&|-|"+(b.language.and||"and")+"|"+(b.language.or||"or")+"|"+(b.language.to||"to")+")\\s+)",b.mark.regex.filter=new RegExp(d,"gim")}else console.warn('Widget-mark not initialized: missing "jquery.mark.js"')},regex:{mark:/^mark_(.+)$/,pure:/^\/((?:\\\/|[^\/])+)\/([mig]{0,3})?$/},checkRegex:function(a){if(a instanceof RegExp){var b="".match(a);return null===b||b.length<5}return!1},cleanMatches:function(a){for(var b=[],c=a&&a.length||0;c--;)""!==a[c]&&(b[b.length]=a[c]);return b},update:function(c,d){var e={},f=c.widgetOptions,g="undefined"==typeof f.filter_ignoreCase||f.filter_ignoreCase,h=b.mark.regex,i=c.$table.find("tbody tr").unmark().not("."+(c.widgetOptions.filter_filteredRow||"filtered"));d=d||a.tablesorter.getFilters(c.$table),a.each(c.widgetOptions,function(a,b){var c=a.match(h.mark);c&&"undefined"!=typeof c[1]&&(e[c[1]]=b)}),a.each(d,function(a,d){if(d){var f=null,j=d,k=!1,l=a===c.columns?"":":nth-child("+(a+1)+")";if(h.pure.test(d)){j=h.pure.exec(d),".*"===j[1]&&(j[1]="");try{f=new RegExp(j[1],"gim"),j=new RegExp(j[1],j[2])}catch(a){j=null}return void(b.mark.checkRegex(f)&&i.children(l).markRegExp(j,e))}0===d.indexOf("~")?(k=!0,j=d.replace(/~/g,"").split("")):(d.indexOf("?")>-1&&(k=!0,d=d.replace(/\?/g,"\\S{1}")),d.indexOf("*")>-1&&(k=!0,d=d.replace(/\*/g,"\\S*")),j=d.split(h.filter)),k&&j&&j.length?(j=new RegExp(b.mark.cleanMatches(j).join(".*"),"gm"+(g?"i":"")),b.mark.checkRegex(j)&&i.children(l).markRegExp(j,e)):i.children(l).mark(b.mark.cleanMatches(j),e)}})}},b.addWidget({id:"mark",options:{mark_tsUpdate:"markUpdate"},init:function(a,c,d,e){b.mark.init(d,e)},remove:function(a,b){var c=b.widgetOptions.mark_tsUpdate;b.$table.off("filterEnd.tsmark"+(c?" "+c:""))}})}(jQuery);