tablesorter/dist/js/widgets/widget-mark.min.js
2016-09-23 11:45:10 -05:00

2 lines
2.3 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 9/23/2016 (v2.27.7) */
!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 pagerComplete.tsmark"+(e?" "+e:""),function(a,d){b.mark.update(c,a.type===e?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},ignoreColumns:function(b){for(var c=b.widgetOptions,d=b.columns,e=[];d--;)(c.mark_tsIgnore[d]||a(b.$headerIndexed[d]).hasClass("mark-ignore"))&&(e[e.length]=":nth-child("+(d+1)+")");return e.length?":not("+e.join(",")+")":""},update:function(c,d){var e={},f=c.widgetOptions,g=b.mark.regex,h=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(g.mark);c&&"undefined"!=typeof c[1]&&(e[c[1]]=b)}),a.each(d,function(d,i){if(i&&!a(c.$headerIndexed[d]).hasClass("mark-ignore")&&!f.mark_tsIgnore[d]){var j=null,k=i,l=!1,m=d===c.columns?b.mark.ignoreColumns(c):":nth-child("+(d+1)+")";if(g.pure.test(i)){k=g.pure.exec(i),".*"===k[1]&&(k[1]="");try{j=new RegExp(k[1],"gim"),k=new RegExp(k[1],k[2])}catch(a){k=null}return void(b.mark.checkRegex(j)&&h.children(m).markRegExp(k,e))}0===i.indexOf("~")?(l=!0,k=i.replace(/~/g,"").split("")):(i.indexOf("?")>-1&&(l=!0,i=i.replace(/\?/g,"\\S{1}")),i.indexOf("*")>-1&&(l=!0,i=i.replace(/\*/g,"\\S*")),k=i.split(g.filter)),l&&k&&k.length?(k=new RegExp(b.mark.cleanMatches(k).join(".*"),"gm"),b.mark.checkRegex(k)&&h.children(m).markRegExp(k,e)):h.children(m).mark(b.mark.cleanMatches(k),e)}})}},b.addWidget({id:"mark",options:{mark_tsUpdate:"markUpdate",mark_tsIgnore:{}},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 pagerComplete.tsmark"+(c?" "+c:""))}})}(jQuery);