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