dbm 1.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.
Files changed (90) hide show
  1. package/commands/CallFunction.js +21 -0
  2. package/commands/CommandBaseObject.js +11 -0
  3. package/commands/ResolvePromise.js +20 -0
  4. package/commands/index.js +36 -0
  5. package/core/BaseObject.js +23 -0
  6. package/core/GlobalObject.js +18 -0
  7. package/core/LifeCycleObject.js +25 -0
  8. package/core/index.js +3 -0
  9. package/dbm.js +71 -0
  10. package/flow/DirtyCommands.js +45 -0
  11. package/flow/FlowBaseObject.js +78 -0
  12. package/flow/FlowProperty.js +146 -0
  13. package/flow/FlowUpdateFunction.js +39 -0
  14. package/flow/UpdateFunctionInputs.js +58 -0
  15. package/flow/UpdateFunctionOutputs.js +51 -0
  16. package/flow/index.js +40 -0
  17. package/flow/updatefunctions/basic/CombineString.js +45 -0
  18. package/flow/updatefunctions/basic/RunCommand.js +34 -0
  19. package/flow/updatefunctions/basic/index.js +2 -0
  20. package/flow/updatefunctions/debug/Log.js +30 -0
  21. package/flow/updatefunctions/debug/index.js +1 -0
  22. package/flow/updatefunctions/dom/ElementSize.js +47 -0
  23. package/flow/updatefunctions/dom/StyleObject.js +43 -0
  24. package/flow/updatefunctions/dom/index.js +2 -0
  25. package/flow/updatefunctions/index.js +5 -0
  26. package/flow/updatefunctions/logic/Addition.js +19 -0
  27. package/flow/updatefunctions/logic/Multiplication.js +19 -0
  28. package/flow/updatefunctions/logic/RangeSwitch.js +46 -0
  29. package/flow/updatefunctions/logic/Subtraction.js +19 -0
  30. package/flow/updatefunctions/logic/index.js +38 -0
  31. package/flow/updatefunctions/react/UpdateState.js +22 -0
  32. package/flow/updatefunctions/react/index.js +1 -0
  33. package/graphapi/index.js +1 -0
  34. package/graphapi/webclient/WebSocketConnection.js +236 -0
  35. package/graphapi/webclient/WebSocketRequest.js +30 -0
  36. package/graphapi/webclient/decode/DecodeBaseObject.js +48 -0
  37. package/graphapi/webclient/decode/index.js +59 -0
  38. package/graphapi/webclient/index.js +4 -0
  39. package/index.js +1 -0
  40. package/loading/JsonLoader.js +128 -0
  41. package/loading/LoadingStatus.js +4 -0
  42. package/loading/ScriptLoader.js +40 -0
  43. package/loading/index.js +24 -0
  44. package/package.json +17 -0
  45. package/react/BaseObject.js +179 -0
  46. package/react/RefToProperty.js +20 -0
  47. package/react/admin/Editor.js +153 -0
  48. package/react/admin/EditorBlock.js +53 -0
  49. package/react/admin/EditorBlockName.js +19 -0
  50. package/react/admin/index.js +3 -0
  51. package/react/area/HasData.js +22 -0
  52. package/react/area/InsertElement.js +22 -0
  53. package/react/area/index.js +2 -0
  54. package/react/blocks/index.js +61 -0
  55. package/react/context/AddContextVariables.js +22 -0
  56. package/react/context/Context.js +4 -0
  57. package/react/context/index.js +2 -0
  58. package/react/cookies/CookieBar.js +162 -0
  59. package/react/cookies/CookieSettings.js +118 -0
  60. package/react/cookies/index.js +2 -0
  61. package/react/form/Checkbox.js +28 -0
  62. package/react/form/FormField.js +28 -0
  63. package/react/form/index.js +2 -0
  64. package/react/index.js +13 -0
  65. package/react/login/LoginForm.js +113 -0
  66. package/react/login/index.js +1 -0
  67. package/react/modules/ModuleCreator.js +30 -0
  68. package/react/modules/index.js +1 -0
  69. package/react/source/ContextVariableSource.js +19 -0
  70. package/react/source/index.js +1 -0
  71. package/react/text/HtmlText.js +14 -0
  72. package/react/text/Text.js +13 -0
  73. package/react/text/index.js +19 -0
  74. package/repository/Item.js +70 -0
  75. package/repository/Repository.js +60 -0
  76. package/repository/index.js +2 -0
  77. package/site/SiteDataLoader.js +62 -0
  78. package/site/SiteNavigation.js +242 -0
  79. package/site/index.js +2 -0
  80. package/startup/Controller.js +43 -0
  81. package/startup/Runner.js +40 -0
  82. package/startup/index.js +28 -0
  83. package/tracking/Controller.js +157 -0
  84. package/tracking/DataLayerTracker.js +80 -0
  85. package/tracking/index.js +16 -0
  86. package/updater/PropertyUpdater.js +127 -0
  87. package/updater/RequestAnimationFrameTimer.js +43 -0
  88. package/updater/index.js +16 -0
  89. package/utils/ArrayFunctions.js +20 -0
  90. package/utils/index.js +1 -0
