dbm 1.1.4 → 1.1.6
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/dbm.js +25 -0
- package/flow/controllers/index.js +3 -1
- package/flow/controllers/interaction/MoveElement.js +179 -0
- package/flow/controllers/interaction/index.js +1 -0
- package/flow/controllers/transform/PartOfObject.js +51 -0
- package/flow/controllers/transform/index.js +1 -0
- package/flow/updatefunctions/dom/ElementPosition.js +1 -1
- package/flow/updatefunctions/logic/PositionedItems.js +68 -0
- package/flow/updatefunctions/logic/index.js +1 -0
- package/package.json +1 -1
- package/react/BaseObject.js +4 -0
- package/react/admin/index.js +2 -1
- package/react/admin/pages/PageList.js +66 -0
- package/react/admin/pages/index.js +1 -0
- package/react/blocks/index.js +1 -0
- package/react/image/ContainScaledImage.js +37 -0
- package/react/image/index.js +1 -0
- package/site/SiteNavigation.js +6 -2
- package/tracking/Controller.js +1 -1
- package/tracking/MetaPixelTracker.js +7 -1
- package/tracking/TagManagerTracker.js +58 -0
- package/tracking/index.js +13 -1
- package/utils/ArrayFunctions.js +1 -1
package/dbm.js
CHANGED
|
@@ -57,6 +57,31 @@ export let objectPath = function(aObject, aPath) {
|
|
|
57
57
|
return currentObject;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
export let setAtObjectPath = function(aObject, aPath, aValue) {
|
|
61
|
+
aPath += "";
|
|
62
|
+
if(aPath.length === 0) {
|
|
63
|
+
return 0;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
let baseObject = aObject;
|
|
67
|
+
let propertyName = aPath;
|
|
68
|
+
|
|
69
|
+
let paths = aPath.split(".");
|
|
70
|
+
if(paths.length > 1) {
|
|
71
|
+
propertyName = paths.pop();
|
|
72
|
+
|
|
73
|
+
baseObject = objectPath(baseObject, paths.join("."));
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if(baseObject) {
|
|
77
|
+
let partAsInt = parseInt(propertyName, 10);
|
|
78
|
+
if(partAsInt.toString() === propertyName) {
|
|
79
|
+
propertyName = partAsInt;
|
|
80
|
+
}
|
|
81
|
+
baseObject[propertyName] = aValue;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
60
85
|
export * as utils from "./utils/index.js";
|
|
61
86
|
export * as core from "./core/index.js";
|
|
62
87
|
export * as loading from "./loading/index.js";
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import Dbm from "../../../index.js";
|
|
2
|
+
|
|
3
|
+
export default class MoveElement extends Dbm.core.BaseObject {
|
|
4
|
+
_construct() {
|
|
5
|
+
super._construct();
|
|
6
|
+
|
|
7
|
+
this._element = null;
|
|
8
|
+
this._startX = 0;
|
|
9
|
+
this._startY = 0;
|
|
10
|
+
this._startXParameter = 0;
|
|
11
|
+
this._startYParameter = 0;
|
|
12
|
+
|
|
13
|
+
this._callback_mouseMoveBound = this._callback_mouseMove.bind(this);
|
|
14
|
+
this._callback_mouseUpBound = this._callback_mouseUp.bind(this);
|
|
15
|
+
this._callback_startDragBound = this._callback_startDrag.bind(this);
|
|
16
|
+
|
|
17
|
+
this.item.requireProperty("element", null);
|
|
18
|
+
Dbm.flow.addUpdateCommand(this.item.properties.element, Dbm.commands.callFunction(this._elementUpdated.bind(this)));
|
|
19
|
+
|
|
20
|
+
let updateXCommand = Dbm.commands.callFunction(this._updateX.bind(this));
|
|
21
|
+
let updateYCommand = Dbm.commands.callFunction(this._updateY.bind(this));
|
|
22
|
+
|
|
23
|
+
let clampXCommand = Dbm.commands.callFunction(this._clampX.bind(this));
|
|
24
|
+
let clampYCommand = Dbm.commands.callFunction(this._clampY.bind(this));
|
|
25
|
+
|
|
26
|
+
this.item.requireProperty("minX", 0);
|
|
27
|
+
Dbm.flow.addUpdateCommand(this.item.properties.minX, updateXCommand);
|
|
28
|
+
Dbm.flow.addUpdateCommand(this.item.properties.minX, clampXCommand);
|
|
29
|
+
this.item.requireProperty("maxX", 0);
|
|
30
|
+
Dbm.flow.addUpdateCommand(this.item.properties.maxX, updateXCommand);
|
|
31
|
+
Dbm.flow.addUpdateCommand(this.item.properties.maxX, clampXCommand);
|
|
32
|
+
|
|
33
|
+
this.item.requireProperty("minY", 0);
|
|
34
|
+
Dbm.flow.addUpdateCommand(this.item.properties.minY, updateYCommand);
|
|
35
|
+
Dbm.flow.addUpdateCommand(this.item.properties.minY, clampYCommand);
|
|
36
|
+
this.item.requireProperty("maxY", 0);
|
|
37
|
+
Dbm.flow.addUpdateCommand(this.item.properties.maxY, updateYCommand);
|
|
38
|
+
Dbm.flow.addUpdateCommand(this.item.properties.maxY, clampYCommand);
|
|
39
|
+
|
|
40
|
+
this.item.requireProperty("xParameter", 0);
|
|
41
|
+
Dbm.flow.addUpdateCommand(this.item.properties.xParameter, updateXCommand);
|
|
42
|
+
this.item.requireProperty("yParameter", 0);
|
|
43
|
+
Dbm.flow.addUpdateCommand(this.item.properties.yParameter, updateYCommand);
|
|
44
|
+
|
|
45
|
+
this.item.requireProperty("scaleX", 1);
|
|
46
|
+
Dbm.flow.addUpdateCommand(this.item.properties.scaleX, updateXCommand);
|
|
47
|
+
this.item.requireProperty("scaleY", 1);
|
|
48
|
+
Dbm.flow.addUpdateCommand(this.item.properties.scaleY, updateYCommand);
|
|
49
|
+
|
|
50
|
+
this.item.requireProperty("invertX", 1);
|
|
51
|
+
this.item.requireProperty("invertY", 1);
|
|
52
|
+
|
|
53
|
+
this.item.requireProperty("x", 0);
|
|
54
|
+
this.item.requireProperty("y", 0);
|
|
55
|
+
|
|
56
|
+
this.item.requireProperty("isDragging", false);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
_elementUpdated() {
|
|
60
|
+
console.log("_elementUpdated");
|
|
61
|
+
|
|
62
|
+
if(this._element) {
|
|
63
|
+
let element = this._element;
|
|
64
|
+
element.removeEventListener("mousedown", this._callback_startDragBound);
|
|
65
|
+
element.removeEventListener("touchstart", this._callback_startDragBound);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if(this.item.element) {
|
|
69
|
+
let element = this.item.element;
|
|
70
|
+
element.addEventListener("mousedown", this._callback_startDragBound);
|
|
71
|
+
element.addEventListener("touchstart", this._callback_startDragBound);
|
|
72
|
+
}
|
|
73
|
+
this._element = this.item.element;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
_updateX() {
|
|
77
|
+
this.item.x = this.item.xParameter*this.item.scaleX;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
_clampX() {
|
|
81
|
+
let minX = this.item.minX;
|
|
82
|
+
let maxX = this.item.maxX;
|
|
83
|
+
|
|
84
|
+
this.item.xParameter = Math.max(minX, Math.min(this.item.xParameter, maxX));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
_clampY() {
|
|
88
|
+
let minY = this.item.minY;
|
|
89
|
+
let maxY = this.item.maxY;
|
|
90
|
+
|
|
91
|
+
this.item.yParameter = Math.max(minY, Math.min(this.item.yParameter, maxY));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
_updateY() {
|
|
95
|
+
this.item.y = this.item.yParameter*this.item.scaleY;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
_startMove(aX, aY) {
|
|
100
|
+
//console.log(aX, aY);
|
|
101
|
+
|
|
102
|
+
this._startXParameter = this.item.xParameter;
|
|
103
|
+
this._startYParameter = this.item.yParameter;
|
|
104
|
+
this._startX = aX;
|
|
105
|
+
this._startY = aY;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
_updateMove(aX, aY) {
|
|
109
|
+
console.log("_updateMove");
|
|
110
|
+
//console.log(aX, aY);
|
|
111
|
+
|
|
112
|
+
let x = this._startXParameter + this.item.invertX*(aX-this._startX)/this.item.scaleX;
|
|
113
|
+
let y = this._startYParameter + this.item.invertY*(aY-this._startY)/this.item.scaleY;
|
|
114
|
+
|
|
115
|
+
let minX = this.item.minX;
|
|
116
|
+
let maxX = this.item.maxX;
|
|
117
|
+
|
|
118
|
+
let minY = this.item.minY;
|
|
119
|
+
let maxY = this.item.maxY;
|
|
120
|
+
|
|
121
|
+
this.item.xParameter = Math.max(minX, Math.min(x, maxX));
|
|
122
|
+
this.item.yParameter = Math.max(minY, Math.min(y, maxY));
|
|
123
|
+
|
|
124
|
+
console.log(this.item.xParameter);
|
|
125
|
+
console.log(this.item.yParameter);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
_callback_mouseUp(aEvent) {
|
|
129
|
+
console.log("_callback_mouseUp");
|
|
130
|
+
//console.log(aEvent);
|
|
131
|
+
|
|
132
|
+
if(aEvent.type === "touchend") {
|
|
133
|
+
this._updateMove(aEvent.touches[0].pageX, aEvent.touches[0].pageY);
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
this._updateMove(aEvent.pageX, aEvent.pageY);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
document.removeEventListener("mousemove", this._callback_mouseMoveBound, false);
|
|
140
|
+
document.removeEventListener("mouseup", this._callback_mouseUpBound, false);
|
|
141
|
+
|
|
142
|
+
document.removeEventListener("touchmove", this._callback_mouseMoveBound, false);
|
|
143
|
+
document.removeEventListener("touchup", this._callback_mouseUpBound, false);
|
|
144
|
+
|
|
145
|
+
this.item.isDragging = false;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
_callback_mouseMove(aEvent) {
|
|
149
|
+
console.log("_callback_mouseMove");
|
|
150
|
+
//console.log(aEvent);
|
|
151
|
+
|
|
152
|
+
if(aEvent.type === "touchmove") {
|
|
153
|
+
this._updateMove(aEvent.touches[0].pageX, aEvent.touches[0].pageY);
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
this._updateMove(aEvent.pageX, aEvent.pageY);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
_callback_startDrag(aEvent) {
|
|
161
|
+
console.log("_callback_startDrag");
|
|
162
|
+
//console.log(aEvent, aEvent.type);
|
|
163
|
+
|
|
164
|
+
if(aEvent.type === "touchstart") {
|
|
165
|
+
this._startMove(aEvent.touches[0].pageX, aEvent.touches[0].pageY);
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
this._startMove(aEvent.pageX, aEvent.pageY);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
document.addEventListener("mousemove", this._callback_mouseMoveBound, false);
|
|
172
|
+
document.addEventListener("mouseup", this._callback_mouseUpBound, false);
|
|
173
|
+
|
|
174
|
+
document.addEventListener("touchmove", this._callback_mouseMoveBound, false);
|
|
175
|
+
document.addEventListener("touchup", this._callback_mouseUpBound, false);
|
|
176
|
+
|
|
177
|
+
this.item.isDragging = true;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {default as MoveElement} from "./MoveElement.js";
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import Dbm from "../../../index.js";
|
|
2
|
+
|
|
3
|
+
export default class PartOfObject extends Dbm.core.BaseObject {
|
|
4
|
+
_construct() {
|
|
5
|
+
super._construct();
|
|
6
|
+
|
|
7
|
+
this.item.requireProperty("object", null);
|
|
8
|
+
this.item.requireProperty("path", null);
|
|
9
|
+
this.item.requireProperty("value", null);
|
|
10
|
+
|
|
11
|
+
this._lastUpdatedValue = null;
|
|
12
|
+
|
|
13
|
+
let objectUpdatedCommand = Dbm.commands.callFunction(this._objectUpdated.bind(this));
|
|
14
|
+
Dbm.flow.addUpdateCommand(this.item.properties.object, objectUpdatedCommand);
|
|
15
|
+
Dbm.flow.addUpdateCommand(this.item.properties.path, objectUpdatedCommand);
|
|
16
|
+
|
|
17
|
+
Dbm.flow.addUpdateCommand(this.item.properties.value, Dbm.commands.callFunction(this._valueUpdated.bind(this)));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
_objectUpdated() {
|
|
21
|
+
console.log("_objectUpdated");
|
|
22
|
+
|
|
23
|
+
if(this.item.path !== null) {
|
|
24
|
+
let stringValue = JSON.stringify(Dbm.objectPath(this.item.object, this.item.path));
|
|
25
|
+
|
|
26
|
+
if(stringValue !== this._lastUpdatedValue) {
|
|
27
|
+
this._lastUpdatedValue = stringValue;
|
|
28
|
+
let newValue = JSON.parse(stringValue);
|
|
29
|
+
this.item.value = newValue;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
_valueUpdated() {
|
|
35
|
+
console.log("_valueUpdated");
|
|
36
|
+
|
|
37
|
+
if(this.item.path !== null) {
|
|
38
|
+
let stringValue = JSON.stringify(this.item.value);
|
|
39
|
+
|
|
40
|
+
if(stringValue !== this._lastUpdatedValue) {
|
|
41
|
+
this._lastUpdatedValue = stringValue;
|
|
42
|
+
let object = JSON.parse(JSON.stringify(this.item.object));
|
|
43
|
+
Dbm.setAtObjectPath(object, this.item.path, JSON.parse(stringValue));
|
|
44
|
+
|
|
45
|
+
this.item.properties.object.getMostUpstreamProperty().value = object;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {default as PartOfObject} from "./PartOfObject.js";
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import Dbm from "../../../index.js";
|
|
2
|
+
|
|
3
|
+
export default class PoisitonedItems extends Dbm.flow.FlowUpdateFunction {
|
|
4
|
+
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
|
|
8
|
+
this.input.register("elementWidth", 0);
|
|
9
|
+
this.input.register("itemWidth", 0);
|
|
10
|
+
this.input.register("itemSpacing", 0);
|
|
11
|
+
this.input.register("padding", 0);
|
|
12
|
+
this.input.register("numberOfItems", 0);
|
|
13
|
+
|
|
14
|
+
this.output.register("startPosition", 0);
|
|
15
|
+
this.output.register("parameterLength", 0);
|
|
16
|
+
|
|
17
|
+
this.output.register("minParameter", 0);
|
|
18
|
+
this.output.register("maxParameter", 0);
|
|
19
|
+
|
|
20
|
+
/*
|
|
21
|
+
let parameter = minParameter;
|
|
22
|
+
|
|
23
|
+
let x = padding+startPosition-parameter*parameterLength;
|
|
24
|
+
|
|
25
|
+
console.log(minParameter, maxParameter, fullWidth, startPosition);
|
|
26
|
+
console.log(x);
|
|
27
|
+
|
|
28
|
+
parameter = maxParameter;
|
|
29
|
+
|
|
30
|
+
x = padding+startPosition-parameter*parameterLength;
|
|
31
|
+
|
|
32
|
+
console.log(x);
|
|
33
|
+
*/
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
_update() {
|
|
37
|
+
//console.log("_update");
|
|
38
|
+
|
|
39
|
+
let elementWidth = this.input.elementWidth;
|
|
40
|
+
let itemWidth = this.input.itemWidth;
|
|
41
|
+
let itemSpacing = this.input.itemSpacing;
|
|
42
|
+
let padding = this.input.padding;
|
|
43
|
+
|
|
44
|
+
let visualWidth = elementWidth-2*padding;
|
|
45
|
+
let startPosition = (visualWidth-itemWidth)/2;
|
|
46
|
+
|
|
47
|
+
let parameterLength = itemWidth+itemSpacing;
|
|
48
|
+
let fullWidth = this.input.numberOfItems*parameterLength-itemSpacing;
|
|
49
|
+
|
|
50
|
+
let minParameter = 0;
|
|
51
|
+
let maxParameter = 0;
|
|
52
|
+
|
|
53
|
+
if(fullWidth > visualWidth) {
|
|
54
|
+
minParameter = startPosition/parameterLength;
|
|
55
|
+
maxParameter = (fullWidth-(visualWidth-startPosition))/parameterLength;
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
startPosition = (visualWidth-fullWidth)/2;
|
|
59
|
+
parameterLength = 0;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
this.output.startPosition = startPosition;
|
|
63
|
+
this.output.parameterLength = parameterLength;
|
|
64
|
+
|
|
65
|
+
this.output.minParameter = minParameter;
|
|
66
|
+
this.output.maxParameter = maxParameter;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -11,6 +11,7 @@ export {default as Any} from "./Any.js";
|
|
|
11
11
|
export {default as AllAtValue} from "./AllAtValue.js";
|
|
12
12
|
export {default as WhenMatched} from "./WhenMatched.js";
|
|
13
13
|
export {default as Invert} from "./Invert.js";
|
|
14
|
+
export {default as PositionedItems} from "./PositionedItems.js";
|
|
14
15
|
|
|
15
16
|
export let subtract = function(aInput1 = 0, aInput2 = 0) {
|
|
16
17
|
let updateFunction = new Dbm.flow.updatefunctions.logic.Subtraction();
|
package/package.json
CHANGED
package/react/BaseObject.js
CHANGED
package/react/admin/index.js
CHANGED
|
@@ -2,4 +2,5 @@ export {default as CreatePage} from "./CreatePage.js";
|
|
|
2
2
|
export {default as EditPage} from "./EditPage.js";
|
|
3
3
|
export {default as SelectImageFromLibrary} from "./SelectImageFromLibrary.js";
|
|
4
4
|
|
|
5
|
-
export * as editor from "./editor/index.js";
|
|
5
|
+
export * as editor from "./editor/index.js";
|
|
6
|
+
export * as pages from "./pages/index.js";
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Dbm from "../../../index.js";
|
|
3
|
+
|
|
4
|
+
export default class PageList extends Dbm.react.BaseObject {
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
|
|
8
|
+
let graphApi = Dbm.getInstance().repository.getItem("graphApi").controller;
|
|
9
|
+
|
|
10
|
+
this.item.requireProperty("items", []);
|
|
11
|
+
|
|
12
|
+
let request = graphApi.requestRange(
|
|
13
|
+
[
|
|
14
|
+
{"type": "includePrivate"},
|
|
15
|
+
{"type": "includeDraft"},
|
|
16
|
+
{"type": "byObjectType", "objectType": "page"},
|
|
17
|
+
],
|
|
18
|
+
["urlRequest"]
|
|
19
|
+
);
|
|
20
|
+
Dbm.flow.addUpdateCommandWhenMatched(request.properties.status, Dbm.loading.LoadingStatus.LOADED, Dbm.commands.callFunction(this._loaded.bind(this), [request]));
|
|
21
|
+
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
_loaded(aRequest) {
|
|
25
|
+
console.log("_loaded");
|
|
26
|
+
console.log(aRequest);
|
|
27
|
+
|
|
28
|
+
let items = [...aRequest.items];
|
|
29
|
+
let field = "url";
|
|
30
|
+
items.sort(function(aA, aB) {
|
|
31
|
+
|
|
32
|
+
let aValue = Dbm.objectPath(aA, field);
|
|
33
|
+
let bValue = Dbm.objectPath(aB, field);
|
|
34
|
+
|
|
35
|
+
if(aValue < bValue) {
|
|
36
|
+
return -1;
|
|
37
|
+
}
|
|
38
|
+
else if(aValue < bValue) {
|
|
39
|
+
return 1;
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
return 0;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
console.log(items);
|
|
47
|
+
|
|
48
|
+
this.item.setValue("items", items);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
_renderMainElement() {
|
|
52
|
+
|
|
53
|
+
return React.createElement("div", {"className": "centered-site"},
|
|
54
|
+
React.createElement(Dbm.react.area.List, {"items": this.item.properties.items},
|
|
55
|
+
React.createElement("div", {},
|
|
56
|
+
React.createElement(Dbm.react.text.Link, {"href": Dbm.react.source.contextVariable("item.url")},
|
|
57
|
+
Dbm.react.text.text(Dbm.react.source.contextVariable("item.url")),
|
|
58
|
+
" - ",
|
|
59
|
+
Dbm.react.text.text(Dbm.react.source.contextVariable("item.title")),
|
|
60
|
+
)
|
|
61
|
+
)
|
|
62
|
+
)
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {default as PageList} from "./PageList.js";
|
package/react/blocks/index.js
CHANGED
|
@@ -100,4 +100,5 @@ export let getDefaultEditorModule = function() {
|
|
|
100
100
|
export let registerAllBlocks = function() {
|
|
101
101
|
registerBlock("cookie/settings", "Cookie settings", createElement(Dbm.react.cookies.CookieSettings));
|
|
102
102
|
registerBlock("login/loginForm", "Login form", createElement(Dbm.react.login.LoginForm));
|
|
103
|
+
registerBlock("admin/pageList", "Admin / Page list", createElement(Dbm.react.admin.pages.PageList), createElement(Dbm.react.admin.pages.PageList));
|
|
103
104
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import Dbm from "../../index.js";
|
|
2
|
+
import React from "react";
|
|
3
|
+
|
|
4
|
+
export default class ContainedScaledImage extends Dbm.react.BaseObject {
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
_removedUsedProps(aProps) {
|
|
10
|
+
delete aProps["image"];
|
|
11
|
+
delete aProps["targetWidth"];
|
|
12
|
+
delete aProps["targetHeight"];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
_renderMainElement() {
|
|
16
|
+
|
|
17
|
+
let image = this.getPropValue("image");
|
|
18
|
+
let width = this.getPropValue("targetWidth");
|
|
19
|
+
let height = this.getPropValue("targetHeight");
|
|
20
|
+
let url = Dbm.utils.UrlFunctions.createContainScaledImageUrl(image, width, height);
|
|
21
|
+
|
|
22
|
+
let newProps = this._copyProps({src: url});
|
|
23
|
+
|
|
24
|
+
let altText = Dbm.objectPath(image, "altText");
|
|
25
|
+
if(altText) {
|
|
26
|
+
newProps["alt"] = altText;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
let elementType = this.getPropValue("elementType");
|
|
30
|
+
if(elementType) {
|
|
31
|
+
newProps["elementType"] = elementType;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return React.createElement(Dbm.react.image.Image, newProps, this.getPropValue("children"));
|
|
35
|
+
|
|
36
|
+
}
|
|
37
|
+
}
|
package/react/image/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export {default as Image} from "./Image.js";
|
|
2
2
|
export {default as WidthScaledImage} from "./WidthScaledImage.js";
|
|
3
3
|
export {default as CoverScaledImage} from "./CoverScaledImage.js";
|
|
4
|
+
export {default as ContainScaledImage} from "./ContainScaledImage.js";
|
|
4
5
|
export {default as LocalImage} from "./LocalImage.js";
|
package/site/SiteNavigation.js
CHANGED
|
@@ -172,7 +172,7 @@ export default class SiteNavigation extends Dbm.core.BaseObject {
|
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
-
history.pushState({}, "
|
|
175
|
+
history.pushState({}, "", aUrl);
|
|
176
176
|
this.item.url = aUrl;
|
|
177
177
|
|
|
178
178
|
this._addUrlToPath(aUrl);
|
|
@@ -201,9 +201,13 @@ export default class SiteNavigation extends Dbm.core.BaseObject {
|
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
+
updateQueryString(aUrl) {
|
|
205
|
+
history.replaceState({}, "", aUrl);
|
|
206
|
+
}
|
|
207
|
+
|
|
204
208
|
setUrlFromLocation() {
|
|
205
209
|
let url = document.location.href;
|
|
206
|
-
this.item.url = url
|
|
210
|
+
this.item.url = url;
|
|
207
211
|
|
|
208
212
|
this._addUrlToPath(url);
|
|
209
213
|
|
package/tracking/Controller.js
CHANGED
|
@@ -197,7 +197,7 @@ export default class Controller extends Dbm.core.BaseObject {
|
|
|
197
197
|
|
|
198
198
|
}
|
|
199
199
|
|
|
200
|
-
|
|
200
|
+
trackCheckoutStarted(aProductOrProducts) {
|
|
201
201
|
let items = Dbm.utils.ArrayFunctions.singleOrArray(aProductOrProducts);
|
|
202
202
|
|
|
203
203
|
let data = {
|
|
@@ -4,7 +4,8 @@ export default class MetaPixelTracker extends Dbm.core.BaseObject {
|
|
|
4
4
|
_construct() {
|
|
5
5
|
super._construct();
|
|
6
6
|
|
|
7
|
-
this.
|
|
7
|
+
this._isStarted = false;
|
|
8
|
+
this.item.requireProperty("pixelId");
|
|
8
9
|
}
|
|
9
10
|
|
|
10
11
|
_setupFunction() {
|
|
@@ -45,6 +46,7 @@ export default class MetaPixelTracker extends Dbm.core.BaseObject {
|
|
|
45
46
|
|
|
46
47
|
startMarketingTracking() {
|
|
47
48
|
|
|
49
|
+
this._isStarted = true;
|
|
48
50
|
this._setupFunction();
|
|
49
51
|
Dbm.loading.loadScript("https://connect.facebook.net/en_US/fbevents.js");
|
|
50
52
|
|
|
@@ -85,6 +87,8 @@ export default class MetaPixelTracker extends Dbm.core.BaseObject {
|
|
|
85
87
|
console.log("trackEvent");
|
|
86
88
|
console.log(aEventName, aData);
|
|
87
89
|
|
|
90
|
+
if(!this._isStarted) return;
|
|
91
|
+
|
|
88
92
|
if(aEventName === "Purchase") {
|
|
89
93
|
window.fbq('track', 'Purchase', this._convertGooogleAnalyctisData(aData), {eventID: aData.transaction_id});
|
|
90
94
|
}
|
|
@@ -103,10 +107,12 @@ export default class MetaPixelTracker extends Dbm.core.BaseObject {
|
|
|
103
107
|
}
|
|
104
108
|
|
|
105
109
|
trackCurrentPage() {
|
|
110
|
+
if(!this._isStarted) return;
|
|
106
111
|
window.fbq("track", "PageView");
|
|
107
112
|
}
|
|
108
113
|
|
|
109
114
|
trackPage(aUrl) {
|
|
115
|
+
if(!this._isStarted) return;
|
|
110
116
|
window.fbq("track", "PageView");
|
|
111
117
|
}
|
|
112
118
|
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import Dbm from "../index.js";
|
|
2
|
+
|
|
3
|
+
export default class TagManagerTracker extends Dbm.core.BaseObject {
|
|
4
|
+
_construct() {
|
|
5
|
+
super._construct();
|
|
6
|
+
|
|
7
|
+
this.item.requireProperty("tagManagerId");
|
|
8
|
+
this.item.requireProperty("customDataLayerName");
|
|
9
|
+
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
loadTagManager() {
|
|
13
|
+
|
|
14
|
+
let id = this.item.tagManagerId;
|
|
15
|
+
|
|
16
|
+
let url = "https://www.googletagmanager.com/gtm.js?id="+id;
|
|
17
|
+
if(this.item.customDataLayerName) {
|
|
18
|
+
url += "&l=" + this.customDataLayerName;
|
|
19
|
+
}
|
|
20
|
+
Dbm.loading.loadScript(url);
|
|
21
|
+
|
|
22
|
+
return this;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
startTracking() {
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
startStatisticsTracking() {
|
|
30
|
+
console.log("TagManagerTracker::startStatisticsTracking");
|
|
31
|
+
this.loadTagManager();
|
|
32
|
+
|
|
33
|
+
return this;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
startMarketingTracking() {
|
|
37
|
+
|
|
38
|
+
this.loadTagManager();
|
|
39
|
+
|
|
40
|
+
return this;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
stopTracking() {
|
|
44
|
+
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
trackEvent(aEventName, aData) {
|
|
48
|
+
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
trackCurrentPage() {
|
|
52
|
+
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
trackPage(aUrl) {
|
|
56
|
+
|
|
57
|
+
}
|
|
58
|
+
}
|
package/tracking/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import Dbm from "../index.js";
|
|
|
3
3
|
export {default as Controller} from "./Controller.js";
|
|
4
4
|
export {default as DataLayerTracker} from "./DataLayerTracker.js";
|
|
5
5
|
export {default as MetaPixelTracker} from "./MetaPixelTracker.js";
|
|
6
|
+
export {default as TagManagerTracker} from "./TagManagerTracker.js";
|
|
6
7
|
|
|
7
8
|
export const setup = function() {
|
|
8
9
|
|
|
@@ -19,5 +20,16 @@ export const setup = function() {
|
|
|
19
20
|
export const addMetaPixel = function(aPixelId) {
|
|
20
21
|
let tracker = new Dbm.tracking.MetaPixelTracker();
|
|
21
22
|
tracker.item.pixelId = aPixelId;
|
|
22
|
-
Dbm.getInstance().repository.getItem("trackingController").controller.addTracker();
|
|
23
|
+
Dbm.getInstance().repository.getItem("trackingController").controller.addTracker(tracker.item);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const setCurrency = function(aCurrency) {
|
|
27
|
+
Dbm.getInstance().repository.getItem("trackingController").currency = aCurrency;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const addTagManagerTracking = function(aId) {
|
|
31
|
+
console.log("addTagManagerTracking");
|
|
32
|
+
let tracker = new Dbm.tracking.TagManagerTracker();
|
|
33
|
+
tracker.item.tagManagerId = aId;
|
|
34
|
+
Dbm.getInstance().repository.getItem("trackingController").controller.addTracker(tracker.item);
|
|
23
35
|
}
|
package/utils/ArrayFunctions.js
CHANGED
|
@@ -138,7 +138,7 @@ export const mapField = function(aArray, aField) {
|
|
|
138
138
|
|
|
139
139
|
let currentArray = aArray;
|
|
140
140
|
let currentArrayLength = currentArray.length;
|
|
141
|
-
let returnArray = new Array(
|
|
141
|
+
let returnArray = new Array(currentArrayLength);
|
|
142
142
|
for(let i = 0; i < currentArrayLength; i++) {
|
|
143
143
|
returnArray[i] = Dbm.objectPath(aArray[i], aField);
|
|
144
144
|
}
|