...
|
...
|
@@ -40,18 +40,27 @@ export function createTooltip(target: L.Layer, |
40
|
40
|
});
|
41
|
41
|
}
|
42
|
42
|
target.on('popupopen', () => {
|
43
|
|
- const actions = document.getElementsByClassName('tb-custom-action');
|
44
|
|
- Array.from(actions).forEach(
|
45
|
|
- (element: HTMLElement) => {
|
46
|
|
- const actionName = element.getAttribute('data-action-name');
|
47
|
|
- if (element && settings.tooltipAction[actionName]) {
|
48
|
|
- element.addEventListener('click', ($event) => settings.tooltipAction[actionName]($event, datasource));
|
49
|
|
- }
|
50
|
|
- });
|
|
43
|
+ bindPopupActions(popup, settings, datasource);
|
51
|
44
|
});
|
52
|
45
|
return popup;
|
53
|
46
|
}
|
54
|
47
|
|
|
48
|
+export function bindPopupActions(popup: L.Popup, settings: MarkerSettings | PolylineSettings | PolygonSettings,
|
|
49
|
+ datasource: Datasource) {
|
|
50
|
+ const actions = popup.getElement().getElementsByClassName('tb-custom-action');
|
|
51
|
+ Array.from(actions).forEach(
|
|
52
|
+ (element: HTMLElement) => {
|
|
53
|
+ const actionName = element.getAttribute('data-action-name');
|
|
54
|
+ if (element && settings.tooltipAction[actionName]) {
|
|
55
|
+ element.onclick = ($event) =>
|
|
56
|
+ {
|
|
57
|
+ settings.tooltipAction[actionName]($event, datasource);
|
|
58
|
+ return false;
|
|
59
|
+ };
|
|
60
|
+ }
|
|
61
|
+ });
|
|
62
|
+}
|
|
63
|
+
|
55
|
64
|
export function getRatio(firsMoment: number, secondMoment: number, intermediateMoment: number): number {
|
56
|
65
|
return (intermediateMoment - firsMoment) / (secondMoment - firsMoment);
|
57
|
66
|
}
|
...
|
...
|
@@ -133,7 +142,7 @@ const linkActionRegex = /<link-act name=['"]([^['"]*)['"]>([^<]*)<\/link-act>/g; |
133
|
142
|
const buttonActionRegex = /<button-act name=['"]([^['"]*)['"]>([^<]*)<\/button-act>/g;
|
134
|
143
|
|
135
|
144
|
function createLinkElement(actionName: string, actionText: string): string {
|
136
|
|
- return `<a href="#" class="tb-custom-action" data-action-name=${actionName}>${actionText}</a>`;
|
|
145
|
+ return `<a href="javascript:void(0);" class="tb-custom-action" data-action-name=${actionName}>${actionText}</a>`;
|
137
|
146
|
}
|
138
|
147
|
|
139
|
148
|
function createButtonElement(actionName: string, actionText: string) {
|
...
|
...
|
|