1 | const Constants = require('../constants');
|
2 |
|
3 | module.exports = {
|
4 | isOfMetaType: function(type) {
|
5 | return function(e) {
|
6 | const featureTarget = e.featureTarget;
|
7 | if (!featureTarget) return false;
|
8 | if (!featureTarget.properties) return false;
|
9 | return featureTarget.properties.meta === type;
|
10 | };
|
11 | },
|
12 | isShiftMousedown: function(e) {
|
13 | if (!e.originalEvent) return false;
|
14 | if (!e.originalEvent.shiftKey) return false;
|
15 | return e.originalEvent.button === 0;
|
16 | },
|
17 | isActiveFeature: function(e) {
|
18 | if (!e.featureTarget) return false;
|
19 | if (!e.featureTarget.properties) return false;
|
20 | return e.featureTarget.properties.active === Constants.activeStates.ACTIVE &&
|
21 | e.featureTarget.properties.meta === Constants.meta.FEATURE;
|
22 | },
|
23 | isInactiveFeature: function(e) {
|
24 | if (!e.featureTarget) return false;
|
25 | if (!e.featureTarget.properties) return false;
|
26 | return e.featureTarget.properties.active === Constants.activeStates.INACTIVE &&
|
27 | e.featureTarget.properties.meta === Constants.meta.FEATURE;
|
28 | },
|
29 | noTarget: function(e) {
|
30 | return e.featureTarget === undefined;
|
31 | },
|
32 | isFeature: function(e) {
|
33 | if (!e.featureTarget) return false;
|
34 | if (!e.featureTarget.properties) return false;
|
35 | return e.featureTarget.properties.meta === Constants.meta.FEATURE;
|
36 | },
|
37 | isVertex: function(e) {
|
38 | const featureTarget = e.featureTarget;
|
39 | if (!featureTarget) return false;
|
40 | if (!featureTarget.properties) return false;
|
41 | return featureTarget.properties.meta === Constants.meta.VERTEX;
|
42 | },
|
43 | isShiftDown: function(e) {
|
44 | if (!e.originalEvent) return false;
|
45 | return e.originalEvent.shiftKey === true;
|
46 | },
|
47 | isEscapeKey: function(e) {
|
48 | return e.keyCode === 27;
|
49 | },
|
50 | isEnterKey: function(e) {
|
51 | return e.keyCode === 13;
|
52 | },
|
53 | true: function() {
|
54 | return true;
|
55 | }
|
56 | };
|