mirror of
https://github.com/Mottie/tablesorter.git
synced 2024-11-15 23:54:22 +00:00
Mark: Remove internal case matching
This commit is contained in:
parent
adb5ea45af
commit
f9dcd05b1f
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 9/1/2016 (v2.27.6) */
|
||||
!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="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(d,j){if(j&&!a(c.$headerIndexed[d]).hasClass("mark-ignore")&&!f.mark_tsIgnore[d]){var k=null,l=j,m=!1,n=d===c.columns?b.mark.ignoreColumns(c):":nth-child("+(d+1)+")";if(h.pure.test(j)){l=h.pure.exec(j),".*"===l[1]&&(l[1]="");try{k=new RegExp(l[1],"gim"),l=new RegExp(l[1],l[2])}catch(a){l=null}return void(b.mark.checkRegex(k)&&i.children(n).markRegExp(l,e))}0===j.indexOf("~")?(m=!0,l=j.replace(/~/g,"").split("")):(j.indexOf("?")>-1&&(m=!0,j=j.replace(/\?/g,"\\S{1}")),j.indexOf("*")>-1&&(m=!0,j=j.replace(/\*/g,"\\S*")),l=j.split(h.filter)),m&&l&&l.length?(l=new RegExp(b.mark.cleanMatches(l).join(".*"),"gm"+(g?"i":"")),b.mark.checkRegex(l)&&i.children(n).markRegExp(l,e)):i.children(n).mark(b.mark.cleanMatches(l),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);
|
||||
!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);
|
@ -11,9 +11,11 @@
|
||||
<link class="ui-theme" rel="stylesheet" href="css/jquery-ui.min.css">
|
||||
<script src="js/jquery-ui.min.js"></script>
|
||||
<link rel="stylesheet" href="css/jq.css">
|
||||
<link href="css/tipsy.css" rel="stylesheet">
|
||||
<link href="css/prettify.css" rel="stylesheet">
|
||||
<script src="js/prettify.js"></script>
|
||||
<script src="js/docs.js"></script>
|
||||
<script src="js/jquery.tipsy.min.js"></script>
|
||||
|
||||
<!-- Tablesorter: required -->
|
||||
<link rel="stylesheet" href="../css/theme.blue.css">
|
||||
@ -32,7 +34,7 @@ th.tablesorter-header.ignore, .ignore { background-color: #e6bf99; }
|
||||
<script src="../js/jquery.tablesorter.js"></script>
|
||||
<script src="../js/widgets/widget-filter.js"></script>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mark.js/8.0.0/jquery.mark.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mark.js/8.1.1/jquery.mark.js"></script>
|
||||
<script src="../js/widgets/widget-mark.js"></script>
|
||||
|
||||
<script id="js">$(function() {
|
||||
@ -58,6 +60,7 @@ th.tablesorter-header.ignore, .ignore { background-color: #e6bf99; }
|
||||
},
|
||||
// *** default settings for non-regular expression searches only
|
||||
mark_accuracy: 'partially',
|
||||
mark_caseSensitive: false,
|
||||
mark_diacritics: true,
|
||||
mark_separateWordSearch: true,
|
||||
mark_synonyms: {},
|
||||
@ -83,10 +86,12 @@ th.tablesorter-header.ignore, .ignore { background-color: #e6bf99; }
|
||||
// preset searches for the first table
|
||||
$('button[data-filter-column]').click(function(){
|
||||
var filters = [],
|
||||
config = $table[0].config,
|
||||
$t = $(this),
|
||||
col = $t.data('filter-column'), // zero-based index, or "all" column
|
||||
txt = $t.data('filter-text') || $t.text(); // text to add to filter
|
||||
filters[col === "all" ? $table[0].config.columns : col] = txt;
|
||||
filters[col === "all" ? config.columns : col] = txt;
|
||||
config.widgetOptions.mark_caseSensitive = $t.data('mark-case') || false;
|
||||
$.tablesorter.setFilters( $table, filters );
|
||||
return false;
|
||||
});
|
||||
@ -113,22 +118,31 @@ th.tablesorter-header.ignore, .ignore { background-color: #e6bf99; }
|
||||
$('button.table2').click(function(){
|
||||
// check for reset
|
||||
var query = $(this).hasClass('reset2') ? '' : this.textContent;
|
||||
config = $table2[0].config;
|
||||
config.widgetOptions.mark_caseSensitive = $(this).data('mark-case') || false;
|
||||
$('#table2-search')
|
||||
.val(query)
|
||||
.trigger('input');
|
||||
});
|
||||
|
||||
$('#table2-search').on('input', function() {
|
||||
$('#table2-search').on('input', function(event) {
|
||||
var config = $table2[0].config,
|
||||
filters = [];
|
||||
// still target the "any" match column
|
||||
filters[config.columns] = this.value;
|
||||
// if input was not triggered by a button click, reset caseSensitive
|
||||
if (!event.isTrigger) {
|
||||
config.widgetOptions.mark_caseSensitive = false;
|
||||
}
|
||||
// trigger a mark update
|
||||
$table2.trigger('markUpdate', [filters]);
|
||||
// or call the function directly
|
||||
// $.tablesorter.mark.update(config, filters);
|
||||
});
|
||||
|
||||
// add tooltip
|
||||
$('.tooltip').tipsy({ gravity: 's' });
|
||||
|
||||
});</script>
|
||||
|
||||
</head>
|
||||
@ -148,6 +162,7 @@ th.tablesorter-header.ignore, .ignore { background-color: #e6bf99; }
|
||||
<h3 id="notes"><a href="#">Notes</a></h3>
|
||||
<div>
|
||||
<ul>
|
||||
<li>Updated <span class="verison">v2.27.7</span>, removed internal case matching as mark.js v8.1.1 now has a <code>caseSensitive</code> option (set using <code>mark_caseSensitive</code> widget option).</li>
|
||||
<li>Updated <span class="verison">v2.27.6</span>
|
||||
<ul>
|
||||
<li>The mark widget properly applies after a pager change has occured.</li>
|
||||
@ -285,6 +300,11 @@ $('button.update').click(function(){
|
||||
<td>"partially"</td>
|
||||
<td>Use "partially", "complementary", "exactly" or object - see markjs docs for details.</td>
|
||||
</tr>
|
||||
<tr id="mark-casesensitive">
|
||||
<td><span class="permalink">mark_caseSensitive</span></td>
|
||||
<td>false</td>
|
||||
<td>If <code>true</code>, only case sensitive marks are applied.</td>
|
||||
</tr>
|
||||
<tr id="mark-diacritics">
|
||||
<td><span class="permalink">mark_diacritics</span></td>
|
||||
<td>true</td>
|
||||
@ -362,8 +382,9 @@ $('button.update').click(function(){
|
||||
<button class="bad" type="button" data-filter-column="all" title="See "Notes" on why the second row isn't highlighted">~ee</button>
|
||||
<button type="button" data-filter-column="all">br?n</button>
|
||||
<button type="button" data-filter-column="all">br*n</button>
|
||||
<button type="button" data-filter-column="all">aaron|bruce</button>
|
||||
<button type="button" data-filter-column="all">aaron && 2</button>
|
||||
<button type="button" data-filter-column="all">aaron|bruce</button>
|
||||
<button type="button" class="sens tooltip" title="Case Sensitive Mark" data-filter-column="all" data-mark-case="true">aaron|Bruce</button>
|
||||
<table id="table" class="tablesorter">
|
||||
<thead>
|
||||
<tr>
|
||||
@ -401,8 +422,9 @@ $('button.update').click(function(){
|
||||
<button class="table2 bad" type="button" title="See "Notes" on why the "005 Bruce Almighty" row isn't highlighted">~ee</button>
|
||||
<button class="table2" type="button">br?n</button>
|
||||
<button class="table2" type="button">br*n</button>
|
||||
<button class="table2" type="button">aaron|bruce</button>
|
||||
<button class="table2" type="button">aaron && 2</button>
|
||||
<button class="table2" type="button">aaron|bruce</button>
|
||||
<button class="table2 sens tooltip" type="button" title="Case Sensitive Mark" data-filter-column="all" data-mark-case="true">aaron|Bruce</button>
|
||||
|
||||
<table id="table2" class="tablesorter">
|
||||
<thead>
|
||||
|
@ -70,8 +70,6 @@
|
||||
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' )
|
||||
@ -139,7 +137,7 @@
|
||||
if ( useRegex && matches && matches.length ) {
|
||||
matches = new RegExp(
|
||||
ts.mark.cleanMatches( matches ).join( '.*' ),
|
||||
'gm' + ( setIgnoreCase ? 'i' : '' )
|
||||
'gm'
|
||||
);
|
||||
if ( ts.mark.checkRegex( matches ) ) {
|
||||
$rows.children( col ).markRegExp( matches, options );
|
||||
|
Loading…
Reference in New Issue
Block a user