@microbiome-informatics/genome-properties-viewer 1.0.0-beta.2 → 1.0.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/gp-style.css CHANGED
@@ -90,8 +90,9 @@ g.node.loaded text.label-species {
90
90
  opacity: 0.7;
91
91
  }
92
92
  input[type="file"] {
93
- color: transparent;
94
- width: 150px;
93
+ color: inherit;
94
+ width: auto;
95
+ max-width: 220px;
95
96
  }
96
97
  .selector a {
97
98
  color: #3c67c1;
@@ -114,7 +115,8 @@ input[type="file"] {
114
115
  color: #666;
115
116
  text-align: right;
116
117
  margin-bottom: 2px;
117
- cursor: context-menu;
118
+ cursor: pointer;
119
+ position: relative;
118
120
  }
119
121
  .selector::after {
120
122
  content: " ▾ ";
@@ -130,11 +132,15 @@ input[type="file"] {
130
132
  color: #666;
131
133
  padding: 5px;
132
134
  position: absolute;
133
- z-index: 1;
135
+ left: 0;
136
+ top: 100%;
137
+ z-index: 20;
134
138
  border: 2px #ddd solid;
135
139
  text-align: left;
136
140
  }
137
- .selector:hover div.options {
141
+ .selector:hover div.options,
142
+ .selector.open div.options,
143
+ .selector:focus-within div.options {
138
144
  visibility: visible;
139
145
  }
140
146
  .selector .current_status {
@@ -206,6 +212,7 @@ input[type="file"] {
206
212
  top: 0;
207
213
  left: 0;
208
214
  pointer-events: none;
215
+ z-index: 10000;
209
216
  }
210
217
  div.gp-modal.gp-modal-active {
211
218
  pointer-events: auto;
@@ -220,20 +227,20 @@ div.gp-modal-content.gp-modal-active {
220
227
  position: fixed;
221
228
  left: 50%;
222
229
  top: 50%;
230
+ transform: translate(-50%, -50%);
223
231
  pointer-events: none;
232
+ z-index: 10001;
224
233
  }
225
234
  .gp-modal-content {
226
235
  position: relative;
227
- width: 80vw;
236
+ width: min(90vw, 1200px);
228
237
  min-height: 100px;
229
- height: 100%;
230
238
  max-height: 80vh;
231
239
  background: white;
232
- top: -10vh;
233
- left: -50%;
234
240
  opacity: 0;
235
241
  pointer-events: none;
236
- overflow: scroll;
242
+ overflow: auto;
243
+ box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
237
244
  }
238
245
 
239
246
  .progress-panel {
@@ -408,6 +415,7 @@ div.container .top-block {
408
415
  padding: 4px;
409
416
  background: #fafafa;
410
417
  position: relative;
418
+ z-index: 5;
411
419
  }
412
420
  div.container .top-block .minimise {
413
421
  position: absolute;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microbiome-informatics/genome-properties-viewer",
3
- "version": "1.0.0-beta.2",
3
+ "version": "1.0.0-beta.3",
4
4
  "description": "A heatmap styled viewer for the genome properties",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -10,7 +10,8 @@
10
10
  "bin/d3.custom.min.js"
11
11
  ],
12
12
  "publishConfig": {
13
- "access": "public"
13
+ "access": "public",
14
+ "registry": "https://registry.npmjs.org/"
14
15
  },
15
16
  "scripts": {
16
17
  "build": "rollup -c",
@@ -46,14 +46,18 @@ export default class GenomePropertiesController {
46
46
 
47
47
  this.text_filter = "";
48
48
  if (gp_text_filter_selector) {
49
- d3.select(gp_text_filter_selector).on("keyup", (event) => {
49
+ this._textFilterSelector = gp_text_filter_selector;
50
+ const applyTextFilter = (event) => {
50
51
  this.text_filter =
51
52
  event.currentTarget.value.length > 2 ? event.currentTarget.value : "";
52
53
  if (this.text_filter !== this.gp_viewer.filter_text) {
53
54
  this.gp_viewer.filter_text = this.text_filter;
54
55
  this.moveScrollUp();
55
56
  }
56
- });
57
+ };
58
+ d3.select(gp_text_filter_selector)
59
+ .on("input.gpfilter", applyTextFilter)
60
+ .on("keyup.gpfilter", applyTextFilter);
57
61
  }
58
62
  if (gp_label_selector) {
59
63
  d3.select(gp_label_selector).on("change", (event) => {
@@ -185,12 +189,27 @@ export default class GenomePropertiesController {
185
189
  </ul>
186
190
  </div>`);
187
191
 
188
- this.gp_component
189
- .select(".options .all")
190
- .on("click", () => this.update("ALL"));
191
- this.gp_component
192
- .select(".options .none")
193
- .on("click", () => this.update("NONE"));
192
+ this.gp_component.select(".options .all").on("click", (event) => {
193
+ event.preventDefault();
194
+ event.stopPropagation();
195
+ this.update("ALL");
196
+ });
197
+ this.gp_component.select(".options .none").on("click", (event) => {
198
+ event.preventDefault();
199
+ event.stopPropagation();
200
+ this.update("NONE");
201
+ });
202
+ this.gp_component.on("click.gpselector", (event) => {
203
+ if (event.target.closest(".options")) return;
204
+ this.gp_component.classed("open", !this.gp_component.classed("open"));
205
+ });
206
+ this._onDocClick = (event) => {
207
+ const node = this.gp_component.node();
208
+ if (node && !node.contains(event.target)) {
209
+ this.gp_component.classed("open", false);
210
+ }
211
+ };
212
+ document.addEventListener("click", this._onDocClick);
194
213
 
195
214
  const tll = this.gp_component
196
215
  .select(".options ul")
@@ -209,11 +228,19 @@ export default class GenomePropertiesController {
209
228
  (d) => `2px solid ${this.hierarchy_contorller.color(d.id)}`
210
229
  )
211
230
  .style("border-radius", "50%")
212
- .on("click", (event, d) => this.update(d));
231
+ .on("click", (event, d) => {
232
+ event.preventDefault();
233
+ event.stopPropagation();
234
+ this.update(d);
235
+ });
213
236
 
214
237
  li.append("a")
215
238
  .text((d) => this.hierarchy_contorller.nodes[d.id].name)
216
- .on("click", (event, d) => this.update(d));
239
+ .on("click", (event, d) => {
240
+ event.preventDefault();
241
+ event.stopPropagation();
242
+ this.update(d);
243
+ });
217
244
  }
218
245
 
219
246
  update(d) {
@@ -263,9 +290,10 @@ export default class GenomePropertiesController {
263
290
  }
264
291
  this.gp_component
265
292
  .select(".options ul")
266
- .selectAll(".top-level-option div")
293
+ .selectAll(".top-level-option")
294
+ .select("div")
267
295
  .style("background", (item) =>
268
- d.enable ? this.hierarchy_contorller.color(item.id) : "#e3e3e3"
296
+ item.enable ? this.hierarchy_contorller.color(item.id) : "#e3e3e3"
269
297
  );
270
298
  }
271
299
 
@@ -275,8 +303,20 @@ export default class GenomePropertiesController {
275
303
  }
276
304
 
277
305
  destroy() {
306
+ if (this._onDocClick) {
307
+ document.removeEventListener("click", this._onDocClick);
308
+ this._onDocClick = null;
309
+ }
310
+ if (this._textFilterSelector) {
311
+ d3.select(this._textFilterSelector)
312
+ .on("input.gpfilter", null)
313
+ .on("keyup.gpfilter", null);
314
+ }
278
315
  if (this.legends_component) this.legends_component.remove();
279
316
  if (this.tooltip_component) this.tooltip_component.remove();
280
- if (this.gp_component) this.gp_component.html("");
317
+ if (this.gp_component) {
318
+ this.gp_component.on("click.gpselector", null);
319
+ this.gp_component.html("");
320
+ }
281
321
  }
282
322
  }
package/src/gp-filters.js CHANGED
@@ -13,28 +13,35 @@ import * as d3 from "./d3";
13
13
  * The current set of filters is in `viewer.legend_filters` and the filtered props will be saved in `viewer.props`.
14
14
  * @param {GernomeProperiesViewer} viewer - The instance of the genome properites viewer
15
15
  */
16
+ const organismKeys = (viewer) =>
17
+ new Set((viewer.organisms || []).map((id) => String(id)));
18
+
19
+ const valuesForLoadedOrganisms = (prop, viewer) => {
20
+ const loaded = organismKeys(viewer);
21
+ return d3
22
+ .entries(prop.values)
23
+ .filter((e) => e.key !== "TOTAL" && loaded.has(String(e.key)));
24
+ };
25
+
16
26
  export const filterByLegend = (viewer) => {
17
27
  if (viewer.legend_filters) {
18
28
  for (const x of Object.keys(viewer.legend_filters)) {
19
29
  if (viewer.legend_filters[x] === "∀") {
20
30
  viewer.props = viewer.props.filter((prop) => {
21
- const values = d3
22
- .entries(prop.values)
23
- .filter((e) => viewer.organisms.indexOf(e.key) !== -1);
24
- return values.filter((e) => e.value === x).length === values.length;
31
+ const values = valuesForLoadedOrganisms(prop, viewer);
32
+ return (
33
+ values.length > 0 &&
34
+ values.filter((e) => e.value === x).length === values.length
35
+ );
25
36
  });
26
37
  } else if (viewer.legend_filters[x] === "∃") {
27
38
  viewer.props = viewer.props.filter((prop) => {
28
- const values = d3
29
- .entries(prop.values)
30
- .filter((e) => viewer.organisms.indexOf(e.key) !== -1);
39
+ const values = valuesForLoadedOrganisms(prop, viewer);
31
40
  return values.filter((e) => e.value === x).length > 0;
32
41
  });
33
42
  } else if (viewer.legend_filters[x] === "∄") {
34
43
  viewer.props = viewer.props.filter((prop) => {
35
- const values = d3
36
- .entries(prop.values)
37
- .filter((e) => viewer.organisms.indexOf(e.key) !== -1);
44
+ const values = valuesForLoadedOrganisms(prop, viewer);
38
45
  return values.filter((e) => e.value === x).length === 0;
39
46
  });
40
47
  }
@@ -49,7 +56,8 @@ export const filterByLegend = (viewer) => {
49
56
  */
50
57
  export const filterByHierarchy = (viewer) => {
51
58
  viewer.props = viewer.props.filter((e) => {
52
- if (e.parent_top_properties === null) return true;
59
+ if (!e.parent_top_properties || e.parent_top_properties.length === 0)
60
+ return true;
53
61
  for (const p of e.parent_top_properties)
54
62
  for (const tp of viewer.gp_hierarchy.hierarchy_switch)
55
63
  if (p === tp.id && tp.enable) return true;
@@ -91,8 +91,10 @@ class GenomePropertiesHierarchy {
91
91
  * @return {Array} Array of ids of the top level properties.
92
92
  */
93
93
  get_top_level_gp_by_id(id) {
94
- if (id in this.nodes)
95
- return [...this.get_top_level_gp(this.nodes[id])].map((d) => d.id);
94
+ if (id in this.nodes) {
95
+ const top = this.get_top_level_gp(this.nodes[id]);
96
+ if (top) return [...top].map((d) => d.id);
97
+ }
96
98
  return [];
97
99
  }
98
100
 
@@ -109,11 +111,11 @@ class GenomePropertiesHierarchy {
109
111
  return node.top_level_gp;
110
112
  }
111
113
  node.top_level_gp = new Set();
112
- for (const parent of node.parents) {
113
- node.top_level_gp = new Set([
114
- ...node.top_level_gp,
115
- ...this.get_top_level_gp(parent),
116
- ]);
114
+ for (const parent of node.parents || []) {
115
+ const parentTop = this.get_top_level_gp(parent);
116
+ if (parentTop) {
117
+ node.top_level_gp = new Set([...node.top_level_gp, ...parentTop]);
118
+ }
117
119
  }
118
120
  return node.top_level_gp;
119
121
  }
@@ -1,19 +1,71 @@
1
1
  import { tsvParseRows, select } from "./d3";
2
2
 
3
- const isLineOK = (line) => line.length === 3;
3
+ const ASSIGNMENT_VALUES = new Set(["YES", "PARTIAL", "NO"]);
4
+ const IPR_RE = /^IPR\d{6}$/;
5
+ const MD5_RE = /^[A-Fa-f0-9]{32}$/;
6
+ const GENPROP_RE = /^GenProp\d{4}$/;
7
+
8
+ const firstDataLine = (text) => {
9
+ const body = String(text || "").replace(/^\uFEFF/, "");
10
+ for (const raw of body.split(/\r?\n/)) {
11
+ if (raw && raw[0] !== "#") return raw;
12
+ }
13
+ return "";
14
+ };
15
+
16
+ export const classifyUpload = (filename, text) => {
17
+ const name = String(filename || "").toLowerCase();
18
+ if (name.endsWith(".gz")) return "assign";
19
+ const trimmed = String(text || "")
20
+ .replace(/^\uFEFF/, "")
21
+ .trim();
22
+ if (!trimmed) return "unknown";
23
+ if (trimmed.startsWith("{") || trimmed.startsWith("[")) return "json";
24
+ const cols = firstDataLine(text).split("\t");
25
+ if (cols[0] === "Accession" && cols[1] === "Name") return "assign";
26
+ if (
27
+ cols.length >= 11 &&
28
+ (MD5_RE.test(cols[1] || "") ||
29
+ (/^\d+$/.test(cols[2] || "") &&
30
+ /^\d+$/.test(cols[6] || "") &&
31
+ /^\d+$/.test(cols[7] || "")))
32
+ ) {
33
+ return "assign";
34
+ }
35
+ if (IPR_RE.test(cols[0] || "")) return "assign";
36
+ const value = String(cols[2] || "").toUpperCase();
37
+ if (
38
+ ASSIGNMENT_VALUES.has(value) &&
39
+ (GENPROP_RE.test(cols[0] || "") || cols.length >= 3)
40
+ ) {
41
+ return "summary";
42
+ }
43
+ return "unknown";
44
+ };
45
+
46
+ const isSummaryLine = (line) =>
47
+ Array.isArray(line) &&
48
+ line.length >= 3 &&
49
+ ASSIGNMENT_VALUES.has(String(line[2] || "").toUpperCase());
4
50
 
5
51
  const mergeObjectToData = (data, obj) => {
6
- for (const gp of Object.keys(data)) {
7
- for (const newOrg of Object.keys((obj[gp] && obj[gp].values) || {})) {
8
- if (newOrg !== "TOTAL") data[gp].values[newOrg] = obj[gp].values[newOrg];
9
- }
10
- const stepsObj = ((obj[gp] && obj[gp].steps) || []).reduce((agg, v) => {
11
- agg[v.step] = v;
12
- return agg;
13
- }, {});
14
- for (const step of data[gp].steps) {
15
- for (const newOrg of Object.keys(stepsObj[step.step].values)) {
16
- step.values[newOrg] = stepsObj[step.step].values[newOrg];
52
+ for (const gp of Object.keys(obj || {})) {
53
+ if (data[gp]) {
54
+ for (const newOrg of Object.keys((obj[gp] && obj[gp].values) || {})) {
55
+ if (newOrg !== "TOTAL")
56
+ data[gp].values[newOrg] = obj[gp].values[newOrg];
57
+ }
58
+ const stepsObj = ((obj[gp] && obj[gp].steps) || []).reduce((agg, v) => {
59
+ agg[String(v.step)] = v;
60
+ return agg;
61
+ }, {});
62
+ for (const step of data[gp].steps || []) {
63
+ const stepData = stepsObj[String(step.step)];
64
+ if (stepData && stepData.values) {
65
+ for (const newOrg of Object.keys(stepData.values)) {
66
+ step.values[newOrg] = stepData.values[newOrg];
67
+ }
68
+ }
17
69
  }
18
70
  }
19
71
  }
@@ -59,10 +111,14 @@ export const loadGenomePropertiesText = (
59
111
  let allLinesAreOK = true;
60
112
  const errorLines = [];
61
113
  tsvParseRows(text, (d, i) => {
62
- if (!isLineOK(d)) {
114
+ if (!d || (d.length === 1 && !d[0])) return;
115
+ if (!isSummaryLine(d)) {
116
+ if (i === 0 && (d[0] === "Accession" || d[0] === "property")) return;
63
117
  allLinesAreOK = false;
64
118
  errorLines.push([i, d]);
119
+ return;
65
120
  }
121
+ const value = String(d[2]).toUpperCase();
66
122
  if (wl && wl.indexOf(d[0]) === -1) return;
67
123
  if (!(d[0] in viewer.data))
68
124
  viewer.data[d[0]] = {
@@ -87,9 +143,9 @@ export const loadGenomePropertiesText = (
87
143
  isShowingSteps: false,
88
144
  };
89
145
  if (tax_id in viewer.data[d[0]].values) return;
90
- viewer.data[d[0]].values[tax_id] = d[2];
91
- viewer.data[d[0]].values.TOTAL[d[2]]++;
92
- viewer.organism_totals[tax_id][d[2]]++;
146
+ viewer.data[d[0]].values[tax_id] = value;
147
+ viewer.data[d[0]].values.TOTAL[value]++;
148
+ viewer.organism_totals[tax_id][value]++;
93
149
  // TODO: Replace for actual steps information
94
150
  viewer.data[d[0]].steps.forEach(
95
151
  (step) => (step.values[tax_id] = Math.random() > 0.5)
@@ -349,54 +405,94 @@ export const loadGenomePropertiesFile = (viewer, tax_id) => {
349
405
  });
350
406
  };
351
407
 
352
- function isIpproLine(line) {
353
- const parts = line.split("\t");
354
- return !(parts.length < 11 || parts[1].length !== 32);
408
+ function assignErrorMessage(status, body) {
409
+ try {
410
+ const parsed = JSON.parse(body);
411
+ const detail = parsed && parsed.detail;
412
+ if (typeof detail === "string" && detail.trim()) return detail;
413
+ if (Array.isArray(detail) && detail.length) {
414
+ return detail
415
+ .map((item) => (item && (item.msg || item.message)) || "")
416
+ .filter(Boolean)
417
+ .join(" ");
418
+ }
419
+ } catch (_error) {
420
+ // keep the HTTP status fallback
421
+ }
422
+ return `Could not calculate Genome Properties (${status}).`;
355
423
  }
356
424
 
357
- export const uploadLocalGPFile = (viewer, fileToRead) => {
358
- const reader = new FileReader();
359
- reader.fileToRead = fileToRead;
360
- reader.onload = (evt) => {
361
- try {
362
- const firstline = evt.target.result.split("\n")[0];
363
- if (isIpproLine(firstline)) {
364
- viewer.modal.showContent(
365
- "<h3><div class='loading'>◉</div>Calculation Genome Properties from InterProScan Data</h3>",
366
- true
367
- );
425
+ async function isGzipFile(file) {
426
+ if (/\.gz$/i.test(file.name || "")) return true;
427
+ const head = new Uint8Array(await file.slice(0, 2).arrayBuffer());
428
+ return head[0] === 0x1f && head[1] === 0x8b;
429
+ }
368
430
 
369
- fetch(viewer.options.gp_server, {
370
- method: "POST",
371
- body: `ipproname=${reader.fileToRead.name}&ipprotsv=${evt.target.result}`,
372
- headers: new Headers({
373
- "Content-Type": "application/x-www-form-urlencoded",
374
- "Access-Control-Request-Method": "POST",
375
- "Access-Control-Request-Headers": "X-PINGOTHER, Content-Type",
376
- }),
377
- })
378
- .then((response) => response.text())
379
- .then((x) => {
380
- viewer.loadGenomePropertiesText(reader.fileToRead.name, x);
381
- viewer.modal.setVisibility(false);
382
- })
383
- .catch(() => {
384
- viewer.modal.showContent(
385
- "<h3><div class='error'>Server Error processing the file</div></h3>",
386
- false
387
- );
388
- });
389
- } else {
390
- viewer.loadGenomePropertiesText(
391
- reader.fileToRead.name,
392
- evt.target.result
393
- );
394
- }
395
- } catch (e) {
396
- // eslint-disable-next-line no-console
397
- console.error(e);
431
+ function sendToAssign(viewer, fileToRead, showError) {
432
+ if (!viewer.options.gp_server) {
433
+ showError("Genome Properties assignment is not configured.");
434
+ return Promise.resolve();
435
+ }
436
+ viewer.modal.showContent(
437
+ "<h3><div class='loading'>◉</div>Calculating Genome Properties from InterPro data</h3>",
438
+ true
439
+ );
440
+ const body = new FormData();
441
+ body.append("file", fileToRead);
442
+ body.append("ipproname", fileToRead.name);
443
+ return fetch(viewer.options.gp_server, {
444
+ method: "POST",
445
+ body,
446
+ })
447
+ .then(async (response) => {
448
+ const text = await response.text();
449
+ if (!response.ok)
450
+ throw new Error(assignErrorMessage(response.status, text));
451
+ return text;
452
+ })
453
+ .then((x) => {
454
+ viewer.loadGenomePropertiesText(fileToRead.name, x);
455
+ viewer.modal.setVisibility(false);
456
+ })
457
+ .catch((error) => {
458
+ showError(
459
+ error.message || "Could not calculate Genome Properties from this file"
460
+ );
461
+ });
462
+ }
463
+
464
+ export const uploadLocalGPFile = (viewer, fileToRead) => {
465
+ if (!viewer || !fileToRead) return;
466
+ const showError = (message) => {
467
+ if (viewer.modal && viewer.modal.showContent) {
468
+ viewer.modal.showContent(
469
+ `<h3><div class='error'>${message}</div></h3>`,
470
+ false
471
+ );
472
+ }
473
+ };
474
+ const run = async () => {
475
+ if (await isGzipFile(fileToRead)) {
476
+ await sendToAssign(viewer, fileToRead, showError);
477
+ return;
478
+ }
479
+ const text = await fileToRead.text();
480
+ const kind = classifyUpload(fileToRead.name, text);
481
+ if (kind === "assign") {
482
+ await sendToAssign(viewer, fileToRead, showError);
483
+ return;
398
484
  }
399
- document.getElementById("newfile").value = null;
485
+ if (kind === "unknown") {
486
+ showError(
487
+ "This is not an InterProScan TSV, an InterPro entry export, or a Genome Properties summary file."
488
+ );
489
+ return;
490
+ }
491
+ viewer.loadGenomePropertiesText(fileToRead.name, text);
400
492
  };
401
- reader.readAsText(fileToRead);
493
+ run().catch((error) => {
494
+ // eslint-disable-next-line no-console
495
+ console.error(error);
496
+ showError(error.message || "Could not load the selected file");
497
+ });
402
498
  };
package/src/gp-viewer.js CHANGED
@@ -61,7 +61,7 @@ export default class GenomePropertiesViewer {
61
61
  tax_label_selector = "#tax_label",
62
62
  tax_search_selector = "#tax-search",
63
63
  template_link_to_GP_page = "https://wwwdev.ebi.ac.uk/interpro/genomeproperties/#{}",
64
- gp_server = "http://wwwdev.ebi.ac.uk/interpro/genomeproperties/cgi-bin/test.pl",
64
+ gp_server = "http://127.0.0.1:8000/api/v1/assign",
65
65
  dimensions = {
66
66
  tree: { width: 160 },
67
67
  labels: { width: 220 },
@@ -309,6 +309,9 @@ export default class GenomePropertiesViewer {
309
309
  if (this.controller && this.controller.destroy) {
310
310
  this.controller.destroy();
311
311
  }
312
+ if (this.modal && this.modal.destroy) {
313
+ this.modal.destroy();
314
+ }
312
315
  d3.select(this.options.element_selector).selectAll("*").remove();
313
316
  }
314
317
 
package/src/modal.js CHANGED
@@ -6,19 +6,16 @@ class GPModal {
6
6
  /**
7
7
  * Appends the divs for the modal overlay and the popup.
8
8
  * Inside the popup creates a `div` element with a refence in `this.content`.
9
- * @param {HTMLElement} element - DOM element where the modal should be appended.
9
+ * The overlay is mounted on `document.body` so it stacks above page chrome.
10
10
  */
11
- constructor(element) {
11
+ constructor() {
12
12
  this.fixed = false;
13
- this.mask = d3
14
- .selectAll(element)
13
+ const host = d3.select("body");
14
+ this.mask = host
15
15
  .append("div")
16
16
  .attr("class", "gp-modal")
17
17
  .on("click", () => !this.fixed && this.setVisibility(false));
18
- this.popup = d3
19
- .selectAll(element)
20
- .append("div")
21
- .attr("class", "gp-modal-popup");
18
+ this.popup = host.append("div").attr("class", "gp-modal-popup");
22
19
  this.content = this.popup.append("div").attr("class", "gp-modal-content");
23
20
  }
24
21
 
@@ -51,6 +48,11 @@ class GPModal {
51
48
  getContentElement() {
52
49
  return this.content;
53
50
  }
51
+
52
+ destroy() {
53
+ this.mask.remove();
54
+ this.popup.remove();
55
+ }
54
56
  }
55
57
 
56
58
  export default GPModal;