• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2020 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5class AppEvent extends CustomEvent {
6  constructor(name) {
7    super(name, {bubbles: true, composed: true});
8  }
9}
10
11export class SelectionEvent extends AppEvent {
12  // TODO: turn into static class fields once Safari supports it.
13  static get name() {
14    return 'select';
15  }
16
17  constructor(entries) {
18    super(SelectionEvent.name);
19    if (!Array.isArray(entries) || entries.length == 0) {
20      throw new Error('No valid entries selected!');
21    }
22    this.entries = entries;
23  }
24}
25
26export class SelectRelatedEvent extends AppEvent {
27  static get name() {
28    return 'selectrelated';
29  }
30
31  constructor(entry) {
32    super(SelectRelatedEvent.name);
33    this.entry = entry;
34  }
35}
36
37export class FocusEvent extends AppEvent {
38  static get name() {
39    return 'showentrydetail';
40  }
41
42  constructor(entry) {
43    super(FocusEvent.name);
44    this.entry = entry;
45  }
46}
47
48export class SelectTimeEvent extends AppEvent {
49  static get name() {
50    return 'timerangeselect';
51  }
52
53  constructor(start = 0, end = Infinity, focus = false, zoom = false) {
54    super(SelectTimeEvent.name);
55    this.start = start;
56    this.end = end;
57    this.focus = focus;
58    this.zoom = zoom;
59  }
60}
61
62export class SynchronizeSelectionEvent extends AppEvent {
63  static get name() {
64    return 'syncselection';
65  }
66
67  constructor(start, end) {
68    super(SynchronizeSelectionEvent.name);
69    this.start = start;
70    this.end = end;
71  }
72}
73
74export class ToolTipEvent extends AppEvent {
75  static get name() {
76    return 'showtooltip';
77  }
78
79  constructor(content, positionOrTargetNode) {
80    super(ToolTipEvent.name);
81    if (!positionOrTargetNode) {
82      throw Error('Either provide a valid position or targetNode');
83    }
84    this._content = content;
85    this._positionOrTargetNode = positionOrTargetNode;
86  }
87
88  get content() {
89    return this._content;
90  }
91
92  get positionOrTargetNode() {
93    return this._positionOrTargetNode;
94  }
95}
96