otsdaq_utilities  v2_05_02_indev
resize_table.js
1 /* Tabulator v4.5.3 (c) Oliver Folkerd */
2 
3 var ResizeTable = function ResizeTable(table) {
4  this.table = table; //hold Tabulator object
5  this.binding = false;
6  this.observer = false;
7 };
8 
9 ResizeTable.prototype.initialize = function (row) {
10  var table = this.table,
11  observer;
12 
13  if (typeof ResizeObserver !== "undefined" && table.rowManager.getRenderMode() === "virtual") {
14  this.observer = new ResizeObserver(function (entry) {
15  if (!table.browserMobile || table.browserMobile && !table.modules.edit.currentCell) {
16  table.redraw();
17  }
18  });
19 
20  this.observer.observe(table.element);
21  } else {
22  this.binding = function () {
23  if (!table.browserMobile || table.browserMobile && !table.modules.edit.currentCell) {
24  table.redraw();
25  }
26  };
27 
28  window.addEventListener("resize", this.binding);
29  }
30 };
31 
32 ResizeTable.prototype.clearBindings = function (row) {
33  if (this.binding) {
34  window.removeEventListener("resize", this.binding);
35  }
36 
37  if (this.observer) {
38  this.observer.unobserve(this.table.element);
39  }
40 };
41 
42 Tabulator.prototype.registerModule("resizeTable", ResizeTable);