diff --git a/demo/events.js b/demo/events.js index d32bbeb7..bca7ae3f 100644 --- a/demo/events.js +++ b/demo/events.js @@ -1,59 +1,59 @@ function addEvents(grid, id) { - let g = (id !== undefined ? 'grid' + id + ' ' : ''); + let g = (id !== undefined ? 'grid' + id : ''); grid.on('added removed change', function(event, items) { let str = ''; items.forEach(function(item) { str += ' (' + item.x + ',' + item.y + ' ' + item.w + 'x' + item.h + ')'; }); - console.log(g + event.type + ' ' + items.length + ' items (x,y w h):' + str ); + console.log((g || items[0].grid.opts.id) + ' ' + event.type + ' ' + items.length + ' items (x,y w h):' + str ); }) .on('enable', function(event) { - let grid = event.target; - console.log(g + 'enable'); + let el = event.target; + console.log((g || el.gridstackNode.grid.opts.id) + ' enable'); }) .on('disable', function(event) { - let grid = event.target; - console.log(g + 'disable'); + let el = event.target; + console.log((g || el.gridstackNode.grid.opts.id) + ' disable'); }) .on('dragstart', function(event, el) { let n = el.gridstackNode; let x = el.getAttribute('gs-x'); // verify node (easiest) and attr are the same let y = el.getAttribute('gs-y'); - console.log(g + 'dragstart ' + (n.content || '') + ' pos: (' + n.x + ',' + n.y + ') = (' + x + ',' + y + ')'); + console.log((g || el.gridstackNode.grid.opts.id) + ' dragstart ' + (n.content || '') + ' pos: (' + n.x + ',' + n.y + ') = (' + x + ',' + y + ')'); }) .on('drag', function(event, el) { let n = el.gridstackNode; let x = el.getAttribute('gs-x'); // verify node (easiest) and attr are the same let y = el.getAttribute('gs-y'); - // console.log(g + 'drag ' + (n.content || '') + ' pos: (' + n.x + ',' + n.y + ') = (' + x + ',' + y + ')'); + // console.log((g || el.gridstackNode.grid.opts.id) + ' drag ' + (n.content || '') + ' pos: (' + n.x + ',' + n.y + ') = (' + x + ',' + y + ')'); }) .on('dragstop', function(event, el) { let n = el.gridstackNode; let x = el.getAttribute('gs-x'); // verify node (easiest) and attr are the same let y = el.getAttribute('gs-y'); - console.log(g + 'dragstop ' + (n.content || '') + ' pos: (' + n.x + ',' + n.y + ') = (' + x + ',' + y + ')'); + console.log((g || el.gridstackNode.grid.opts.id) + ' dragstop ' + (n.content || '') + ' pos: (' + n.x + ',' + n.y + ') = (' + x + ',' + y + ')'); }) .on('dropped', function(event, previousNode, newNode) { if (previousNode) { - console.log(g + 'dropped - Removed widget from grid:', previousNode); + console.log((g || previousNode.grid.opts.id) + ' dropped - Removed widget from grid:', previousNode); } if (newNode) { - console.log(g + 'dropped - Added widget in grid:', newNode); + console.log((g || newNode.grid.opts.id) + ' dropped - Added widget in grid:', newNode); } }) .on('resizestart', function(event, el) { let n = el.gridstackNode; let rec = el.getBoundingClientRect(); - console.log(`${g} resizestart ${n.content || ''} size: (${n.w}x${n.h}) = (${Math.round(rec.width)}x${Math.round(rec.height)})px`); + console.log(`${g || el.gridstackNode.grid.opts.id} resizestart ${n.content || ''} size: (${n.w}x${n.h}) = (${Math.round(rec.width)}x${Math.round(rec.height)})px`); }) .on('resize', function(event, el) { let n = el.gridstackNode; let rec = el.getBoundingClientRect(); - console.log(`${g} resize ${n.content || ''} size: (${n.w}x${n.h}) = (${Math.round(rec.width)}x${Math.round(rec.height)})px`); + console.log(`${g || el.gridstackNode.grid.opts.id} resize ${n.content || ''} size: (${n.w}x${n.h}) = (${Math.round(rec.width)}x${Math.round(rec.height)})px`); }) .on('resizestop', function(event, el) { let n = el.gridstackNode; let rec = el.getBoundingClientRect(); - console.log(`${g} resizestop ${n.content || ''} size: (${n.w}x${n.h}) = (${Math.round(rec.width)}x${Math.round(rec.height)})px`); + console.log(`${g || el.gridstackNode.grid.opts.id} resizestop ${n.content || ''} size: (${n.w}x${n.h}) = (${Math.round(rec.width)}x${Math.round(rec.height)})px`); }); } \ No newline at end of file diff --git a/demo/nested.html b/demo/nested.html index 2f80b9e7..d8a099c7 100644 --- a/demo/nested.html +++ b/demo/nested.html @@ -40,7 +40,7 @@

Nested grids demo

Load

- d +