Math: add math_event option

This commit is contained in:
Mottie 2015-02-09 16:57:08 -06:00
parent 9993d77f38
commit 1de9c46e30
3 changed files with 16 additions and 6 deletions

View File

@ -176,6 +176,7 @@
<h3><a href="#">Notes</a></h3>
<div>
<ul>
<li>In <span class="version">v2.19.1</span>, added <code>math_event</code> option &amp; fixed an issue with event unbinding in jQuery version &lt; 1.9.</li>
<li>In <span class="version">v2.17.1</span>,
<ul>
<li>Values added to the data-attribute set by the <a href="../#textattribute"><code>textAttribute</code> option</a> will now be used in the calculation instead of the actual cell content.</li>
@ -223,6 +224,14 @@
</td>
</tr>
<tr id="math_event">
<td><span class="permalink">math_event</span></td>
<td><code>'recalculate'</code></td>
<td>
Set this option change the name of the event that the widget listens for to perform an update.
</td>
</tr>
<tr id="math_ignore">
<td><a href="#" class="permalink">math_ignore</a></td>
<td><code>[ ]</code></td>

View File

@ -494,7 +494,7 @@
</ul>
</li>
<li><a href="example-widget-header-titles.html">Header titles widget</a> (v2.15.6; <span class="version updated">2.15.7</span>)</li>
<li><a href="example-widget-math.html">Math widget</a> (<span class="version">v2.16</span>; <span class="version updated">v2.19.0</span>).</li>
<li><a href="example-widget-math.html">Math widget</a> (<span class="version">v2.16</span>; <span class="version updated">v2.19.1</span>).</li>
<li>
<a href="example-widget-output.html">Output widget</a> (<span class="version">v2.16</span>; <span class="version updated">v2.19.0</span>)
<br><br>

View File

@ -12,7 +12,7 @@
math = {
events : ( 'tablesorter-initialized update updateAll updateRows addRows updateCell ' +
'filterReset filterEnd recalculate ' ).split(' ').join('.tsmath '),
'filterReset filterEnd ' ).split(' ').join('.tsmath '),
// get all of the row numerical values in an arry
getRow : function(table, wo, $el, dataAttrib) {
@ -388,12 +388,13 @@
// template for or just prepend the mask prefix & suffix with this HTML
// e.g. '<span class="red">{content}</span>'
math_prefix : '',
math_suffix : ''
math_suffix : '',
math_event : 'recalculate'
},
init : function(table, thisWidget, c, wo){
c.$table
.off( $.trim(math.events) + ' updateComplete.tsmath' )
.on( $.trim(math.events), function(e){
.off( $.trim(math.events) + ' ' + $.trim('updateComplete.tsmath ' + wo.math_event) )
.on( $.trim(math.events) + ' ' + wo.math_event, function(e){
var init = e.type === 'tablesorter-initialized';
if (e.type === 'updateAll') {
// redo data-column indexes in case columns were rearranged
@ -414,7 +415,7 @@
remove: function(table, c, wo, refreshing){
if (refreshing) { return; }
$(table)
.off( $trim(math.events) + ' updateComplete.tsmath' )
.off( $trim(math.events) + ' ' + $.trim('updateComplete.tsmath ' + wo.math_event) )
.find('[data-' + wo.math_data + ']').empty();
}
});