mirror of
https://github.com/Mottie/tablesorter.git
synced 2025-01-12 15:24:21 +00:00
Parser: remove unused variables & add ignoreChildRow option
This commit is contained in:
parent
a23e12af1f
commit
91eb28d7f2
@ -2224,6 +2224,25 @@ $(function(){
|
|||||||
<td><a href="example-parsers-globalize.html">2</a> <a href="example-parsers-dates.html">2</a></td>
|
<td><a href="example-parsers-globalize.html">2</a> <a href="example-parsers-dates.html">2</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
<tr id="ignorechildrow">
|
||||||
|
<td><a href="#" class="permalink">ignoreChildRow</a></td>
|
||||||
|
<td>Boolean</td>
|
||||||
|
<td>false</td>
|
||||||
|
<td>
|
||||||
|
Used by the input-select parser indicate if changes to child row content is to be ignored (<span class="version">v2.28.10</span>)
|
||||||
|
<div class="collapsible"><br>
|
||||||
|
Change this setting to ignore input, textarea and select changes inside of child rows:
|
||||||
|
<pre class="prettyprint lang-js">$(function(){
|
||||||
|
$('table').tablesorter({
|
||||||
|
ignoreChildRow : true
|
||||||
|
});
|
||||||
|
});</pre>
|
||||||
|
See <a href="https://github.com/Mottie/tablesorter/pull/1399">pull request #1399</a> for more information.
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
<tr id="imgattr">
|
<tr id="imgattr">
|
||||||
<td><a href="#" class="permalink">imgAttr</a></td>
|
<td><a href="#" class="permalink">imgAttr</a></td>
|
||||||
<td>String</td>
|
<td>String</td>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/*! Parser: input & select - updated 11/26/2016 (v2.28.0) *//*
|
/*! Parser: input & select - updated 5/12/2017 (v2.28.10) *//*
|
||||||
* for jQuery 1.7+ & tablesorter 2.7.11+
|
* for jQuery 1.7+ & tablesorter 2.7.11+
|
||||||
* Demo: http://mottie.github.com/tablesorter/docs/example-widget-grouping.html
|
* Demo: http://mottie.github.com/tablesorter/docs/example-widget-grouping.html
|
||||||
*/
|
*/
|
||||||
@ -165,23 +165,17 @@
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.on( 'focus' + namespace, 'select, input:not([type=checkbox]), textarea', function( event ) {
|
.on( 'focus' + namespace, 'select, input:not([type=checkbox]), textarea', function( event ) {
|
||||||
var $target = $( event.target ),
|
var $row = $( event.target ).closest( 'tr' ),
|
||||||
$cell = $target.closest( 'td' ),
|
c = $row.closest( 'table' )[0].config;
|
||||||
$row = $cell.closest( 'tr '),
|
if ( !c || c && c.ignoreChildRow && $row.hasClass( c.cssChildRow ) ) {
|
||||||
$table = $row.closest( 'table' ),
|
|
||||||
c = $table[ 0 ].config || false;
|
|
||||||
if ($row.hasClass(c.cssChildRow)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$( this ).data( 'ts-original-value', this.value );
|
$( this ).data( 'ts-original-value', this.value );
|
||||||
})
|
})
|
||||||
.on( 'blur' + namespace, 'input:not([type=checkbox]), textarea', function( event ) {
|
.on( 'blur' + namespace, 'input:not([type=checkbox]), textarea', function( event ) {
|
||||||
var $target = $( event.target ),
|
var $row = $( event.target ).closest( 'tr' ),
|
||||||
$cell = $target.closest( 'td' ),
|
c = $row.closest( 'table' )[0].config;
|
||||||
$row = $cell.closest( 'tr '),
|
if ( !c || c && c.ignoreChildRow && $row.hasClass( c.cssChildRow ) ) {
|
||||||
$table = $row.closest( 'table' ),
|
|
||||||
c = $table[ 0 ].config || false;
|
|
||||||
if ($row.hasClass(c.cssChildRow)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// restore input value;
|
// restore input value;
|
||||||
@ -189,12 +183,9 @@
|
|||||||
this.value = $( this ).data( 'ts-original-value' );
|
this.value = $( this ).data( 'ts-original-value' );
|
||||||
})
|
})
|
||||||
.on( 'change keyup '.split( ' ' ).join( namespace + ' ' ), 'select, input, textarea', function( event ) {
|
.on( 'change keyup '.split( ' ' ).join( namespace + ' ' ), 'select, input, textarea', function( event ) {
|
||||||
var $target = $( event.target ),
|
var $row = $( this ).closest( 'tr' ),
|
||||||
$cell = $target.closest( 'td' ),
|
c = $row.closest( 'table' )[0].config;
|
||||||
$row = $cell.closest( 'tr '),
|
if ( !c || c && c.ignoreChildRow && $row.hasClass( c.cssChildRow ) ) {
|
||||||
$table = $row.closest( 'table' ),
|
|
||||||
c = $table[ 0 ].config || false;
|
|
||||||
if ($row.hasClass(c.cssChildRow)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ( event.which === 27 && !( this.nodeName === 'INPUT' && this.type === 'checkbox' ) ) {
|
if ( event.which === 27 && !( this.nodeName === 'INPUT' && this.type === 'checkbox' ) ) {
|
||||||
@ -210,11 +201,9 @@
|
|||||||
$target = $( event.target ),
|
$target = $( event.target ),
|
||||||
isCheckbox = event.target.type === 'checkbox',
|
isCheckbox = event.target.type === 'checkbox',
|
||||||
$cell = $target.closest( 'td' ),
|
$cell = $target.closest( 'td' ),
|
||||||
$table = $cell.closest( 'table' ),
|
|
||||||
indx = $cell[ 0 ].cellIndex,
|
indx = $cell[ 0 ].cellIndex,
|
||||||
c = $table[ 0 ].config || false,
|
busy = c.table.tablesorterBusy,
|
||||||
busy = $table.length && $table[ 0 ].tablesorterBusy,
|
$hdr = c.$headerIndexed && c.$headerIndexed[ indx ] || [],
|
||||||
$hdr = c && c.$headerIndexed && c.$headerIndexed[ indx ] || [],
|
|
||||||
val = isCheckbox ? event.target.checked : $target.val();
|
val = isCheckbox ? event.target.checked : $target.val();
|
||||||
// abort if not a tablesorter table, or busy
|
// abort if not a tablesorter table, or busy
|
||||||
if ( $.isEmptyObject( c ) || busy !== false ) {
|
if ( $.isEmptyObject( c ) || busy !== false ) {
|
||||||
@ -223,7 +212,7 @@
|
|||||||
if ( isCheckbox ) {
|
if ( isCheckbox ) {
|
||||||
checkboxClass = c.checkboxClass || 'checked';
|
checkboxClass = c.checkboxClass || 'checked';
|
||||||
toggleRowClass( $cell.closest( 'tr' ), checkboxClass, indx, val );
|
toggleRowClass( $cell.closest( 'tr' ), checkboxClass, indx, val );
|
||||||
updateHeaderCheckbox( $table, checkboxClass );
|
updateHeaderCheckbox( c.$table, checkboxClass );
|
||||||
}
|
}
|
||||||
// don't use updateCell if column is set to 'sorter-false' and 'filter-false',
|
// don't use updateCell if column is set to 'sorter-false' and 'filter-false',
|
||||||
// or column is set to 'parser-false'
|
// or column is set to 'parser-false'
|
||||||
@ -236,11 +225,11 @@
|
|||||||
// ignore change event if nothing changed
|
// ignore change event if nothing changed
|
||||||
if ( c && val !== $target.data( 'ts-original-value' ) || isCheckbox ) {
|
if ( c && val !== $target.data( 'ts-original-value' ) || isCheckbox ) {
|
||||||
$target.data( 'ts-original-value', val );
|
$target.data( 'ts-original-value', val );
|
||||||
$table[ 0 ].tablesorterBusy = true;
|
c.table.tablesorterBusy = true;
|
||||||
// pass undefined resort value so it falls back to config.resort setting
|
// pass undefined resort value so it falls back to config.resort setting
|
||||||
$.tablesorter.updateCell( c, $cell, undef, function() {
|
$.tablesorter.updateCell( c, $cell, undef, function() {
|
||||||
updateServer( event, $table, $target );
|
updateServer( event, c.$table, $target );
|
||||||
$table[ 0 ].tablesorterBusy = false;
|
c.table.tablesorterBusy = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user