otsdaq_utilities  v2_05_02_indev
format.js
1 var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
2 
3 /* Tabulator v4.5.3 (c) Oliver Folkerd */
4 
5 var Format = function Format(table) {
6  this.table = table; //hold Tabulator object
7 };
8 
9 //initialize column formatter
10 Format.prototype.initializeColumn = function (column) {
11  var self = this,
12  config = { params: column.definition.formatterParams || {} };
13 
14  //set column formatter
15  switch (_typeof(column.definition.formatter)) {
16  case "string":
17 
18  if (column.definition.formatter === "tick") {
19  column.definition.formatter = "tickCross";
20 
21  if (typeof config.params.crossElement == "undefined") {
22  config.params.crossElement = false;
23  }
24 
25  console.warn("DEPRECATION WARNING - the tick formatter has been deprecated, please use the tickCross formatter with the crossElement param set to false");
26  }
27 
28  if (self.formatters[column.definition.formatter]) {
29  config.formatter = self.formatters[column.definition.formatter];
30  } else {
31  console.warn("Formatter Error - No such formatter found: ", column.definition.formatter);
32  config.formatter = self.formatters.plaintext;
33  }
34  break;
35 
36  case "function":
37  config.formatter = column.definition.formatter;
38  break;
39 
40  default:
41  config.formatter = self.formatters.plaintext;
42  break;
43  }
44 
45  column.modules.format = config;
46 };
47 
48 Format.prototype.cellRendered = function (cell) {
49  if (cell.modules.format && cell.modules.format.renderedCallback) {
50  cell.modules.format.renderedCallback();
51  }
52 };
53 
54 //return a formatted value for a cell
55 Format.prototype.formatValue = function (cell) {
56  var component = cell.getComponent(),
57  params = typeof cell.column.modules.format.params === "function" ? cell.column.modules.format.params(component) : cell.column.modules.format.params;
58 
59  function onRendered(callback) {
60  if (!cell.modules.format) {
61  cell.modules.format = {};
62  }
63 
64  cell.modules.format.renderedCallback = callback;
65  }
66 
67  return cell.column.modules.format.formatter.call(this, component, params, onRendered);
68 };
69 
70 Format.prototype.sanitizeHTML = function (value) {
71  if (value) {
72  var entityMap = {
73  '&': '&',
74  '<': '&lt;',
75  '>': '&gt;',
76  '"': '&quot;',
77  "'": '&#39;',
78  '/': '&#x2F;',
79  '`': '&#x60;',
80  '=': '&#x3D;'
81  };
82 
83  return String(value).replace(/[&<>"'`=\/]/g, function (s) {
84  return entityMap[s];
85  });
86  } else {
87  return value;
88  }
89 };
90 
91 Format.prototype.emptyToSpace = function (value) {
92  return value === null || typeof value === "undefined" ? "&nbsp;" : value;
93 };
94 
95 //get formatter for cell
96 Format.prototype.getFormatter = function (formatter) {
97  var formatter;
98 
99  switch (typeof formatter === "undefined" ? "undefined" : _typeof(formatter)) {
100  case "string":
101  if (this.formatters[formatter]) {
102  formatter = this.formatters[formatter];
103  } else {
104  console.warn("Formatter Error - No such formatter found: ", formatter);
105  formatter = this.formatters.plaintext;
106  }
107  break;
108 
109  case "function":
110  formatter = formatter;
111  break;
112 
113  default:
114  formatter = this.formatters.plaintext;
115  break;
116  }
117 
118  return formatter;
119 };
120 
121 //default data formatters
122 Format.prototype.formatters = {
123  //plain text value
124  plaintext: function plaintext(cell, formatterParams, onRendered) {
125  return this.emptyToSpace(this.sanitizeHTML(cell.getValue()));
126  },
127 
128  //html text value
129  html: function html(cell, formatterParams, onRendered) {
130  return cell.getValue();
131  },
132 
133  //multiline text area
134  textarea: function textarea(cell, formatterParams, onRendered) {
135  cell.getElement().style.whiteSpace = "pre-wrap";
136  return this.emptyToSpace(this.sanitizeHTML(cell.getValue()));
137  },
138 
139  //currency formatting
140  money: function money(cell, formatterParams, onRendered) {
141  var floatVal = parseFloat(cell.getValue()),
142  number,
143  integer,
144  decimal,
145  rgx;
146 
147  var decimalSym = formatterParams.decimal || ".";
148  var thousandSym = formatterParams.thousand || ",";
149  var symbol = formatterParams.symbol || "";
150  var after = !!formatterParams.symbolAfter;
151  var precision = typeof formatterParams.precision !== "undefined" ? formatterParams.precision : 2;
152 
153  if (isNaN(floatVal)) {
154  return this.emptyToSpace(this.sanitizeHTML(cell.getValue()));
155  }
156 
157  number = precision !== false ? floatVal.toFixed(precision) : floatVal;
158  number = String(number).split(".");
159 
160  integer = number[0];
161  decimal = number.length > 1 ? decimalSym + number[1] : "";
162 
163  rgx = /(\d+)(\d{3})/;
164 
165  while (rgx.test(integer)) {
166  integer = integer.replace(rgx, "$1" + thousandSym + "$2");
167  }
168 
169  return after ? integer + decimal + symbol : symbol + integer + decimal;
170  },
171 
172  //clickable anchor tag
173  link: function link(cell, formatterParams, onRendered) {
174  var value = cell.getValue(),
175  urlPrefix = formatterParams.urlPrefix || "",
176  download = formatterParams.download,
177  label = value,
178  el = document.createElement("a"),
179  data;
180 
181  if (formatterParams.labelField) {
182  data = cell.getData();
183  label = data[formatterParams.labelField];
184  }
185 
186  if (formatterParams.label) {
187  switch (_typeof(formatterParams.label)) {
188  case "string":
189  label = formatterParams.label;
190  break;
191 
192  case "function":
193  label = formatterParams.label(cell);
194  break;
195  }
196  }
197 
198  if (label) {
199  if (formatterParams.urlField) {
200  data = cell.getData();
201  value = data[formatterParams.urlField];
202  }
203 
204  if (formatterParams.url) {
205  switch (_typeof(formatterParams.url)) {
206  case "string":
207  value = formatterParams.url;
208  break;
209 
210  case "function":
211  value = formatterParams.url(cell);
212  break;
213  }
214  }
215 
216  el.setAttribute("href", urlPrefix + value);
217 
218  if (formatterParams.target) {
219  el.setAttribute("target", formatterParams.target);
220  }
221 
222  if (formatterParams.download) {
223 
224  if (typeof download == "function") {
225  download = download(cell);
226  } else {
227  download = download === true ? "" : download;
228  }
229 
230  el.setAttribute("download", download);
231  }
232 
233  el.innerHTML = this.emptyToSpace(this.sanitizeHTML(label));
234 
235  return el;
236  } else {
237  return "&nbsp;";
238  }
239  },
240 
241  //image element
242  image: function image(cell, formatterParams, onRendered) {
243  var el = document.createElement("img");
244  el.setAttribute("src", cell.getValue());
245 
246  switch (_typeof(formatterParams.height)) {
247  case "number":
248  el.style.height = formatterParams.height + "px";
249  break;
250 
251  case "string":
252  el.style.height = formatterParams.height;
253  break;
254  }
255 
256  switch (_typeof(formatterParams.width)) {
257  case "number":
258  el.style.width = formatterParams.width + "px";
259  break;
260 
261  case "string":
262  el.style.width = formatterParams.width;
263  break;
264  }
265 
266  el.addEventListener("load", function () {
267  cell.getRow().normalizeHeight();
268  });
269 
270  return el;
271  },
272 
273  //tick or cross
274  tickCross: function tickCross(cell, formatterParams, onRendered) {
275  var value = cell.getValue(),
276  element = cell.getElement(),
277  empty = formatterParams.allowEmpty,
278  truthy = formatterParams.allowTruthy,
279  tick = typeof formatterParams.tickElement !== "undefined" ? formatterParams.tickElement : '<svg enable-background="new 0 0 24 24" height="14" width="14" viewBox="0 0 24 24" xml:space="preserve" ><path fill="#2DC214" clip-rule="evenodd" d="M21.652,3.211c-0.293-0.295-0.77-0.295-1.061,0L9.41,14.34 c-0.293,0.297-0.771,0.297-1.062,0L3.449,9.351C3.304,9.203,3.114,9.13,2.923,9.129C2.73,9.128,2.534,9.201,2.387,9.351 l-2.165,1.946C0.078,11.445,0,11.63,0,11.823c0,0.194,0.078,0.397,0.223,0.544l4.94,5.184c0.292,0.296,0.771,0.776,1.062,1.07 l2.124,2.141c0.292,0.293,0.769,0.293,1.062,0l14.366-14.34c0.293-0.294,0.293-0.777,0-1.071L21.652,3.211z" fill-rule="evenodd"/></svg>',
280  cross = typeof formatterParams.crossElement !== "undefined" ? formatterParams.crossElement : '<svg enable-background="new 0 0 24 24" height="14" width="14" viewBox="0 0 24 24" xml:space="preserve" ><path fill="#CE1515" d="M22.245,4.015c0.313,0.313,0.313,0.826,0,1.139l-6.276,6.27c-0.313,0.312-0.313,0.826,0,1.14l6.273,6.272 c0.313,0.313,0.313,0.826,0,1.14l-2.285,2.277c-0.314,0.312-0.828,0.312-1.142,0l-6.271-6.271c-0.313-0.313-0.828-0.313-1.141,0 l-6.276,6.267c-0.313,0.313-0.828,0.313-1.141,0l-2.282-2.28c-0.313-0.313-0.313-0.826,0-1.14l6.278-6.269 c0.313-0.312,0.313-0.826,0-1.14L1.709,5.147c-0.314-0.313-0.314-0.827,0-1.14l2.284-2.278C4.308,1.417,4.821,1.417,5.135,1.73 L11.405,8c0.314,0.314,0.828,0.314,1.141,0.001l6.276-6.267c0.312-0.312,0.826-0.312,1.141,0L22.245,4.015z"/></svg>';
281 
282  if (truthy && value || value === true || value === "true" || value === "True" || value === 1 || value === "1") {
283  element.setAttribute("aria-checked", true);
284  return tick || "";
285  } else {
286  if (empty && (value === "null" || value === "" || value === null || typeof value === "undefined")) {
287  element.setAttribute("aria-checked", "mixed");
288  return "";
289  } else {
290  element.setAttribute("aria-checked", false);
291  return cross || "";
292  }
293  }
294  },
295 
296  datetime: function datetime(cell, formatterParams, onRendered) {
297  var inputFormat = formatterParams.inputFormat || "YYYY-MM-DD hh:mm:ss";
298  var outputFormat = formatterParams.outputFormat || "DD/MM/YYYY hh:mm:ss";
299  var invalid = typeof formatterParams.invalidPlaceholder !== "undefined" ? formatterParams.invalidPlaceholder : "";
300  var value = cell.getValue();
301 
302  var newDatetime = moment(value, inputFormat);
303 
304  if (newDatetime.isValid()) {
305  return newDatetime.format(outputFormat);
306  } else {
307 
308  if (invalid === true) {
309  return value;
310  } else if (typeof invalid === "function") {
311  return invalid(value);
312  } else {
313  return invalid;
314  }
315  }
316  },
317 
318  datetimediff: function datetime(cell, formatterParams, onRendered) {
319  var inputFormat = formatterParams.inputFormat || "YYYY-MM-DD hh:mm:ss";
320  var invalid = typeof formatterParams.invalidPlaceholder !== "undefined" ? formatterParams.invalidPlaceholder : "";
321  var suffix = typeof formatterParams.suffix !== "undefined" ? formatterParams.suffix : false;
322  var unit = typeof formatterParams.unit !== "undefined" ? formatterParams.unit : undefined;
323  var humanize = typeof formatterParams.humanize !== "undefined" ? formatterParams.humanize : false;
324  var date = typeof formatterParams.date !== "undefined" ? formatterParams.date : moment();
325  var value = cell.getValue();
326 
327  var newDatetime = moment(value, inputFormat);
328 
329  if (newDatetime.isValid()) {
330  if (humanize) {
331  return moment.duration(newDatetime.diff(date)).humanize(suffix);
332  } else {
333  return newDatetime.diff(date, unit) + (suffix ? " " + suffix : "");
334  }
335  } else {
336 
337  if (invalid === true) {
338  return value;
339  } else if (typeof invalid === "function") {
340  return invalid(value);
341  } else {
342  return invalid;
343  }
344  }
345  },
346 
347  //select
348  lookup: function lookup(cell, formatterParams, onRendered) {
349  var value = cell.getValue();
350 
351  if (typeof formatterParams[value] === "undefined") {
352  console.warn('Missing display value for ' + value);
353  return value;
354  }
355 
356  return formatterParams[value];
357  },
358 
359  //star rating
360  star: function star(cell, formatterParams, onRendered) {
361  var value = cell.getValue(),
362  element = cell.getElement(),
363  maxStars = formatterParams && formatterParams.stars ? formatterParams.stars : 5,
364  stars = document.createElement("span"),
365  star = document.createElementNS('http://www.w3.org/2000/svg', "svg"),
366  starActive = '<polygon fill="#FFEA00" stroke="#C1AB60" stroke-width="37.6152" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" points="259.216,29.942 330.27,173.919 489.16,197.007 374.185,309.08 401.33,467.31 259.216,392.612 117.104,467.31 144.25,309.08 29.274,197.007 188.165,173.919 "/>',
367  starInactive = '<polygon fill="#D2D2D2" stroke="#686868" stroke-width="37.6152" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" points="259.216,29.942 330.27,173.919 489.16,197.007 374.185,309.08 401.33,467.31 259.216,392.612 117.104,467.31 144.25,309.08 29.274,197.007 188.165,173.919 "/>';
368 
369  //style stars holder
370  stars.style.verticalAlign = "middle";
371 
372  //style star
373  star.setAttribute("width", "14");
374  star.setAttribute("height", "14");
375  star.setAttribute("viewBox", "0 0 512 512");
376  star.setAttribute("xml:space", "preserve");
377  star.style.padding = "0 1px";
378 
379  value = value && !isNaN(value) ? parseInt(value) : 0;
380 
381  value = Math.max(0, Math.min(value, maxStars));
382 
383  for (var i = 1; i <= maxStars; i++) {
384  var nextStar = star.cloneNode(true);
385  nextStar.innerHTML = i <= value ? starActive : starInactive;
386 
387  stars.appendChild(nextStar);
388  }
389 
390  element.style.whiteSpace = "nowrap";
391  element.style.overflow = "hidden";
392  element.style.textOverflow = "ellipsis";
393 
394  element.setAttribute("aria-label", value);
395 
396  return stars;
397  },
398 
399  traffic: function traffic(cell, formatterParams, onRendered) {
400  var value = this.sanitizeHTML(cell.getValue()) || 0,
401  el = document.createElement("span"),
402  max = formatterParams && formatterParams.max ? formatterParams.max : 100,
403  min = formatterParams && formatterParams.min ? formatterParams.min : 0,
404  colors = formatterParams && typeof formatterParams.color !== "undefined" ? formatterParams.color : ["red", "orange", "green"],
405  color = "#666666",
406  percent,
407  percentValue;
408 
409  if (isNaN(value) || typeof cell.getValue() === "undefined") {
410  return;
411  }
412 
413  el.classList.add("tabulator-traffic-light");
414 
415  //make sure value is in range
416  percentValue = parseFloat(value) <= max ? parseFloat(value) : max;
417  percentValue = parseFloat(percentValue) >= min ? parseFloat(percentValue) : min;
418 
419  //workout percentage
420  percent = (max - min) / 100;
421  percentValue = Math.round((percentValue - min) / percent);
422 
423  //set color
424  switch (typeof colors === "undefined" ? "undefined" : _typeof(colors)) {
425  case "string":
426  color = colors;
427  break;
428  case "function":
429  color = colors(value);
430  break;
431  case "object":
432  if (Array.isArray(colors)) {
433  var unit = 100 / colors.length;
434  var index = Math.floor(percentValue / unit);
435 
436  index = Math.min(index, colors.length - 1);
437  index = Math.max(index, 0);
438  color = colors[index];
439  break;
440  }
441  }
442 
443  el.style.backgroundColor = color;
444 
445  return el;
446  },
447 
448  //progress bar
449  progress: function progress(cell, formatterParams, onRendered) {
450  //progress bar
451  var value = this.sanitizeHTML(cell.getValue()) || 0,
452  element = cell.getElement(),
453  max = formatterParams && formatterParams.max ? formatterParams.max : 100,
454  min = formatterParams && formatterParams.min ? formatterParams.min : 0,
455  legendAlign = formatterParams && formatterParams.legendAlign ? formatterParams.legendAlign : "center",
456  percent,
457  percentValue,
458  color,
459  legend,
460  legendColor,
461  top,
462  left,
463  right,
464  bottom;
465 
466  //make sure value is in range
467  percentValue = parseFloat(value) <= max ? parseFloat(value) : max;
468  percentValue = parseFloat(percentValue) >= min ? parseFloat(percentValue) : min;
469 
470  //workout percentage
471  percent = (max - min) / 100;
472  percentValue = Math.round((percentValue - min) / percent);
473 
474  //set bar color
475  switch (_typeof(formatterParams.color)) {
476  case "string":
477  color = formatterParams.color;
478  break;
479  case "function":
480  color = formatterParams.color(value);
481  break;
482  case "object":
483  if (Array.isArray(formatterParams.color)) {
484  var unit = 100 / formatterParams.color.length;
485  var index = Math.floor(percentValue / unit);
486 
487  index = Math.min(index, formatterParams.color.length - 1);
488  index = Math.max(index, 0);
489  color = formatterParams.color[index];
490  break;
491  }
492  default:
493  color = "#2DC214";
494  }
495 
496  //generate legend
497  switch (_typeof(formatterParams.legend)) {
498  case "string":
499  legend = formatterParams.legend;
500  break;
501  case "function":
502  legend = formatterParams.legend(value);
503  break;
504  case "boolean":
505  legend = value;
506  break;
507  default:
508  legend = false;
509  }
510 
511  //set legend color
512  switch (_typeof(formatterParams.legendColor)) {
513  case "string":
514  legendColor = formatterParams.legendColor;
515  break;
516  case "function":
517  legendColor = formatterParams.legendColor(value);
518  break;
519  case "object":
520  if (Array.isArray(formatterParams.legendColor)) {
521  var unit = 100 / formatterParams.legendColor.length;
522  var index = Math.floor(percentValue / unit);
523 
524  index = Math.min(index, formatterParams.legendColor.length - 1);
525  index = Math.max(index, 0);
526  legendColor = formatterParams.legendColor[index];
527  }
528  break;
529  default:
530  legendColor = "#000";
531  }
532 
533  element.style.minWidth = "30px";
534  element.style.position = "relative";
535 
536  element.setAttribute("aria-label", percentValue);
537 
538  var barEl = document.createElement("div");
539  barEl.style.display = "inline-block";
540  barEl.style.position = "relative";
541  barEl.style.width = percentValue + "%";
542  barEl.style.backgroundColor = color;
543  barEl.style.height = "100%";
544 
545  barEl.setAttribute('data-max', max);
546  barEl.setAttribute('data-min', min);
547 
548  if (legend) {
549  var legendEl = document.createElement("div");
550  legendEl.style.position = "absolute";
551  legendEl.style.top = "4px";
552  legendEl.style.left = 0;
553  legendEl.style.textAlign = legendAlign;
554  legendEl.style.width = "100%";
555  legendEl.style.color = legendColor;
556  legendEl.innerHTML = legend;
557  }
558 
559  onRendered(function () {
560  element.appendChild(barEl);
561 
562  if (legend) {
563  element.appendChild(legendEl);
564  }
565  });
566 
567  return "";
568  },
569 
570  //background color
571  color: function color(cell, formatterParams, onRendered) {
572  cell.getElement().style.backgroundColor = this.sanitizeHTML(cell.getValue());
573  return "";
574  },
575 
576  //tick icon
577  buttonTick: function buttonTick(cell, formatterParams, onRendered) {
578  return '<svg enable-background="new 0 0 24 24" height="14" width="14" viewBox="0 0 24 24" xml:space="preserve" ><path fill="#2DC214" clip-rule="evenodd" d="M21.652,3.211c-0.293-0.295-0.77-0.295-1.061,0L9.41,14.34 c-0.293,0.297-0.771,0.297-1.062,0L3.449,9.351C3.304,9.203,3.114,9.13,2.923,9.129C2.73,9.128,2.534,9.201,2.387,9.351 l-2.165,1.946C0.078,11.445,0,11.63,0,11.823c0,0.194,0.078,0.397,0.223,0.544l4.94,5.184c0.292,0.296,0.771,0.776,1.062,1.07 l2.124,2.141c0.292,0.293,0.769,0.293,1.062,0l14.366-14.34c0.293-0.294,0.293-0.777,0-1.071L21.652,3.211z" fill-rule="evenodd"/></svg>';
579  },
580 
581  //cross icon
582  buttonCross: function buttonCross(cell, formatterParams, onRendered) {
583  return '<svg enable-background="new 0 0 24 24" height="14" width="14" viewBox="0 0 24 24" xml:space="preserve" ><path fill="#CE1515" d="M22.245,4.015c0.313,0.313,0.313,0.826,0,1.139l-6.276,6.27c-0.313,0.312-0.313,0.826,0,1.14l6.273,6.272 c0.313,0.313,0.313,0.826,0,1.14l-2.285,2.277c-0.314,0.312-0.828,0.312-1.142,0l-6.271-6.271c-0.313-0.313-0.828-0.313-1.141,0 l-6.276,6.267c-0.313,0.313-0.828,0.313-1.141,0l-2.282-2.28c-0.313-0.313-0.313-0.826,0-1.14l6.278-6.269 c0.313-0.312,0.313-0.826,0-1.14L1.709,5.147c-0.314-0.313-0.314-0.827,0-1.14l2.284-2.278C4.308,1.417,4.821,1.417,5.135,1.73 L11.405,8c0.314,0.314,0.828,0.314,1.141,0.001l6.276-6.267c0.312-0.312,0.826-0.312,1.141,0L22.245,4.015z"/></svg>';
584  },
585 
586  //current row number
587  rownum: function rownum(cell, formatterParams, onRendered) {
588  return this.table.rowManager.activeRows.indexOf(cell.getRow()._getSelf()) + 1;
589  },
590 
591  //row handle
592  handle: function handle(cell, formatterParams, onRendered) {
593  cell.getElement().classList.add("tabulator-row-handle");
594  return "<div class='tabulator-row-handle-box'><div class='tabulator-row-handle-bar'></div><div class='tabulator-row-handle-bar'></div><div class='tabulator-row-handle-bar'></div></div>";
595  },
596 
597  responsiveCollapse: function responsiveCollapse(cell, formatterParams, onRendered) {
598  var self = this,
599  open = false,
600  el = document.createElement("div"),
601  config = cell.getRow()._row.modules.responsiveLayout;
602 
603  el.classList.add("tabulator-responsive-collapse-toggle");
604  el.innerHTML = "<span class='tabulator-responsive-collapse-toggle-open'>+</span><span class='tabulator-responsive-collapse-toggle-close'>-</span>";
605 
606  cell.getElement().classList.add("tabulator-row-handle");
607 
608  function toggleList(isOpen) {
609  var collapseEl = config.element;
610 
611  config.open = isOpen;
612 
613  if (collapseEl) {
614 
615  if (config.open) {
616  el.classList.add("open");
617  collapseEl.style.display = '';
618  } else {
619  el.classList.remove("open");
620  collapseEl.style.display = 'none';
621  }
622  }
623  }
624 
625  el.addEventListener("click", function (e) {
626  e.stopImmediatePropagation();
627  toggleList(!config.open);
628  });
629 
630  toggleList(config.open);
631 
632  return el;
633  },
634 
635  rowSelection: function rowSelection(cell) {
636  var _this = this;
637 
638  var checkbox = document.createElement("input");
639 
640  checkbox.type = 'checkbox';
641 
642  if (this.table.modExists("selectRow", true)) {
643 
644  checkbox.addEventListener("click", function (e) {
645  e.stopPropagation();
646  });
647 
648  if (typeof cell.getRow == 'function') {
649  var row = cell.getRow();
650 
651  checkbox.addEventListener("change", function (e) {
652  row.toggleSelect();
653  });
654 
655  checkbox.checked = row.isSelected();
656  this.table.modules.selectRow.registerRowSelectCheckbox(row, checkbox);
657  } else {
658  checkbox.addEventListener("change", function (e) {
659  if (_this.table.modules.selectRow.selectedRows.length) {
660  _this.table.deselectRow();
661  } else {
662  _this.table.selectRow();
663  }
664  });
665 
666  this.table.modules.selectRow.registerHeaderSelectCheckbox(checkbox);
667  }
668  }
669  return checkbox;
670  }
671 };
672 
673 Tabulator.prototype.registerModule("format", Format);