mirror of
https://github.com/Mottie/tablesorter.git
synced 2024-11-15 23:54:22 +00:00
Mark: Actually include options this time! See #1243
This commit is contained in:
parent
ee5879a7eb
commit
ff2d6e9c80
2
dist/js/widgets/widget-mark.min.js
vendored
2
dist/js/widgets/widget-mark.min.js
vendored
@ -1,2 +1,2 @@
|
||||
/*! Widget: mark.js - updated 7/31/2016 (v2.27.1) */
|
||||
!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=b.mark.regex,g=c.$table.find("tbody tr").unmark().not("."+(c.widgetOptions.filter_filteredRow||"filtered"));d=d||a.tablesorter.getFilters(c.$table),a.each(d,function(a,d){if(d){var h=null,i=d,j=!1,k=a===c.columns?"":":nth-child("+(a+1)+")";if(f.pure.test(d)){i=f.pure.exec(d),".*"===i[1]&&(i[1]="");try{h=new RegExp(i[1],"gim"),i=new RegExp(i[1],i[2])}catch(a){i=null}return void(b.mark.checkRegex(h)&&g.children(k).markRegExp(i,e))}0===d.indexOf("~")?(j=!0,i=d.replace(/~/g,"").split("")):(d.indexOf("?")>-1&&(j=!0,d=d.replace(/\?/g,"\\S{1}")),d.indexOf("*")>-1&&(j=!0,d=d.replace(/\*/g,"\\S*")),i=d.split(f.filter)),j&&i&&i.length?(i=new RegExp(b.mark.cleanMatches(i).join(".*"),"gim"),b.mark.checkRegex(i)&&g.children(k).markRegExp(i,e)):g.children(k).mark(b.mark.cleanMatches(i),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);
|
||||
!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);
|
@ -42,9 +42,9 @@ tr td:nth-child(6) mark { background: #aa00aa; color: #fff; }
|
||||
// sort & filter diacritics
|
||||
sortLocaleCompare: true,
|
||||
widgets: ['zebra', 'filter', 'mark'],
|
||||
widgetOptions : {
|
||||
filter_external : 'input[name="keyword"]',
|
||||
filter_reset : 'button.reset',
|
||||
widgetOptions: {
|
||||
filter_external: 'input[name="keyword"]',
|
||||
filter_reset: 'button.reset',
|
||||
|
||||
// default settings
|
||||
mark_accuracy: 'partially',
|
||||
|
@ -51,6 +51,8 @@
|
||||
},
|
||||
update : function( c, filters ) {
|
||||
var options = {},
|
||||
wo = c.widgetOptions,
|
||||
setIgnoreCase = typeof wo.filter_ignoreCase === 'undefined' ? true : wo.filter_ignoreCase,
|
||||
regex = ts.mark.regex,
|
||||
$rows = c.$table
|
||||
.find( 'tbody tr' )
|
||||
@ -59,6 +61,12 @@
|
||||
filters = filters || $.tablesorter.getFilters( c.$table );
|
||||
// extract & save mark options from widgetOptions (prefixed with "mark_")
|
||||
// update dynamically
|
||||
$.each( c.widgetOptions, function( key, val ) {
|
||||
var matches = key.match( regex.mark );
|
||||
if ( matches && typeof matches[1] !== 'undefined' ) {
|
||||
options[ matches[1] ] = val;
|
||||
}
|
||||
});
|
||||
$.each( filters, function( indx, filter ) {
|
||||
if ( filter ) {
|
||||
var testRegex = null,
|
||||
@ -105,7 +113,10 @@
|
||||
matches = filter.split( regex.filter );
|
||||
}
|
||||
if ( useRegex && matches && matches.length ) {
|
||||
matches = new RegExp( ts.mark.cleanMatches( matches ).join( '.*' ), 'gim' );
|
||||
matches = new RegExp(
|
||||
ts.mark.cleanMatches( matches ).join( '.*' ),
|
||||
'gm' + ( setIgnoreCase ? 'i' : '' )
|
||||
);
|
||||
if ( ts.mark.checkRegex( matches ) ) {
|
||||
$rows.children( col ).markRegExp( matches, options );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user