@alisaitteke/seatmap-canvas 2.0.0
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/.eslintrc.json +15 -0
- package/.github/FUNDING.yml +4 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- package/.github/workflows/codeql-analysis.yml +29 -0
- package/.github/workflows/npm-publish-packages.yml +35 -0
- package/.github/workflows/webpack.yml +22 -0
- package/AUTHORS +3 -0
- package/LICENSE +21 -0
- package/README.md +160 -0
- package/SECURITY.md +21 -0
- package/_config.yml +1 -0
- package/assets/banner_ui.png +0 -0
- package/assets/bn.jpg +0 -0
- package/assets/logo.jpg +0 -0
- package/assets/logo_small.jpg +0 -0
- package/assets/zoom_out.svg +11 -0
- package/examples/basic/bootstrap.min.css +7 -0
- package/examples/basic/index.html +201 -0
- package/examples/basic/jquery.min.js +2 -0
- package/examples/data/data.json +70007 -0
- package/examples/data/small.json +1307 -0
- package/examples/data/tiny.json +119 -0
- package/examples/old/index.html +262 -0
- package/package.json +59 -0
- package/src/lib/canvas.index.ts +122 -0
- package/src/lib/config.ts +11 -0
- package/src/lib/decorators/dom.ts +40 -0
- package/src/lib/decorators/index.ts +6 -0
- package/src/lib/dev.tools.ts +18 -0
- package/src/lib/enums/global.ts +67 -0
- package/src/lib/models/block.model.ts +170 -0
- package/src/lib/models/coordinate.model.ts +43 -0
- package/src/lib/models/data.model.ts +105 -0
- package/src/lib/models/defaults.model.ts +125 -0
- package/src/lib/models/global.model.ts +24 -0
- package/src/lib/models/label.model.ts +58 -0
- package/src/lib/models/legend.model.ts +56 -0
- package/src/lib/models/model.base.ts +32 -0
- package/src/lib/models/seat.model.ts +182 -0
- package/src/lib/svg/event.manager.ts +56 -0
- package/src/lib/svg/legend/legend.circle.ts +28 -0
- package/src/lib/svg/legend/legend.item.ts +50 -0
- package/src/lib/svg/legend/legend.title.ts +27 -0
- package/src/lib/svg/legend.ts +55 -0
- package/src/lib/svg/stage/blocks/block-item/block-item.bounds.ts +51 -0
- package/src/lib/svg/stage/blocks/block-item/block-item.index.ts +173 -0
- package/src/lib/svg/stage/blocks/block-item/block-item.info.index.ts +38 -0
- package/src/lib/svg/stage/blocks/block-item/block-item.labels.index.ts +41 -0
- package/src/lib/svg/stage/blocks/block-item/block-item.mask.ts +67 -0
- package/src/lib/svg/stage/blocks/block-item/block-item.seats.index.ts +81 -0
- package/src/lib/svg/stage/blocks/block-item/bound/bound-item.index.ts +43 -0
- package/src/lib/svg/stage/blocks/block-item/info/title.ts +30 -0
- package/src/lib/svg/stage/blocks/block-item/label/label-item.circle.ts +27 -0
- package/src/lib/svg/stage/blocks/block-item/label/label-item.index.ts +46 -0
- package/src/lib/svg/stage/blocks/block-item/label/label-item.title.ts +27 -0
- package/src/lib/svg/stage/blocks/block-item/seat/seat-item.check.ts +45 -0
- package/src/lib/svg/stage/blocks/block-item/seat/seat-item.circle.ts +30 -0
- package/src/lib/svg/stage/blocks/block-item/seat/seat-item.index.ts +159 -0
- package/src/lib/svg/stage/blocks/block-item/seat/seat-item.title.ts +27 -0
- package/src/lib/svg/stage/blocks/blocks.index.ts +68 -0
- package/src/lib/svg/stage/blocks.search-circle.ts +86 -0
- package/src/lib/svg/stage/multi-select/rect.ts +36 -0
- package/src/lib/svg/stage/multi-select.ts +107 -0
- package/src/lib/svg/stage/search-circle/circle.ts +37 -0
- package/src/lib/svg/stage/stage.index.ts +41 -0
- package/src/lib/svg/svg.base.ts +217 -0
- package/src/lib/svg/svg.index.ts +76 -0
- package/src/lib/svg/tooltip/rect.ts +66 -0
- package/src/lib/svg/tooltip/title.ts +57 -0
- package/src/lib/svg/tooltip.ts +92 -0
- package/src/lib/svg/zoom-out.bg.ts +35 -0
- package/src/lib/svg/zoom.manager.ts +440 -0
- package/src/lib/window.manager.ts +40 -0
- package/src/scss/lib.scss +10 -0
- package/src/scss/style.scss +221 -0
- package/tsconfig.json +28 -0
- package/webpack.environments/development.js +58 -0
- package/webpack.environments/production.js +52 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* $project.fileName
|
|
3
|
+
* https://github.com/seatmap/canvas Copyright 2018 Ali Sait TEKE
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
import {dom} from "../../decorators";
|
|
8
|
+
import SvgBase from "../svg.base";
|
|
9
|
+
import Circle from "./search-circle/circle";
|
|
10
|
+
import {EventType, ZoomLevel} from "../../enums/global";
|
|
11
|
+
import Stage from "./stage.index";
|
|
12
|
+
|
|
13
|
+
@dom({
|
|
14
|
+
tag: "g",
|
|
15
|
+
class: "search-circle",
|
|
16
|
+
autoGenerate: false
|
|
17
|
+
})
|
|
18
|
+
export default class BlocksSearchCircle extends SvgBase {
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
public circle: Circle;
|
|
22
|
+
public is_enable: boolean = true;
|
|
23
|
+
|
|
24
|
+
constructor(public parent: Stage) {
|
|
25
|
+
super(parent);
|
|
26
|
+
this.global.eventManager.addEventListener(EventType.MOUSE_MOVE, (mouse: any) => {
|
|
27
|
+
if (this.global.zoomManager.zoomLevel === ZoomLevel.BLOCK && this.is_enable) {
|
|
28
|
+
this.node.attr("transform", "translate(" + mouse + ")");
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
this.global.eventManager.addEventListener(EventType.ZOOM_LEVEL_CHANGE, (zoom_level: any) => {
|
|
33
|
+
if (zoom_level.level === ZoomLevel.VENUE || zoom_level.level === ZoomLevel.SEAT) {
|
|
34
|
+
this.node.classed("show", false);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
this.global.eventManager.addEventListener(EventType.MULTI_SELECT_ENABLE, () => {
|
|
40
|
+
this.disable();
|
|
41
|
+
});
|
|
42
|
+
this.global.eventManager.addEventListener(EventType.MULTI_SELECT_DISABLE, () => {
|
|
43
|
+
this.enable();
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
return this;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
update(): this {
|
|
51
|
+
|
|
52
|
+
this.clear();
|
|
53
|
+
this.circle = new Circle(this);
|
|
54
|
+
this.addChild(this.circle);
|
|
55
|
+
this.updateChilds();
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
this.parent.blocks.node.on("mouseleave.search", () => {
|
|
59
|
+
this.node.classed("show", false);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
this.parent.blocks.node.on("mousemove.search", () => {
|
|
63
|
+
if (this.global.zoomManager.zoomLevel === ZoomLevel.VENUE) {
|
|
64
|
+
this.node.classed("show", false);
|
|
65
|
+
} else if (this.global.zoomManager.zoomLevel === ZoomLevel.BLOCK) {
|
|
66
|
+
this.node.classed("show", true);
|
|
67
|
+
} else if (this.global.zoomManager.zoomLevel === ZoomLevel.SEAT) {
|
|
68
|
+
this.node.classed("show", false);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
return this;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
public enable(): this {
|
|
76
|
+
this.is_enable = true;
|
|
77
|
+
this.node.style("display", "block");
|
|
78
|
+
return this;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
public disable(): this {
|
|
82
|
+
this.is_enable = false;
|
|
83
|
+
this.node.style("display", "none");
|
|
84
|
+
return this;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* $project.fileName
|
|
3
|
+
* https://github.com/seatmap/canvas Copyright 2018 Ali Sait TEKE
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
import {dom} from "../../../decorators";
|
|
8
|
+
import SvgBase from "./../../svg.base";
|
|
9
|
+
import MultiSelect from "../multi-select";
|
|
10
|
+
|
|
11
|
+
@dom({
|
|
12
|
+
tag: "rect",
|
|
13
|
+
class: "multi-select-rect",
|
|
14
|
+
autoGenerate: false
|
|
15
|
+
})
|
|
16
|
+
export default class MultiSelectRect extends SvgBase {
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
constructor(public parent: MultiSelect) {
|
|
20
|
+
super(parent);
|
|
21
|
+
this.attr("width", 250);
|
|
22
|
+
this.attr("height", 250);
|
|
23
|
+
|
|
24
|
+
this.attr("x", 250);
|
|
25
|
+
this.attr("y", 250);
|
|
26
|
+
|
|
27
|
+
this.attr("fill", "none");
|
|
28
|
+
this.attr("stroke", "rgba(0,0,0,0.5)");
|
|
29
|
+
this.attr("stroke-width", "3px");
|
|
30
|
+
this.attr("stroke-dasharray", "4");
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
update() {
|
|
34
|
+
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* $project.fileName
|
|
3
|
+
* https://github.com/seatmap/canvas Copyright 2018 Ali Sait TEKE
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import {mouse as d3Mouse} from 'd3-selection'
|
|
7
|
+
|
|
8
|
+
import SvgBase from "../svg.base";
|
|
9
|
+
import Svg from "../svg.index";
|
|
10
|
+
import MultiSelectRect from "./multi-select/rect";
|
|
11
|
+
import {EventType} from "../../enums/global";
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
import {dom} from "../../decorators";
|
|
15
|
+
|
|
16
|
+
@dom({
|
|
17
|
+
tag: "g",
|
|
18
|
+
class: "multi-select-tools",
|
|
19
|
+
autoGenerate: false
|
|
20
|
+
})
|
|
21
|
+
export default class MultiSelect extends SvgBase {
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
public rect: MultiSelectRect;
|
|
25
|
+
public enable: boolean;
|
|
26
|
+
public start: boolean;
|
|
27
|
+
|
|
28
|
+
public points: any = {
|
|
29
|
+
start: null,
|
|
30
|
+
end: null
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
constructor(public parent: Svg) {
|
|
34
|
+
super(parent);
|
|
35
|
+
this.enable = false;
|
|
36
|
+
this.start = false;
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
// this.global.eventManager.addEventListener(EventType.MOUSEDOWN_BLOCK, (e: any, node: any, mouse: any) => {
|
|
40
|
+
//
|
|
41
|
+
// });
|
|
42
|
+
this.global.eventManager.addEventListener(EventType.MOUSEUP_BLOCK, () => {
|
|
43
|
+
if (this.global.multi_select && this.start) {
|
|
44
|
+
//console.log("up");
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
return this;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
update(): this {
|
|
52
|
+
|
|
53
|
+
this.rect = new MultiSelectRect(this).addTo(this);
|
|
54
|
+
this.updateChilds();
|
|
55
|
+
|
|
56
|
+
return this;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
afterGenerate() {
|
|
60
|
+
|
|
61
|
+
this.parent.stage.node.on("mousedown", () => {
|
|
62
|
+
if (!this.global.multi_select) return;
|
|
63
|
+
// console.log("e", e);
|
|
64
|
+
// console.log("mouse", mouse);
|
|
65
|
+
// console.log("mouse", mouse);
|
|
66
|
+
let mouse = d3Mouse(this.parent.stage.node.node());
|
|
67
|
+
if (this.start) {
|
|
68
|
+
this.start = false;
|
|
69
|
+
|
|
70
|
+
this.points.end = mouse;
|
|
71
|
+
let width = this.points.end[0] - this.points.start[0];
|
|
72
|
+
let height = this.points.end[1] - this.points.start[1];
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
this.rect.node.attr("width", width);
|
|
76
|
+
this.rect.node.attr("height", height);
|
|
77
|
+
this.rect.node.attr("x", this.points.start[0]);
|
|
78
|
+
this.rect.node.attr("y", this.points.end[0]);
|
|
79
|
+
|
|
80
|
+
this.points.start = null;
|
|
81
|
+
this.points.end = null;
|
|
82
|
+
} else {
|
|
83
|
+
this.start = true;
|
|
84
|
+
this.points.start = mouse;
|
|
85
|
+
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
});
|
|
89
|
+
this.parent.stage.node.on("mousemove", () => {
|
|
90
|
+
if (this.global.multi_select) {
|
|
91
|
+
if (this.start) {
|
|
92
|
+
let mouse = d3Mouse(this.parent.stage.node.node());
|
|
93
|
+
let width = mouse[0] - this.points.start[0];
|
|
94
|
+
let height = mouse[1] - this.points.start[1];
|
|
95
|
+
|
|
96
|
+
this.points.end = mouse;
|
|
97
|
+
|
|
98
|
+
this.rect.node.attr("width", width);
|
|
99
|
+
this.rect.node.attr("height", height);
|
|
100
|
+
this.rect.node.attr("x", this.points.start[0]);
|
|
101
|
+
this.rect.node.attr("y", this.points.end[0]);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* $project.fileName
|
|
3
|
+
* https://github.com/seatmap/canvas Copyright 2018 Ali Sait TEKE
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
import {dom} from "../../../decorators";
|
|
8
|
+
import SvgBase from "../../svg.base";
|
|
9
|
+
import BlocksSearchCircle from "../blocks.search-circle";
|
|
10
|
+
|
|
11
|
+
@dom({
|
|
12
|
+
tag: "circle",
|
|
13
|
+
class: "circle",
|
|
14
|
+
autoGenerate: false
|
|
15
|
+
})
|
|
16
|
+
export default class Circle extends SvgBase {
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
constructor(public parent: BlocksSearchCircle) {
|
|
20
|
+
super(parent);
|
|
21
|
+
// .attr("r", this.defaults.zoom_focus_circle_radius)
|
|
22
|
+
// .style("display", "none")
|
|
23
|
+
// .classed("zoom-circle", true);
|
|
24
|
+
|
|
25
|
+
this.attr("r", this.parent.global.config.zoom_focus_circle_radius);
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
return this;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
update(): this {
|
|
32
|
+
|
|
33
|
+
this.updateChilds();
|
|
34
|
+
|
|
35
|
+
return this;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* index.ts
|
|
3
|
+
* https://github.com/seatmap/canvas Copyright 2018 Ali Sait TEKE
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import Blocks from "./blocks/blocks.index";
|
|
7
|
+
import Svg from "../svg.index";
|
|
8
|
+
import SvgBase from "../svg.base";
|
|
9
|
+
import {dom} from "../../decorators/dom";
|
|
10
|
+
import BlocksSearchCircle from "./blocks.search-circle";
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@dom({
|
|
15
|
+
tag: "g",
|
|
16
|
+
class: "stage",
|
|
17
|
+
autoGenerate: false
|
|
18
|
+
})
|
|
19
|
+
export default class Stage extends SvgBase {
|
|
20
|
+
|
|
21
|
+
public blocks: Blocks;
|
|
22
|
+
public searchCircle:BlocksSearchCircle;
|
|
23
|
+
|
|
24
|
+
constructor(public parent: Svg) {
|
|
25
|
+
super(parent);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
update() {
|
|
30
|
+
this.blocks = new Blocks(this);
|
|
31
|
+
this.addChild(this.blocks);
|
|
32
|
+
|
|
33
|
+
this.searchCircle = new BlocksSearchCircle(this);
|
|
34
|
+
this.addChild(this.searchCircle);
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
this.updateChilds();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* $project.fileName
|
|
3
|
+
* https://github.com/seatmap/canvas Copyright 2018 Ali Sait TEKE
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import Block from "./stage/blocks/block-item/block-item.index";
|
|
7
|
+
import {GlobalModel} from "../models/global.model";
|
|
8
|
+
import {EventObject} from "./event.manager";
|
|
9
|
+
import {mouse as d3Mouse} from 'd3-selection'
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
export default class SvgBase {
|
|
13
|
+
|
|
14
|
+
public node: any = null;
|
|
15
|
+
public domClass: string = null;
|
|
16
|
+
public domTag: string = null;
|
|
17
|
+
public eventCode: string = null;
|
|
18
|
+
public autoGenerate: boolean = false;
|
|
19
|
+
public tags: Array<string>;
|
|
20
|
+
|
|
21
|
+
public child_items: Array<any> | any;
|
|
22
|
+
|
|
23
|
+
public dom_attrs: Array<any>;
|
|
24
|
+
public dom_classeds: Array<any>;
|
|
25
|
+
|
|
26
|
+
public child_index: number = null;
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
public global: GlobalModel;
|
|
30
|
+
|
|
31
|
+
constructor(public parent: any) {
|
|
32
|
+
this.child_items = [];
|
|
33
|
+
this.dom_attrs = [];
|
|
34
|
+
this.dom_classeds = [];
|
|
35
|
+
this.tags = [];
|
|
36
|
+
|
|
37
|
+
this.eventCode = null;
|
|
38
|
+
|
|
39
|
+
if (typeof parent.global !== "undefined") {
|
|
40
|
+
this.global = parent.global;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (Object(this).dom_params) {
|
|
44
|
+
|
|
45
|
+
if (Object(this).dom_params['tag']) {
|
|
46
|
+
this.domTag = Object(this).dom_params['tag'];
|
|
47
|
+
}
|
|
48
|
+
if (Object(this).dom_params['class']) {
|
|
49
|
+
this.domClass = Object(this).dom_params['class'];
|
|
50
|
+
}
|
|
51
|
+
if (Object(this).dom_params['event_code']) {
|
|
52
|
+
this.eventCode = Object(this).dom_params['event_code'];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (typeof Object(this).dom_params['autoGenerate'] !== "undefined" && Object(this).dom_params['autoGenerate'] === true) {
|
|
56
|
+
this.autoGenerate = true;
|
|
57
|
+
}
|
|
58
|
+
this.generateThisDom();
|
|
59
|
+
return this;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
public generateThisDom(): this {
|
|
63
|
+
if (this.autoGenerate) {
|
|
64
|
+
this.domGenerate(this.parent.node);
|
|
65
|
+
this.afterGenerate();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return this;
|
|
69
|
+
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
public domGenerate(to: any, index: number = 0): this {
|
|
73
|
+
let domTag = this.domTag ? this.domTag : "g";
|
|
74
|
+
this.child_index = index;
|
|
75
|
+
|
|
76
|
+
this.node = to.datum(this.parent).append(domTag);
|
|
77
|
+
|
|
78
|
+
for (let di = 0; di < this.dom_attrs.length; di++) {
|
|
79
|
+
let _dom_attr = this.dom_attrs[di];
|
|
80
|
+
this.node.attr(_dom_attr.name, _dom_attr.value)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (this.domClass) {
|
|
84
|
+
this.node.classed(this.domClass, true);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
for (let ci = 0; ci < this.dom_classeds.length; ci++) {
|
|
89
|
+
let _dom_class = this.dom_classeds[ci];
|
|
90
|
+
this.node.classed(_dom_class.name, _dom_class.value);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return this;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
public attr(name: string, value: string | number): this {
|
|
97
|
+
this.dom_attrs.push({
|
|
98
|
+
name: name,
|
|
99
|
+
value: value
|
|
100
|
+
});
|
|
101
|
+
return this;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
public addChild(item: any, attrs?: any, replace: boolean = true): this {
|
|
105
|
+
for (let key in attrs) {
|
|
106
|
+
let value = attrs[key];
|
|
107
|
+
item.dom_attrs.push({
|
|
108
|
+
name: key,
|
|
109
|
+
value: value
|
|
110
|
+
})
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
this.child_items.push(item);
|
|
114
|
+
return this;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
public classed(className: string, value: boolean = true): this {
|
|
118
|
+
this.dom_classeds.push({
|
|
119
|
+
name: className,
|
|
120
|
+
value: value
|
|
121
|
+
});
|
|
122
|
+
return this;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
public clear(): this {
|
|
127
|
+
this.child_items.map((item: Block) => {
|
|
128
|
+
item.node.remove()
|
|
129
|
+
});
|
|
130
|
+
this.child_items = [];
|
|
131
|
+
return this;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
public updateChilds(): this {
|
|
135
|
+
this.child_items.map((item: Block, index: number) => {
|
|
136
|
+
item.domGenerate(this.node, index);
|
|
137
|
+
item.update();
|
|
138
|
+
});
|
|
139
|
+
this.afterGenerate();
|
|
140
|
+
this.updateEvents(false);
|
|
141
|
+
return this;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
public updateEvents(recursive: boolean = false): this {
|
|
145
|
+
let _self = this;
|
|
146
|
+
|
|
147
|
+
let allowed_event_types: Array<string> = ["click", "mousever", "mouseleave", "mouseout", "mouseenter", "mousemove", "keydown", "keypress", "mousedown", "mouseup","touchstart"];
|
|
148
|
+
|
|
149
|
+
for (let i = 0; i < this.global.eventManager.events.length; i++) {
|
|
150
|
+
let _event = this.global.eventManager.events[i];
|
|
151
|
+
let _split = _event.type.toString().split(".");
|
|
152
|
+
if (_split[0].toLowerCase() === this.eventCode.toLowerCase() && allowed_event_types.indexOf(_split[1].toLowerCase()) !== -1 && typeof _split[1] !== "undefined") {
|
|
153
|
+
this.node.on(_split[1].toLowerCase() + ".globalevent", function (item: EventObject) {
|
|
154
|
+
let _mouse = d3Mouse(_self.parent.node.node());
|
|
155
|
+
_event.fn(_self, item, _mouse);
|
|
156
|
+
})
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (recursive && this.child_items.length > 0) {
|
|
161
|
+
this.child_items.map((child_item: any) => {
|
|
162
|
+
if (typeof child_item.updateEvents === "function") {
|
|
163
|
+
child_item.updateEvents(true);
|
|
164
|
+
}
|
|
165
|
+
})
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return this;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
public addEventListener(eventType: string, cb: any): this {
|
|
172
|
+
this.global.eventManager.addEventListener(eventType, cb);
|
|
173
|
+
this.updateEvents(false);
|
|
174
|
+
return this;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
public addTag(tag: string): this {
|
|
178
|
+
this.tags.push(tag);
|
|
179
|
+
return this;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
public hasTag(tag: string): boolean {
|
|
183
|
+
return this.tags.indexOf(tag) !== -1
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
public getChilds(type: string = null): Array<any> {
|
|
187
|
+
if (type === null) {
|
|
188
|
+
return this.child_items.filter((item: any) => item.constructor.name === type);
|
|
189
|
+
} else {
|
|
190
|
+
return this.child_items;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
public getChildCount(): number {
|
|
195
|
+
return this.child_items.length;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
public beforeGenerate() {
|
|
199
|
+
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
public afterGenerate() {
|
|
203
|
+
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
public addToParent(): this {
|
|
207
|
+
this.parent.addChild(this);
|
|
208
|
+
return this;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
public addTo(container: any): this {
|
|
212
|
+
container.addChild(this);
|
|
213
|
+
return this;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* $project.fileName
|
|
3
|
+
* https://github.com/seatmap/canvas Copyright 2018 Ali Sait TEKE
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import Stage from "./stage/stage.index";
|
|
7
|
+
import {mouse as d3Mouse} from 'd3-selection'
|
|
8
|
+
import "reflect-metadata";
|
|
9
|
+
|
|
10
|
+
import {SeatMapCanvas} from "../canvas.index";
|
|
11
|
+
import SvgBase from "./svg.base";
|
|
12
|
+
import {dom} from "../decorators/dom";
|
|
13
|
+
import {EventType, ZoomLevel} from "../enums/global";
|
|
14
|
+
import ZoomOutBg from "./zoom-out.bg";
|
|
15
|
+
import Legend from "./legend";
|
|
16
|
+
import Tooltip from "./tooltip";
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
declare const window: any;
|
|
21
|
+
|
|
22
|
+
@dom({
|
|
23
|
+
tag: "svg",
|
|
24
|
+
class: "seatmap-svg",
|
|
25
|
+
autoGenerate: false
|
|
26
|
+
})
|
|
27
|
+
export default class Svg extends SvgBase {
|
|
28
|
+
public stage: Stage;
|
|
29
|
+
public zoomOutBg: ZoomOutBg;
|
|
30
|
+
public legend: Legend;
|
|
31
|
+
public tooltip: Tooltip;
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
constructor(public parent: SeatMapCanvas) {
|
|
35
|
+
super(parent);
|
|
36
|
+
this.global.eventManager.addEventListener(EventType.ZOOM_LEVEL_CHANGE, (zoom_level: any) => {
|
|
37
|
+
this.node.classed("zoom-level-" + ZoomLevel.SEAT, false);
|
|
38
|
+
this.node.classed("zoom-level-" + ZoomLevel.BLOCK, false);
|
|
39
|
+
this.node.classed("zoom-level-" + ZoomLevel.VENUE, false);
|
|
40
|
+
this.node.classed("zoom-level-" + zoom_level.level, true);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
//this.update();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
update() {
|
|
48
|
+
this.stage = new Stage(this).addToParent();
|
|
49
|
+
this.zoomOutBg = new ZoomOutBg(this).addToParent();
|
|
50
|
+
if(this.global.config.legend_show){
|
|
51
|
+
this.legend = new Legend(this).addToParent();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
this.tooltip = new Tooltip(this).addToParent();
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
this.updateChilds();
|
|
58
|
+
|
|
59
|
+
this.stage.node.raise();
|
|
60
|
+
if(this.global.config.legend_show){
|
|
61
|
+
this.legend.node.raise();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
this.tooltip.node.raise();
|
|
65
|
+
|
|
66
|
+
this.node.on("mousemove", () => {
|
|
67
|
+
let cor = d3Mouse(this.stage.node.node());
|
|
68
|
+
this.parent.eventManager.dispatch(EventType.MOUSE_MOVE, cor);
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
//this.stage.updateEvents(true);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* $project.fileName
|
|
3
|
+
* https://github.com/seatmap/canvas Copyright 2018 Ali Sait TEKE
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
import {dom} from "../../decorators";
|
|
8
|
+
import SvgBase from "../svg.base";
|
|
9
|
+
|
|
10
|
+
import {line as d3Line} from "d3-shape";
|
|
11
|
+
import Tooltip from "../tooltip";
|
|
12
|
+
|
|
13
|
+
@dom({
|
|
14
|
+
tag: "rect",
|
|
15
|
+
class: "tooltip-rect",
|
|
16
|
+
autoGenerate: false
|
|
17
|
+
})
|
|
18
|
+
export default class TooltipRect extends SvgBase {
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
constructor(public parent: Tooltip) {
|
|
22
|
+
super(parent);
|
|
23
|
+
this.attr("width", this.global.config.tooltip_style.width);
|
|
24
|
+
this.attr("height", this.global.config.tooltip_style.height);
|
|
25
|
+
this.attr("x", 0);
|
|
26
|
+
this.attr("y", 0);
|
|
27
|
+
this.attr("rx", 3);
|
|
28
|
+
this.attr("ry", 3);
|
|
29
|
+
|
|
30
|
+
const data:any = [
|
|
31
|
+
{'x': 0, 'y': 0},
|
|
32
|
+
{'x': 0, 'y': 30},
|
|
33
|
+
{'x': 30, 'y': 30},
|
|
34
|
+
{'x': 30, 'y': 0},
|
|
35
|
+
{'x': 0, 'y': 0},
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
const line = d3Line()
|
|
39
|
+
.x((d: any) => {
|
|
40
|
+
return d['x'];
|
|
41
|
+
})
|
|
42
|
+
.y((d: any) => {
|
|
43
|
+
return d['y'];
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
this.attr("fill", this.global.config.tooltip_style.bg);
|
|
47
|
+
this.attr("stroke", "rgba(0,0,0,0.3)");
|
|
48
|
+
this.attr("stroke-width", "1px");
|
|
49
|
+
this.attr("opacity", 0.8);
|
|
50
|
+
|
|
51
|
+
//this.attr('d', line(data));
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
return this;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
update(): this {
|
|
58
|
+
this.updateChilds();
|
|
59
|
+
return this;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
afterGenerate() {
|
|
63
|
+
|
|
64
|
+
this.node.style("pointer-events", "none");
|
|
65
|
+
}
|
|
66
|
+
}
|