mirror of
https://gitea.baerentsen.space/FrederikBaerentsen/BrickTracker.git
synced 2026-01-01 14:20:13 -06:00
30 lines
741 B
JavaScript
30 lines
741 B
JavaScript
// Grid class
|
|
class BrickGrid {
|
|
constructor(grid, target = "div#grid>div") {
|
|
this.id = grid.id;
|
|
this.target = target;
|
|
|
|
// Grid elements (built based on the initial id)
|
|
this.html_grid = document.getElementById(this.id);
|
|
|
|
if (this.html_grid) {
|
|
// Sort setup
|
|
this.sort = new BrickGridSort(this);
|
|
|
|
// Filter setup
|
|
this.filter = new BrickGridFilter(this);
|
|
}
|
|
}
|
|
}
|
|
|
|
// Global grid instances storage
|
|
window.gridInstances = {};
|
|
|
|
// Helper to setup the grids
|
|
const setup_grids = () => document.querySelectorAll('*[data-grid="true"]').forEach(
|
|
el => {
|
|
const grid = new BrickGrid(el);
|
|
window.gridInstances[el.id] = grid;
|
|
}
|
|
);
|