-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfront-script.js
More file actions
53 lines (42 loc) · 1.4 KB
/
Copy pathfront-script.js
File metadata and controls
53 lines (42 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// highlight hovered cols and rows
jQuery( document ).ready( function() {
jQuery("table.table_field").delegate('td','mouseover mouseleave', function(e) {
if (e.type == 'mouseover') {
jQuery(this).parent().addClass("hover");
jQuery("colgroup").eq(jQuery(this).index()).addClass("hover");
}
else {
jQuery(this).parent().removeClass("hover");
jQuery("colgroup").eq(jQuery(this).index()).removeClass("hover");
}
});
function registerComposeValueTriggers() {
jQuery( '.table_field' ).each( function( i, object ) {
var table = object;
composeValue( table );
jQuery( 'input', table ).each( function( i, v ) {
console.log( v );
});
jQuery( 'input', table ).on( 'keyup', function() {
console.log( 'keyup' );
composeValue( table );
});
});
}
function composeValue( table ) {
var prevIndex = -1;
var tableValuesMatrix = new Array();
jQuery( 'input[data-type="table-cell"]', table ).each( function( i, cell ) {
cell = jQuery( cell );
var col = cell.attr( 'data-col' );
var row = cell.attr( 'data-row' );
if( row != prevIndex ) {
tableValuesMatrix.push( new Array() );
prevIndex = row;
}
tableValuesMatrix[ prevIndex ].push( cell.val() );
});
jQuery( '.composedTableValue', table ).val( JSON.stringify( tableValuesMatrix ) );
}
registerComposeValueTriggers();
});