@@ -0,0 +1,113 @@
1
+ import React from "react";
2
+ import Dbm from "../../index.js";
3
+
4
+ export default class LoginForm extends Dbm.react.BaseObject {
5
+ _construct() {
6
+ super._construct();
7
+
8
+ this.item.setValue("username", "");
9
+ this.item.setValue("password", "");
10
+
11
+ }
12
+
13
+ _login() {
14
+ console.log("_login");
15
+
16
+ let loader = new Dbm.loading.JsonLoader();
17
+ loader.setupJsonPost("/api/user/login", {"username": this.item.username, "password": this.item.password});
18
+
19
+ Dbm.flow.addUpdateCommand(loader.item.properties.status, Dbm.commands.callFunction(this._loaderStatusChanged.bind(this), [loader]));
20
+
21
+ loader.load();
22
+ }
23
+
24
+ _loaderStatusChanged(aLoader) {
25
+ console.log("_loaderStatusChanged");
26
+ console.log(aLoader, aLoader.item.status);
27
+
28
+ if(aLoader.item.status === Dbm.loading.LoadingStatus.LOADED) {
29
+ if(aLoader.item.data.success) {
30
+
31
+ let item = Dbm.getInstance().repository.getItem("graphApi").controller.signIn(aLoader.item.data.data.wsToken);
32
+ Dbm.flow.addUpdateCommand(item.properties.status, Dbm.commands.callFunction(this._graphApiRequestStatusChanges.bind(this), [item, aLoader]));
33
+ }
34
+ else {
35
+ alert("Unable to log in: " + aLoader.item.data.message);
36
+ }
37
+ }
38
+ }
39
+
40
+ _graphApiRequestStatusChanges(aRequest, aLoader) {
41
+ console.log("_graphApiRequestStatusChanges");
42
+ console.log(aRequest, aRequest.status);
43
+
44
+ if(aRequest.status === Dbm.loading.LoadingStatus.LOADED) {
45
+ let completedCommands = this.getProp("completedCommands");
46
+ if(completedCommands) {
47
+ let currentArray = completedCommands;
48
+ let currentArrayLength = currentArray.length;
49
+ for(let i = 0; i < currentArrayLength; i++) {
50
+ let currentCommand = currentArray[i];
51
+ currentCommand.perform(this, aLoader.item.data.data);
52
+ }
53
+ return;
54
+ }
55
+
56
+ let site = Dbm.getInstance().repository.getItem("site");
57
+ let queryString = new URLSearchParams(window.location.search);
58
+ let skipRedirect = this.getProp("skipRedirect");
59
+
60
+ if(!skipRedirect) {
61
+ let redirectUrl = queryString.get('redirect');
62
+ if(redirectUrl) {
63
+ Dbm.getInstance().repository.getItem("siteNavigation").controller.navigate(redirectUrl);
64
+ return;
65
+ }
66
+ }
67
+
68
+ let action = queryString.get('action');
69
+ if(action) {
70
+ let actionCommand = Dbm.objectPath(site, "loginActions." + action);
71
+ if(actionCommand) {
72
+ actionCommand.perform(this, aLoader.item.data.data);
73
+ return;
74
+ }
75
+ console.warn("Unknown action " + action);
76
+ }
77
+
78
+ let actionCommand = Dbm.objectPath(site, "loginActions.default");
79
+ if(actionCommand) {
80
+ actionCommand.perform(this, aLoader.item.data.data);
81
+ return;
82
+ }
83
+
84
+ Dbm.getInstance().repository.getItem("siteNavigation").controller.navigate(site.loggedInUrl);
85
+ }
86
+ }
87
+
88
+ _renderMainElement() {
89
+
90
+ return this._createMainElement("div", {},
91
+ React.createElement("div", {className: "body-text"},
92
+ React.createElement("div", {"className": ""},
93
+ React.createElement("label", {className: ""},
94
+ "Email"
95
+ )
96
+ ),
97
+ React.createElement(Dbm.react.form.FormField, {value: this.item.properties.username}),
98
+ React.createElement("div", {"className": "spacing standard"}),
99
+ React.createElement("div", {"className": ""},
100
+ React.createElement("label", {className: ""},
101
+ "Password"
102
+ )
103
+ ),
104
+ React.createElement(Dbm.react.form.FormField, {type: "password", value: this.item.properties.password})
105
+ ),
106
+ React.createElement("div", {"className": "spacing standard"}),
107
+ React.createElement("div", {"className": "flex-row justify-center"},
108
+ React.createElement("div", {"className": "standard-button standard-button-padding", onClick: () => this._login()}, "Login")
109
+ )
110
+ );
111
+ }
112
+ }
113
+
@@ -0,0 +1 @@
1
+ export {default as LoginForm} from "./LoginForm.js";
@@ -0,0 +1,30 @@
1
+ import Dbm from "../../index.js";
2
+ import {createRoot} from 'react-dom/client';
3
+ import {createElement} from "react";
4
+
5
+ export default class ModuleCreator extends Dbm.core.BaseObject {
6
+ constructor() {
7
+ super();
8
+
9
+ this._mainElement = null;
10
+ }
11
+
12
+ setMainElement(aElement) {
13
+ this._mainElement = aElement;
14
+
15
+ return this;
16
+ }
17
+
18
+ createModule(aHolderNode, aData) {
19
+ //console.log("createModule");
20
+ //console.log(this, aData);
21
+
22
+ let root = createRoot(aHolderNode);
23
+
24
+ let elementWithInjections = createElement(Dbm.react.context.Context.Provider, {value: {moduleCreator: this, moduleData: aData, moduleRoot: root}}, this._mainElement);
25
+
26
+ root.render(elementWithInjections);
27
+
28
+ return root;
29
+ }
30
+ }
@@ -0,0 +1 @@
1
+ export {default as ModuleCreator} from "./ModuleCreator.js";
@@ -0,0 +1,19 @@
1
+ import Dbm from "../../index.js";
2
+
3
+ export default class ContextVariableSource extends Dbm.core.BaseObject {
4
+ _construct() {
5
+ super._construct();
6
+
7
+ this.item.setValue("path", null);
8
+ }
9
+
10
+ get isSource() {
11
+ return true;
12
+ }
13
+
14
+ getSource(aFromObject) {
15
+ //console.log("getSource");
16
+
17
+ return Dbm.objectPath(aFromObject.context, this.item.path);
18
+ }
19
+ }
@@ -0,0 +1 @@
1
+ export {default as ContextVariableSource} from "./ContextVariableSource.js";
@@ -0,0 +1,14 @@
1
+ import Dbm from "../../index.js";
2
+
3
+ export default class HtmlText extends Dbm.react.BaseObject {
4
+ _construct() {
5
+ super._construct();
6
+ }
7
+
8
+ _renderMainElement() {
9
+
10
+ let text = "" + this.getPropValue("text");
11
+
12
+ return this._createMainElement("span", {"dangerouslySetInnerHTML": {__html: text}});;
13
+ }
14
+ }
@@ -0,0 +1,13 @@
1
+ import Dbm from "../../index.js";
2
+
3
+ export default class Text extends Dbm.react.BaseObject {
4
+ _construct() {
5
+ super._construct();
6
+ }
7
+
8
+ render() {
9
+ let text = "" + this.getPropValue("text");
10
+
11
+ return text;
12
+ }
13
+ }
@@ -0,0 +1,19 @@
1
+ import Dbm from "../../index.js";
2
+ import {createElement} from "react";
3
+
4
+ export {default as Text} from "./Text.js";
5
+ export {default as HtmlText} from "./HtmlText.js";
6
+
7
+ export let text = function(aText) {
8
+ if(typeof(aText) === "string") {
9
+ return aText;
10
+ }
11
+ return createElement(Dbm.react.text.Text, {text: aText});
12
+ }
13
+
14
+ export let htmlText = function(aText, aElementType = "span") {
15
+ if(typeof(aText) === "string") {
16
+ //return createElement(aElementType, {"dangerouslySetInnerHTML": {__html: aText}});
17
+ }
18
+ return createElement(Dbm.react.text.HtmlText, {text: aText, elementType: aElementType});
19
+ }
@@ -0,0 +1,70 @@
1
+ import Dbm from "../index.js";
2
+
3
+ export default class Item extends Dbm.core.LifeCycleObject {
4
+ _constructProperties() {
5
+ super._constructProperties();
6
+
7
+ this._id = null;
8
+
9
+ this.properties = {};
10
+ }
11
+
12
+ get id() {
13
+ return this._id;
14
+ }
15
+
16
+ register(aId) {
17
+ this.setId(aId);
18
+ Dbm.getInstance().repository.addItem(this);
19
+
20
+ return this;
21
+ }
22
+
23
+ setId(aId) {
24
+ this._id = aId;
25
+
26
+ return this;
27
+ }
28
+
29
+ setValue(aName, aValue) {
30
+ this.getProperty(aName).value = aValue;
31
+
32
+ return this;
33
+ }
34
+
35
+ propertyInput(aName, aFlowProperty) {
36
+ this.getProperty(aName).connectInput(aFlowProperty);
37
+
38
+ return this;
39
+ }
40
+
41
+ propertyOutput(aName, aFlowProperty) {
42
+ aFlowProperty.connectInput(this.getProperty(aName));
43
+
44
+ return this;
45
+ }
46
+
47
+ getProperty(aName) {
48
+ if(!this.properties.hasOwnProperty(aName)) {
49
+ let property = new Dbm.flow.FlowProperty();
50
+ Object.defineProperty(this, aName, {
51
+ get() {
52
+ return property.value;
53
+ },
54
+ set(aValue) {
55
+ property.value = aValue;
56
+ }
57
+ });
58
+ this.properties[aName] = property;
59
+ }
60
+
61
+ return this.properties[aName];
62
+ }
63
+
64
+ requireProperty(aName, aDefaultValue = null) {
65
+ if(!this.properties.hasOwnProperty(aName)) {
66
+ this.setValue(aName, aDefaultValue);
67
+ }
68
+ return this.properties[aName];
69
+ }
70
+ }
@@ -0,0 +1,60 @@
1
+ import Dbm from "../index.js";
2
+
3
+ export default class Repository extends Dbm.core.BaseObject {
4
+ _construct() {
5
+ super._construct();
6
+
7
+ this._items = {};
8
+
9
+ this._item = this.getItem("repository");
10
+ this.item.setValue("controller", this);
11
+ }
12
+
13
+ addItem(aItem) {
14
+ this._items[aItem.id] = aItem;
15
+
16
+ return this;
17
+ }
18
+
19
+ addAlias(aAlias, aItem) {
20
+ this._items[aAlias] = aItem;
21
+
22
+ return this;
23
+ }
24
+
25
+ getItem(aName) {
26
+ let item = this._items[aName];
27
+ if(!item) {
28
+ item = new Dbm.repository.Item();
29
+ item.setId(aName);
30
+ this._items[aName] = item;
31
+ }
32
+
33
+ return item;
34
+ }
35
+
36
+ getItems(aNames) {
37
+ let currentArray = aNames;
38
+ let currentArrayLength = currentArray.length;
39
+ let returnArray = new Array(currentArrayLength);
40
+ for(let i = 0; i < currentArrayLength; i++) {
41
+ returnArray[i] = this.getItem(currentArray[i]);
42
+ }
43
+
44
+ return returnArray;
45
+ }
46
+
47
+ getItemIfExists(aName) {
48
+ let item = this._items[aName];
49
+ if(item) {
50
+ return item;
51
+ }
52
+
53
+ return null;
54
+ }
55
+
56
+ createInternalItem() {
57
+ let name = "_internal" + Dbm.getInstance().getNextId();
58
+ return this.getItem(name);
59
+ }
60
+ }
@@ -0,0 +1,2 @@
1
+ export {default as Item} from "./Item.js";
2
+ export {default as Repository} from "./Repository.js";
@@ -0,0 +1,62 @@
1
+ import Dbm from "../index.js";
2
+
3
+ export default class SiteDataLoader extends Dbm.core.BaseObject {
4
+ _construct() {
5
+ super._construct();
6
+
7
+ this.item.setValue("status", 0);
8
+ this.item.setValue("url", null);
9
+ this.item.setValue("currentPage", null);
10
+
11
+ let urlUpdate = new Dbm.flow.updatefunctions.basic.RunCommand();
12
+ urlUpdate.input.properties.value.connectInput(this.item.properties.url);
13
+ urlUpdate.input.command = Dbm.commands.callFunction(this._loadUrl.bind(this), []);
14
+
15
+ urlUpdate.output.properties.value.startUpdating();
16
+ }
17
+
18
+ _loadUrl() {
19
+ console.log("_loadUrl");
20
+
21
+ let url = this.item.url;
22
+ if(url != null) {
23
+ let parsedUrl = new URL(url);
24
+ let pathName = parsedUrl.pathname;
25
+
26
+ let pageData = Dbm.getInstance().repository.getItem(pathName);
27
+ pageData.setValue("url", url);
28
+
29
+ let graphApi = Dbm.getInstance().repository.getItem("graphApi").controller;
30
+ let request = graphApi.requestUrl(pathName);
31
+
32
+ let urlUpdate = new Dbm.flow.updatefunctions.basic.RunCommand();
33
+ urlUpdate.input.properties.value.connectInput(request.properties.status);
34
+ urlUpdate.input.command = Dbm.commands.callFunction(this._pageDataLoaded.bind(this), [pageData, request]);
35
+
36
+ this.item.setValue("status", 2);
37
+ urlUpdate.output.properties.value.startUpdating();
38
+ }
39
+ else {
40
+ this.item.currentPage = null;
41
+ this.item.setValue("status", 0);
42
+ }
43
+ }
44
+
45
+ _pageDataLoaded(aPageData, aRequest) {
46
+ //console.log("_pageDataLoaded");
47
+ //console.log(aPageData, aRequest, aRequest.status);
48
+
49
+ if(aRequest.status === 1) {
50
+ aPageData.setValue("page", aRequest.item);
51
+ aPageData.setValue("canRender", true);
52
+
53
+ if(this.item.url === aPageData.url) {
54
+ this.item.currentPage = aPageData;
55
+ this.item.setValue("status", 1);
56
+ }
57
+
58
+ //METODO: remove updaters
59
+ }
60
+
61
+ }
62
+ }
@@ -0,0 +1,242 @@
1
+ import Dbm from "../index.js";
2
+
3
+ export default class SiteNavigation extends Dbm.core.BaseObject {
4
+ _construct() {
5
+ super._construct();
6
+
7
+ this.item.setValue("url", null);
8
+ this.item.setValue("active", false);
9
+
10
+ this.item.setValue("travelPaths", []);
11
+ this.item.setValue("navigationLocks", []);
12
+
13
+ this.item.setValue("allowedPaths", [
14
+ new RegExp(".*")
15
+ ]);
16
+
17
+ this.item.setValue("ignoredPaths", [
18
+ new RegExp("/assets/.*$"),
19
+ new RegExp("/api/.*$")
20
+ ]);
21
+
22
+ this._callback_beforeUnloadBound = this._callback_beforeUnload.bind(this);
23
+ this._callback_clickBound = this._callback_click.bind(this);
24
+ this._callback_popStateBound = this._callback_popState.bind(this);
25
+ }
26
+
27
+ start() {
28
+ this._performStart();
29
+ this.item.active = true;
30
+
31
+ return this;
32
+ }
33
+
34
+ _performStart() {
35
+ window.addEventListener("beforeunload", this._callback_beforeUnloadBound, true);
36
+ window.addEventListener("click", this._callback_clickBound, false);
37
+ window.addEventListener("popstate", this._callback_popStateBound, false);
38
+ }
39
+
40
+ stop() {
41
+ this._performStop();
42
+ this.item.active = false;
43
+
44
+ return this;
45
+ }
46
+
47
+ _performStop() {
48
+ window.removeEventListener("beforeunload", this._callback_beforeUnloadBound, true);
49
+ window.removeEventListener("click", this._callback_clickBound, false);
50
+ window.removeEventListener("popstate", this._callback_popStateBound, false);
51
+ }
52
+
53
+ _callback_beforeUnload(aEvent) {
54
+ //METODO
55
+ let isLocked = this.hasNavigationLock();
56
+
57
+ if(isLocked) {
58
+ aEvent.preventDefault();
59
+ aEvent.returnValue = "";
60
+
61
+ return true;
62
+ }
63
+
64
+ return false;
65
+ }
66
+
67
+ _shouldHandle(aLink) {
68
+ let shouldHandle = false
69
+ {
70
+ let currentArray = this.item.allowedPaths;
71
+ let currentArrayLength = currentArray.length;
72
+ for(let i = 0; i < currentArrayLength; i++) {
73
+ let currentIgnoredPattern = currentArray[i];
74
+ if(currentIgnoredPattern.test(aLink)) {
75
+ shouldHandle = true;
76
+ break;
77
+ }
78
+ }
79
+ }
80
+
81
+ if(!shouldHandle) {
82
+ return false;
83
+ }
84
+
85
+ {
86
+ let currentArray = this.item.ignoredPaths;
87
+ let currentArrayLength = currentArray.length;
88
+ for(let i = 0; i < currentArrayLength; i++) {
89
+ let currentIgnoredPattern = currentArray[i];
90
+ if(currentIgnoredPattern.test(aLink)) {
91
+ return false;
92
+ }
93
+ }
94
+ }
95
+
96
+
97
+ return true;
98
+ }
99
+
100
+ _hasSpecialKey(aEvent) {
101
+ return aEvent.altKey || aEvent.ctrlKey || aEvent.metaKey || aEvent.shiftKey;
102
+ }
103
+
104
+ _callback_click(aEvent) {
105
+ if(aEvent.defaultPrevented) {
106
+ return true;
107
+ }
108
+ if(this._hasSpecialKey(aEvent)) {
109
+ return true;
110
+ }
111
+
112
+ let link = null;
113
+ let currentNode = aEvent.target;
114
+ let debugCounter = 0;
115
+ while(currentNode) {
116
+ if(debugCounter++ > 10000) {
117
+ console.error("Loop has run for too long");
118
+ break;
119
+ }
120
+ if(currentNode.localName === "a") {
121
+ let hrefAttribute = currentNode.getAttribute("href");
122
+ if(hrefAttribute) {
123
+ link = hrefAttribute.toString();
124
+ let hardNavigation = currentNode.getAttribute("data-not-spa-link");
125
+ if(hardNavigation) {
126
+ return true;
127
+ }
128
+ break;
129
+ }
130
+ }
131
+ currentNode = currentNode.parentNode;
132
+ }
133
+
134
+ if(!link) {
135
+ return true;
136
+ }
137
+
138
+ let originalUrl = new URL(document.location.href);
139
+ let finalUrl = new URL(link, document.location.href);
140
+
141
+ if(originalUrl.hostname !== finalUrl.hostname) {
142
+ return true;
143
+ }
144
+
145
+ if(!this._shouldHandle(finalUrl.href)) {
146
+ return false;
147
+ }
148
+
149
+ //console.log(finalUrl);
150
+
151
+ aEvent.preventDefault();
152
+
153
+ this._internalNavigation(finalUrl.href);
154
+ window.scrollTo(0, 0);
155
+
156
+ return false;
157
+ }
158
+
159
+ _addUrlToPath(aUrl) {
160
+ let paths = [].concat(this.item.travelPaths);
161
+
162
+ paths.push(aUrl);
163
+
164
+ this.item.travelPaths = paths;
165
+ }
166
+
167
+ _trackPage(aUrl) {
168
+ //console.log("_trackPage");
169
+
170
+ let trackingController = Dbm.getInstance().repository.getItem("trackingController").controller;
171
+ if(trackingController) {
172
+ trackingController.trackPage(aUrl);
173
+ }
174
+ }
175
+
176
+ _internalNavigation(aUrl) {
177
+
178
+ let locks = this.getLockedNavigationLocks();
179
+ if(locks.length > 0) {
180
+ if(!confirm("Leave without saving changes?")) {
181
+ return;
182
+ }
183
+ }
184
+
185
+ history.pushState({}, "Page", aUrl);
186
+ this.item.url = aUrl;
187
+
188
+ this._trackPage(aUrl);
189
+
190
+ this._addUrlToPath(aUrl);
191
+ }
192
+
193
+ _callback_popState(aEvent) {
194
+ //console.log("_callback_popState");
195
+
196
+ let url = document.location.href;
197
+ this.item.url = url;
198
+
199
+ this._trackPage(url);
200
+
201
+ let paths = [].concat(this.item.travelPaths);
202
+ paths.pop();
203
+ this.item.travelPaths = paths;
204
+ }
205
+
206
+ navigate(aUrl) {
207
+ let originalUrl = new URL(document.location.href);
208
+ let finalUrl = new URL(aUrl, document.location.href);
209
+
210
+ if(this.item.active && originalUrl.hostname === finalUrl.hostname && this._shouldHandle(finalUrl.href)) {
211
+ this._internalNavigation(finalUrl.href);
212
+ window.scrollTo(0, 0);
213
+ }
214
+ else {
215
+ document.location.href = aUrl;
216
+ }
217
+ }
218
+
219
+ setUrlFromLocation() {
220
+ let url = document.location.href;
221
+ this.item.url = url
222
+
223
+ this._addUrlToPath(url);
224
+
225
+ return this;
226
+ }
227
+
228
+ getLockedNavigationLocks() {
229
+ let locks = this.item.navigationLocks;
230
+
231
+ let lockedLocks = locks; //METODO: filter by locked locks
232
+
233
+ return lockedLocks;
234
+ }
235
+
236
+ hasNavigationLock() {
237
+
238
+ let locks = this.getLockedNavigationLocks();
239
+
240
+ return (locks.length > 0);
241
+ }
242
+ }
package/site/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export {default as SiteNavigation} from "./SiteNavigation.js";
2
+ export {default as SiteDataLoader} from "./SiteDataLoader.js";