Completed
Push — master ( eca4bd...8c9b02 )
by
unknown
03:47
created

Selectors.ts ➔ selectTooltipBackground   A

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
1
import { select } from 'd3-selection';
2
import { LabelColors, ElementIds } from '../AppConsts';
3
import { DependencyLink, DependencyNode } from '../../components/types';
4
import { BaseType } from 'd3-selection';
5
6
export function selectHighLightedNodes() {
7
    return selectAllNodes().filter(function(this: SVGGElement) {
8
        return this.firstElementChild ? this.firstElementChild.getAttribute('fill') !== LabelColors.DEFAULT : false;
9
    });
10
}
11
12
export function selectAllNodes() {
13
    return selectById<SVGGElement>(ElementIds.LABELS).selectAll<SVGGElement, DependencyNode>('g');
14
}
15
16
export function selectAllLinks() {
17
    return selectById<SVGGElement>(ElementIds.LINKS).selectAll<SVGPathElement, DependencyLink>('path');
18
}
19
20
export function selectHighlightBackground() {
21
    return selectById<SVGGElement>(ElementIds.HIGHLIGHT_BACKGROUND);
22
}
23
24
export function selectDetailsButtonWrapper() {
25
    return selectById<SVGGElement>(ElementIds.DETAILS_BUTTON);
26
}
27
28
export function selectDetailsExitButtonWrapper() {
29
    return selectById<SVGGElement>(ElementIds.DETAILS_EXIT_BUTTON);
30
}
31
32
export function selectDetailsButtonRect() {
33
    return selectDetailsButtonWrapper().select('rect');
34
}
35
36
export function selectDetailsButtonText() {
37
    return selectDetailsButtonWrapper().select('text');
38
}
39
40
export function selectDetailsViewContainer() {
41
    return selectById<SVGSVGElement>(ElementIds.DETAILS_VIEW_CONTAINER);
42
}
43
44
export function selectDetailsContainerDiv() {
45
    return selectById<HTMLDivElement>(ElementIds.DETAILS_CONTAINER_DIV);
46
}
47
48
export function selectDetailsZoom() {
49
    return selectById<SVGGElement>(ElementIds.DETAILS_ZOOM);
50
}
51
52
export function selectOverviewZoom() {
53
    return selectById<SVGGElement>(ElementIds.OVERVIEW_ZOOM);
54
}
55
56
export function selectOverviewContainer() {
57
    return selectById<SVGSVGElement>(ElementIds.OVERVIEW_CONTAINER);
58
}
59
60
export function selectTooltip() {
61
    return selectById<SVGGElement>(ElementIds.TOOLTIP);
62
}
63
64
export function selectTooltipBackground() {
65
    return selectTooltip().select<SVGRectElement>('rect');
66
}
67
68
export function selectTooltipText() {
69
    return selectTooltip().select<SVGTextElement>('text');
70
}
71
72
export function selectDetailsRootNodeContainer() {
73
    return selectById<SVGSVGElement>(ElementIds.DETAILS_ROOT_NODE_CONTAINER);
74
}
75
76
export function selectById<Type extends BaseType = BaseType, Data = unknown>(selector: ElementIds) {
77
    return select<Type, Data>(`#${selector}`);
78
}
79