From 0c7658893c2edfa7975c0d9971eab39a5bc6c244 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ansis=20K=C4=BCavi=C5=86=C5=A1?= Date: Sun, 4 Oct 2015 18:06:07 +0300 Subject: [PATCH] Update widget-math.js Created new calculation type "below". It works just like "above" except in other direction starting from top to bottom. --- js/widgets/widget-math.js | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/js/widgets/widget-math.js b/js/widgets/widget-math.js index d28edae2..8684b32f 100644 --- a/js/widgets/widget-math.js +++ b/js/widgets/widget-math.js @@ -86,6 +86,27 @@ } index--; } + } else if (type === 'below') { + + len = $rows.length; + // index + 1 to ignore starting node + for (index = $rows.index( $row ) + 1; index < len; index++ ) { + + $t = $rows.eq( index ).children().filter( '[data-column=' + cIndex + ']' ); + + if ($t.filter( '[' + wo.math_dataAttrib + '^=below]' ).length) + break; + + if ( ( !$rows.eq( index ).hasClass( filtered ) && + $rows.eq( index ).not( '[' + wo.math_dataAttrib + '=ignore]' ).length)) { + + if ( $t.length ) { + arry.push( math.processText( c, $t ) ); + } + } + + } + } else { $mathRows = $rows.not( '[' + wo.math_dataAttrib + '=ignore]' ); // .each(function(){ len = $mathRows.length; @@ -436,7 +457,7 @@ // complete executed after each fucntion math_complete : null, // function($cell, wo, result, value, arry){ return result; }, // order of calculation; 'all' is last - math_priority : [ 'row', 'above', 'col' ], + math_priority : [ 'row', 'above', 'below', 'col' ], // template for or just prepend the mask prefix & suffix with this HTML // e.g. '{content}' math_prefix : '',