mirror of
https://github.com/Mottie/tablesorter.git
synced 2025-01-12 15:24:21 +00:00
Math: add math_debug option
This commit is contained in:
parent
83b38fd419
commit
148a699e72
2
dist/js/widgets/widget-math.min.js
vendored
2
dist/js/widgets/widget-math.min.js
vendored
File diff suppressed because one or more lines are too long
@ -199,6 +199,7 @@
|
||||
<li>In <span class="version">v2.27.0</span>
|
||||
<ul>
|
||||
<li>Added check for <code>data-math-target</code> attribute which allows you to target an element inside the table cell. See the <a href="#attribute_settings">Attribute Settings</a> > <strong>Targeting cell content</strong> section below.</li>
|
||||
<li>Added a <code>math_debug</code> option which when <code>true</code>, enables debug logging of only the math widget.</li>
|
||||
<li>The math widget no longer uses "update" after recalculating cell values. Instead it uses "updateCache" to remove the need to resort and update the other widgets.</li>
|
||||
</ul>
|
||||
</li>
|
||||
@ -288,6 +289,14 @@
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr id="math_debug">
|
||||
<td><span class="permalink">math_debug</span></td>
|
||||
<td><code>false</code></td>
|
||||
<td>
|
||||
Set this option to <code>true</code> to enable the debug log of the math widget without all the extra noise from the overall <a href="index.html#debug"><code>debug</code></a> option (<span class="version">v2.27.0</span>).
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr id="math_event">
|
||||
<td><a href="#" class="permalink">math_event</a></td>
|
||||
<td><code>'recalculate'</code></td>
|
||||
|
@ -216,7 +216,7 @@
|
||||
var undef, time, mathAttr, $mathCells, indx, len,
|
||||
changed = false,
|
||||
filters = {};
|
||||
if ( c.debug ) {
|
||||
if ( c.debug || wo.math_debug ) {
|
||||
time = new Date();
|
||||
}
|
||||
|
||||
@ -256,7 +256,7 @@
|
||||
// trigger an update only if cells inside the tbody changed
|
||||
if ( changed ) {
|
||||
wo.math_isUpdating = true;
|
||||
if ( c.debug ) {
|
||||
if ( c.debug || wo.math_debug ) {
|
||||
console[ console.group ? 'group' : 'log' ]( 'Math widget updating the cache after recalculation' );
|
||||
}
|
||||
|
||||
@ -266,7 +266,7 @@
|
||||
if ( !init && typeof wo.math_completed === 'function' ) {
|
||||
wo.math_completed( c );
|
||||
}
|
||||
if ( c.debug ) {
|
||||
if ( c.debug || wo.math_debug ) {
|
||||
console.log( 'Math widget update completed' + ts.benchmark( time ) );
|
||||
}
|
||||
});
|
||||
@ -274,7 +274,7 @@
|
||||
if ( !init && typeof wo.math_completed === 'function' ) {
|
||||
wo.math_completed( c );
|
||||
}
|
||||
if ( c.debug ) {
|
||||
if ( c.debug || wo.math_debug ) {
|
||||
console.log( 'Math widget found no changes in data' + ts.benchmark( time ) );
|
||||
}
|
||||
}
|
||||
@ -283,7 +283,9 @@
|
||||
|
||||
updateComplete : function( c ) {
|
||||
var wo = c.widgetOptions;
|
||||
if ( wo.math_isUpdating && c.debug && console.groupEnd ) { console.groupEnd(); }
|
||||
if ( wo.math_isUpdating && (c.debug || wo.math_debug ) && console.groupEnd ) {
|
||||
console.groupEnd();
|
||||
}
|
||||
wo.math_isUpdating = false;
|
||||
},
|
||||
|
||||
@ -298,7 +300,7 @@
|
||||
// mathType is called multiple times if more than one "hasFilter" is used
|
||||
getAll = math.getAll( c, hasFilter );
|
||||
}
|
||||
if (c.debug) {
|
||||
if (c.debug || wo.math_debug) {
|
||||
console[ console.group ? 'group' : 'log' ]( 'Tablesorter Math widget recalculation' );
|
||||
}
|
||||
// $.each is okay here... only 4 priorities
|
||||
@ -307,7 +309,7 @@
|
||||
$targetCells = $cells.filter( '[' + mathAttr + '^=' + type + ']' ),
|
||||
len = $targetCells.length;
|
||||
if ( len ) {
|
||||
if (c.debug) {
|
||||
if (c.debug || wo.math_debug) {
|
||||
console[ console.group ? 'group' : 'log' ]( type );
|
||||
}
|
||||
for ( index = 0; index < len; index++ ) {
|
||||
@ -323,7 +325,7 @@
|
||||
if ( equations[ formula ] ) {
|
||||
if ( arry.length ) {
|
||||
result = equations[ formula ]( arry, c );
|
||||
if ( c.debug ) {
|
||||
if ( c.debug || wo.math_debug ) {
|
||||
console.log( $el.attr( mathAttr ), hasFilter ? '("' + hasFilter + '")' : '', arry, '=', result );
|
||||
}
|
||||
} else {
|
||||
@ -333,10 +335,10 @@
|
||||
changed = math.output( $el, c, result, arry ) || changed;
|
||||
}
|
||||
}
|
||||
if ( c.debug && console.groupEnd ) { console.groupEnd(); }
|
||||
if ( ( c.debug || wo.math_debug ) && console.groupEnd ) { console.groupEnd(); }
|
||||
}
|
||||
});
|
||||
if ( c.debug && console.groupEnd ) { console.groupEnd(); }
|
||||
if ( ( c.debug || wo.math_debug ) && console.groupEnd ) { console.groupEnd(); }
|
||||
return changed;
|
||||
}
|
||||
return false;
|
||||
@ -589,6 +591,7 @@
|
||||
priority: 100,
|
||||
options: {
|
||||
math_data : 'math',
|
||||
math_debug : false,
|
||||
// column index to ignore
|
||||
math_ignore : [],
|
||||
// mask info: https://code.google.com/p/javascript-number-formatter/
|
||||
|
Loading…
Reference in New Issue
Block a user