@jinntec/fore 2.1.1 → 2.3.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/README.md +2 -2
- package/dist/fore-dev.js +2 -2
- package/dist/fore-dev.js.map +1 -1
- package/dist/fore.js +2 -2
- package/dist/fore.js.map +1 -1
- package/index.js +4 -2
- package/package.json +10 -38
- package/resources/fore.css +263 -262
- package/resources/vars.css +8 -0
- package/src/DependencyNotifyingDomFacade.js +1 -0
- package/src/ForeElementMixin.js +243 -228
- package/src/actions/abstract-action.js +407 -398
- package/src/actions/fx-action.js +6 -6
- package/src/actions/fx-append.js +1 -1
- package/src/actions/fx-call.js +63 -62
- package/src/actions/fx-confirm.js +11 -11
- package/src/actions/fx-construct-done.js +4 -4
- package/src/actions/fx-copy.js +36 -36
- package/src/actions/fx-delete.js +77 -79
- package/src/actions/fx-dispatch.js +14 -14
- package/src/actions/fx-hide.js +15 -15
- package/src/actions/fx-insert.js +9 -12
- package/src/actions/fx-insertchild.js +88 -0
- package/src/actions/fx-load.js +188 -185
- package/src/actions/fx-message.js +18 -19
- package/src/actions/fx-refresh.js +10 -10
- package/src/actions/fx-reload.js +16 -14
- package/src/actions/fx-replace.js +0 -1
- package/src/actions/fx-reset.js +31 -31
- package/src/actions/fx-send.js +59 -52
- package/src/actions/fx-setattribute.js +48 -49
- package/src/actions/fx-setfocus.js +54 -58
- package/src/actions/fx-setvalue.js +85 -81
- package/src/actions/fx-show.js +11 -11
- package/src/actions/fx-toggle.js +2 -2
- package/src/actions/fx-toggleboolean.js +38 -39
- package/src/actions/fx-unmodified.js +27 -0
- package/src/actions/fx-update.js +6 -6
- package/src/dep_graph.js +1 -1
- package/src/drawdown.js +23 -30
- package/src/events.js +19 -19
- package/src/fore.js +143 -125
- package/src/functions/common-function.js +24 -25
- package/src/functions/fx-function.js +6 -99
- package/src/functions/fx-functionlib.js +56 -0
- package/src/functions/registerFunction.js +112 -0
- package/src/fx-bind.js +19 -24
- package/src/fx-connection.js +226 -0
- package/src/fx-fore.js +844 -815
- package/src/fx-header.js +4 -4
- package/src/fx-instance.js +25 -29
- package/src/fx-model.js +405 -380
- package/src/fx-submission.js +399 -397
- package/src/fx-var.js +13 -12
- package/src/getInScopeContext.js +102 -89
- package/src/json-util.js +24 -24
- package/src/lab/fore-component.js +48 -52
- package/src/lab/instance-inspector.js +13 -16
- package/src/modelitem.js +48 -10
- package/src/relevance.js +12 -16
- package/src/tools/adi.js +858 -812
- package/src/tools/fx-action-log.js +377 -295
- package/src/tools/fx-devtools.js +210 -210
- package/src/tools/fx-dom-inspector.js +123 -122
- package/src/tools/fx-json-instance.js +262 -253
- package/src/tools/fx-log-item.js +6 -11
- package/src/tools/fx-log-settings.js +358 -301
- package/src/tools/fx-minimap.js +186 -177
- package/src/tools/helpers.js +1 -1
- package/src/ui/abstract-control.js +73 -53
- package/src/ui/fx-case.js +59 -7
- package/src/ui/fx-container.js +13 -14
- package/src/ui/fx-control.js +572 -538
- package/src/ui/fx-dialog.js +3 -3
- package/src/ui/fx-droptarget.js +3 -4
- package/src/ui/fx-group.js +4 -2
- package/src/ui/fx-hint.js +3 -0
- package/src/ui/fx-inspector.js +5 -5
- package/src/ui/fx-items.js +11 -11
- package/src/ui/fx-output.js +10 -12
- package/src/ui/fx-repeat-attributes.js +23 -27
- package/src/ui/fx-repeat.js +347 -344
- package/src/ui/fx-repeatitem.js +75 -68
- package/src/ui/fx-switch.js +39 -14
- package/src/ui/fx-trigger.js +4 -4
- package/src/withDraggability.js +193 -191
- package/src/xpath-evaluation.js +969 -958
- package/src/xpath-util.js +161 -134
package/src/tools/adi.js
CHANGED
|
@@ -1,87 +1,87 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
addClass,
|
|
3
|
+
removeClass,
|
|
4
|
+
isEmptyTextNode,
|
|
5
|
+
containsOnlyText,
|
|
6
|
+
newElement,
|
|
7
|
+
drawOptions,
|
|
8
|
+
pauseEvent,
|
|
9
|
+
drawAttrRow,
|
|
10
10
|
} from './helpers.js';
|
|
11
11
|
|
|
12
|
-
import {Fore} from '../fore.js';
|
|
12
|
+
import { Fore } from '../fore.js';
|
|
13
13
|
|
|
14
14
|
function isAttributeShown(name, sourceNode) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
if (name === 'style') return false;
|
|
16
|
+
return true;
|
|
17
|
+
// return name === 'id' || name === 'ref' || name === 'event';
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
class ADI {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
21
|
+
constructor(rootElement, instance) {
|
|
22
|
+
this.sourceNodeByInspectorNodeLookup = new Map();
|
|
23
|
+
|
|
24
|
+
this.uiView = null;
|
|
25
|
+
this.menuView = null;
|
|
26
|
+
this.domView = null;
|
|
27
|
+
this.attrView = null;
|
|
28
|
+
this.optsView = null;
|
|
29
|
+
/**
|
|
30
|
+
* The current active element. Note this is the element in the DOM view
|
|
31
|
+
*/
|
|
32
|
+
this.activeElement = null;
|
|
33
|
+
this.vertResizing = false;
|
|
34
|
+
this.horizResizing = false;
|
|
35
|
+
this.pathScrolling = null;
|
|
36
|
+
this.elemLookup = false;
|
|
37
|
+
this.styleBackup = '';
|
|
38
|
+
this.xPos = 0;
|
|
39
|
+
this.delegatedEvents = [];
|
|
40
|
+
|
|
41
|
+
this.options = {
|
|
42
|
+
align: 'right', // NOTE: left is not supported in this version
|
|
43
|
+
split: 50,
|
|
44
|
+
minSplit: 30,
|
|
45
|
+
visible: true,
|
|
46
|
+
saving: false,
|
|
47
|
+
transparent: true,
|
|
48
|
+
omitEmptyText: true,
|
|
49
|
+
makeVisible: true,
|
|
50
|
+
foldText: true,
|
|
51
|
+
nodeTypes: [Node.ELEMENT_NODE, Node.TEXT_NODE, Node.COMMENT_NODE, Node.DOCUMENT_NODE],
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
if (instance === '#document') {
|
|
55
|
+
this.instanceId = '#document';
|
|
56
|
+
this.document = window.document;
|
|
57
|
+
this.isInstanceViewer = false;
|
|
58
|
+
} else {
|
|
59
|
+
this.instanceId = instance.id;
|
|
60
|
+
if (!instance || instance.localName !== 'fx-instance') {
|
|
61
|
+
console.error('No instance found!');
|
|
62
|
+
}
|
|
63
|
+
this.document = instance.getInstanceData();
|
|
64
|
+
this.isInstanceViewer = true;
|
|
65
|
+
this.options.foldText = false;
|
|
66
|
+
}
|
|
67
|
+
this.drawUI(rootElement);
|
|
68
|
+
this.registerEvents();
|
|
69
|
+
|
|
70
|
+
// We're updating here, but we're doing that again later, when the UI is read (the 'ready' event fires)
|
|
71
|
+
this.drawDOM(this.document, this.domView.querySelector('.adi-tree-view'), true);
|
|
72
|
+
document.addEventListener('execute-action', e => this.processExecuteAction);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Returns selected element or null
|
|
76
|
+
getSelected() {
|
|
77
|
+
if (!this.activeElement) {
|
|
78
|
+
return null;
|
|
73
79
|
}
|
|
74
80
|
|
|
75
|
-
|
|
76
|
-
getSelected() {
|
|
77
|
-
if (!this.activeElement) {
|
|
78
|
-
return null;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
let elem = document;
|
|
81
|
+
let elem = document;
|
|
82
82
|
|
|
83
|
-
|
|
84
|
-
/*
|
|
83
|
+
elem = this.sourceNodeByInspectorNodeLookup.get(this.activeElement);
|
|
84
|
+
/*
|
|
85
85
|
document.dispatchEvent(
|
|
86
86
|
new CustomEvent('path-touched', {
|
|
87
87
|
composed: true,
|
|
@@ -91,105 +91,108 @@ class ADI {
|
|
|
91
91
|
);
|
|
92
92
|
*/
|
|
93
93
|
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
return elem;
|
|
95
|
+
}
|
|
96
96
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
97
|
+
// Loads user defined options stored in HTML5 storage (if available)
|
|
98
|
+
loadOptions() {
|
|
99
|
+
let userOptions = {};
|
|
100
100
|
|
|
101
|
-
|
|
101
|
+
userOptions = JSON.parse(window.localStorage.getItem('ADI.options')) || {};
|
|
102
102
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
103
|
+
// merge with defaults
|
|
104
|
+
for (const opt of Object.keys(userOptions)) {
|
|
105
|
+
this.options[opt] = userOptions[opt];
|
|
107
106
|
}
|
|
107
|
+
}
|
|
108
108
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
109
|
+
// Saves user defined options into the HTML5 storage (if available)
|
|
110
|
+
saveOptions() {
|
|
111
|
+
if (this.options.saving) {
|
|
112
|
+
window.localStorage.setItem('ADI.options', JSON.stringify(this.options));
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Checks if a node has some child nodes and if at least on of them is of a supported type
|
|
117
|
+
hasRequiredNodes(node) {
|
|
118
|
+
if (typeof node !== 'object') {
|
|
119
|
+
throw new Error(
|
|
120
|
+
`hasRequiredNodes: Expected argument node of type object, ${typeof node} given.`,
|
|
121
|
+
);
|
|
114
122
|
}
|
|
115
123
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
if (node.hasChildNodes()) {
|
|
125
|
-
for (let i = 0, len = node.childNodes.length; i < len; i += 1) {
|
|
126
|
-
const child = node.childNodes[i];
|
|
127
|
-
if (this.options.nodeTypes.includes(child.nodeType)) {
|
|
128
|
-
return true;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
124
|
+
if (node.hasChildNodes()) {
|
|
125
|
+
for (let i = 0, len = node.childNodes.length; i < len; i += 1) {
|
|
126
|
+
const child = node.childNodes[i];
|
|
127
|
+
if (this.options.nodeTypes.includes(child.nodeType)) {
|
|
128
|
+
return true;
|
|
131
129
|
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
132
|
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
133
135
|
|
|
134
|
-
|
|
136
|
+
// Creates a starting markup for a new DOM tree view node
|
|
137
|
+
newTreeNode(sourceNode) {
|
|
138
|
+
if (typeof sourceNode !== 'object') {
|
|
139
|
+
throw new Error(
|
|
140
|
+
`newTreeNode: Expected argument node of type object, ${typeof sourceNode} given.`,
|
|
141
|
+
);
|
|
135
142
|
}
|
|
136
143
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
150
|
-
const elem = newElement('li', {
|
|
151
|
-
class: adiNode,
|
|
152
|
-
});
|
|
144
|
+
const withChildren = this.hasRequiredNodes(sourceNode);
|
|
145
|
+
let omit = false;
|
|
146
|
+
let adiNode = sourceNode.nodeName.startsWith('FX-')
|
|
147
|
+
? `adi-node ${sourceNode.nodeName.toLowerCase()}`
|
|
148
|
+
: '';
|
|
149
|
+
if (sourceNode.nodeName.startsWith('FX-')) {
|
|
150
|
+
adiNode = `adi-node ${sourceNode.nodeName.toLowerCase()}`;
|
|
151
|
+
adiNode += Fore.isActionElement(sourceNode.nodeName) ? ' action' : '';
|
|
152
|
+
}
|
|
153
|
+
const elem = newElement('li', {
|
|
154
|
+
class: adiNode,
|
|
155
|
+
});
|
|
153
156
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
157
|
+
// do not show ADI DOM nodes in the DOM view
|
|
158
|
+
if (sourceNode === this.uiView) {
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
158
161
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
162
|
+
// generate UI for elements with children
|
|
163
|
+
if (withChildren) {
|
|
164
|
+
elem.appendChild(newElement('span', { class: 'adi-trigger' }));
|
|
165
|
+
}
|
|
163
166
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
167
|
+
// we can omit empty text nodes if allowed in options
|
|
168
|
+
if (this.options.omitEmptyText && sourceNode.nodeType === Node.TEXT_NODE) {
|
|
169
|
+
omit = isEmptyTextNode(sourceNode);
|
|
170
|
+
}
|
|
168
171
|
|
|
169
|
-
|
|
170
|
-
|
|
172
|
+
if (!omit) {
|
|
173
|
+
const tagStart = newElement('span');
|
|
171
174
|
|
|
172
|
-
|
|
173
|
-
|
|
175
|
+
this.sourceNodeByInspectorNodeLookup.set(tagStart, sourceNode);
|
|
176
|
+
this.sourceNodeByInspectorNodeLookup.set(sourceNode, tagStart);
|
|
174
177
|
|
|
175
|
-
|
|
178
|
+
let tagEnd = null;
|
|
176
179
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
180
|
+
if (containsOnlyText(sourceNode)) {
|
|
181
|
+
if (sourceNode.nodeType === Node.COMMENT_NODE) {
|
|
182
|
+
addClass(tagStart, 'adi-comment-node');
|
|
183
|
+
if (typeof tagStart.innerText === 'string') {
|
|
184
|
+
tagStart.innerText = `<!-- ${sourceNode.textContent} -->`;
|
|
185
|
+
}
|
|
186
|
+
} else {
|
|
187
|
+
addClass(tagStart, 'adi-text-node');
|
|
188
|
+
tagStart.textContent = sourceNode.textContent;
|
|
189
|
+
}
|
|
190
|
+
} else {
|
|
191
|
+
addClass(tagStart, 'adi-normal-node');
|
|
192
|
+
if (sourceNode.nodeType !== Node.DOCUMENT_NODE) {
|
|
193
|
+
// tagStart.textContent = '<' + node.nodeName.toLowerCase() + '>';
|
|
191
194
|
|
|
192
|
-
/*
|
|
195
|
+
/*
|
|
193
196
|
let attrString = `<${sourceNode.nodeName.toLowerCase()} `;
|
|
194
197
|
if(sourceNode.attributes){
|
|
195
198
|
Array.from(sourceNode.attributes).forEach(attr => {
|
|
@@ -213,30 +216,29 @@ class ADI {
|
|
|
213
216
|
tagStart.textContent = `<${sourceNode.nodeName.toLowerCase()} id="${sourceNode.getAttribute('id')}">`;
|
|
214
217
|
} else {
|
|
215
218
|
*/
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
}
|
|
219
|
+
const attrString = Array.from(sourceNode.attributes)
|
|
220
|
+
.filter(attr =>
|
|
221
|
+
this.isInstanceViewer ? true : isAttributeShown(attr.name, sourceNode),
|
|
222
|
+
)
|
|
223
|
+
.map(attr => `${attr.name}="${attr.value}"`)
|
|
224
|
+
.join(' ');
|
|
225
|
+
tagStart.textContent = `<${sourceNode.nodeName.toLowerCase()}${
|
|
226
|
+
attrString ? ` ${attrString}` : ''
|
|
227
|
+
}>`;
|
|
228
|
+
// }
|
|
229
|
+
|
|
230
|
+
if (withChildren) {
|
|
231
|
+
tagEnd = newElement('span');
|
|
232
|
+
addClass(tagEnd, 'adi-end-node');
|
|
233
|
+
tagEnd.textContent = `</${sourceNode.nodeName.toLowerCase()}>`;
|
|
234
|
+
}
|
|
235
|
+
} else {
|
|
236
|
+
tagStart.textContent = sourceNode.nodeName.toLowerCase();
|
|
237
|
+
}
|
|
238
|
+
}
|
|
237
239
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
+
elem.appendChild(tagStart);
|
|
241
|
+
/*
|
|
240
242
|
const icon = document.createElement('span');
|
|
241
243
|
icon.textContent = 'x';
|
|
242
244
|
icon.classList.add(('icon'))
|
|
@@ -246,244 +248,246 @@ class ADI {
|
|
|
246
248
|
elem.appendChild(icon);
|
|
247
249
|
elem.appendChild(icon2);
|
|
248
250
|
*/
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
if (tagEnd) {
|
|
255
|
-
elem.appendChild(tagEnd);
|
|
251
|
+
if (sourceNode.nodeName.startsWith('FX-')) {
|
|
252
|
+
tagStart.classList.add('fore-node');
|
|
253
|
+
tagStart.classList.add(sourceNode.nodeName.toLowerCase());
|
|
254
|
+
}
|
|
256
255
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
}
|
|
260
|
-
}
|
|
256
|
+
if (tagEnd) {
|
|
257
|
+
elem.appendChild(tagEnd);
|
|
261
258
|
|
|
262
|
-
|
|
259
|
+
if (sourceNode.nodeName.startsWith('FX-')) {
|
|
260
|
+
tagEnd.classList.add('fore-node');
|
|
263
261
|
}
|
|
264
|
-
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
return elem;
|
|
265
265
|
}
|
|
266
|
+
return null;
|
|
267
|
+
}
|
|
266
268
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
269
|
+
// Renders the DOM Tree view
|
|
270
|
+
drawDOM(root, elem, isRoot) {
|
|
271
|
+
if (typeof root !== 'object') {
|
|
272
|
+
throw new Error(`drawDOM: Expected argument root of type object, ${typeof root} given.`);
|
|
273
|
+
}
|
|
272
274
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
+
let newNode = null;
|
|
276
|
+
let isOpen = true;
|
|
275
277
|
|
|
276
|
-
|
|
278
|
+
const adiNode = elem.nodeName.startsWith('FX-')
|
|
279
|
+
? `adi-node ${node.nodeName.toLowerCase()}`
|
|
280
|
+
: '';
|
|
277
281
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
282
|
+
if (isRoot && this.options.nodeTypes.indexOf(root.nodeType) !== -1) {
|
|
283
|
+
elem.innerHTML = '';
|
|
284
|
+
newNode = this.newTreeNode(root);
|
|
281
285
|
|
|
282
|
-
|
|
286
|
+
if (this.hasRequiredNodes(root)) {
|
|
287
|
+
newNode.appendChild(newElement('ul', { 'data-open': true, class: adiNode }));
|
|
283
288
|
|
|
284
|
-
|
|
289
|
+
addClass(newNode.querySelector('.adi-trigger'), 'opened');
|
|
290
|
+
}
|
|
285
291
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
elem.appendChild(newNode);
|
|
290
|
-
elem = elem.querySelector('ul');
|
|
291
|
-
}
|
|
292
|
+
elem.appendChild(newNode);
|
|
293
|
+
elem = elem.querySelector('ul');
|
|
294
|
+
}
|
|
292
295
|
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
296
|
+
// recursive DOM traversal
|
|
297
|
+
for (let i = 0, len = root.childNodes.length; i < len; i += 1) {
|
|
298
|
+
const node = root.childNodes[i];
|
|
299
|
+
const withChildren = this.hasRequiredNodes(node);
|
|
297
300
|
|
|
298
|
-
|
|
299
|
-
|
|
301
|
+
if (this.options.nodeTypes.indexOf(node.nodeType) !== -1) {
|
|
302
|
+
newNode = this.newTreeNode(node);
|
|
300
303
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
304
|
+
if (newNode) {
|
|
305
|
+
if (withChildren) {
|
|
306
|
+
if (this.options.foldText) {
|
|
307
|
+
isOpen = !containsOnlyText(node, true);
|
|
308
|
+
} else {
|
|
309
|
+
isOpen = true;
|
|
310
|
+
}
|
|
308
311
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
/*
|
|
312
|
+
if (node.nodeName === 'HEAD') isOpen = false;
|
|
313
|
+
if (node.nodeName === 'SELECT') isOpen = false;
|
|
314
|
+
if (node.nodeName === 'FX-INSTANCE') isOpen = false;
|
|
315
|
+
/*
|
|
313
316
|
if(this.options.closedElements.includes(node.nodeName.toLowerCase())){
|
|
314
317
|
isOpen = false;
|
|
315
318
|
}
|
|
316
319
|
*/
|
|
317
320
|
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
321
|
+
if (node.nodeType === Node.DOCUMENT_NODE) {
|
|
322
|
+
newNode.appendChild(newElement('ul', { 'data-open': isOpen, class: adiNode }));
|
|
323
|
+
} else {
|
|
324
|
+
newNode.insertBefore(
|
|
325
|
+
newElement('ul', { 'data-open': isOpen, class: adiNode }),
|
|
326
|
+
newNode.lastChild,
|
|
327
|
+
);
|
|
328
|
+
}
|
|
326
329
|
|
|
327
|
-
|
|
330
|
+
addClass(newNode.querySelector('.adi-trigger'), isOpen ? 'opened' : 'closed');
|
|
331
|
+
}
|
|
328
332
|
|
|
329
|
-
|
|
330
|
-
const span = newNode.querySelector('span.adi-normal-node');
|
|
331
|
-
span?.classList?.add('adi-active-node');
|
|
332
|
-
this.activeElement = span;
|
|
333
|
-
newNode.scrollIntoView({block:'nearest', behavior: 'instant'});
|
|
334
|
-
}
|
|
333
|
+
elem.appendChild(newNode);
|
|
335
334
|
|
|
335
|
+
if (this.getSelected() === node) {
|
|
336
|
+
const span = newNode.querySelector('span.adi-normal-node');
|
|
337
|
+
span?.classList?.add('adi-active-node');
|
|
338
|
+
this.activeElement = span;
|
|
339
|
+
newNode.scrollIntoView({ block: 'nearest', behavior: 'instant' });
|
|
340
|
+
}
|
|
336
341
|
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
+
if (withChildren) {
|
|
343
|
+
this.drawDOM(node, newNode.querySelector('ul'), false);
|
|
344
|
+
}
|
|
342
345
|
}
|
|
346
|
+
}
|
|
343
347
|
}
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
// Show/hide the options view
|
|
351
|
+
toggleOptions() {
|
|
352
|
+
if (this.optsView.className.indexOf('adi-hidden') !== -1) {
|
|
353
|
+
removeClass(this.optsView, 'adi-hidden');
|
|
354
|
+
} else {
|
|
355
|
+
addClass(this.optsView, 'adi-hidden');
|
|
356
|
+
this.attrView.querySelector('.adi-content').innerHTML = '';
|
|
357
|
+
this.refreshUI();
|
|
358
|
+
this.drawDOM(document, this.domView.querySelector('.adi-tree-view'), true);
|
|
359
|
+
if (this.options.saving) {
|
|
360
|
+
this.saveOptions();
|
|
361
|
+
} else {
|
|
362
|
+
window.localStorage.removeItem('ADI.options');
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
// Renders the UI
|
|
368
|
+
drawUI(rootElement) {
|
|
369
|
+
this.uiView = newElement('div', {
|
|
370
|
+
id: 'adi-wrapper',
|
|
371
|
+
class: this.options.transparent ? 'transparent' : '',
|
|
372
|
+
});
|
|
373
|
+
this.domView = newElement('div', { id: 'adi-dom-view' });
|
|
374
|
+
const domViewContent = newElement('div', { class: 'adi-content', id: 'detailsView' });
|
|
375
|
+
// this.attrView.appendChild(newElement('fx-fore', {src: './lab/inspector-view.html'}));
|
|
376
|
+
|
|
377
|
+
// const horizSplit = newElement('div', {id: 'adi-horiz-split'});
|
|
378
|
+
const domTree = newElement('ul', { class: 'adi-tree-view' });
|
|
379
|
+
const domPathWrap = newElement('div', { class: 'adi-path-wrap' });
|
|
380
|
+
const domPathScrollLeft = newElement('span', { class: 'adi-path-left' });
|
|
381
|
+
const domPathScrollRight = newElement('span', { class: 'adi-path-right' });
|
|
382
|
+
this.menuView = newElement('div', { id: 'adi-panel' });
|
|
383
|
+
const naviButtons = newElement('div', { class: 'adi-menu-wrap' });
|
|
384
|
+
const naviConfig = newElement('a', { class: 'adi-menu-config', title: 'Settings' });
|
|
385
|
+
const naviLookup = newElement('a', { class: 'adi-menu-lookup', title: 'Lookup tool' });
|
|
386
|
+
|
|
387
|
+
// this.horizSplit = horizSplit;
|
|
388
|
+
|
|
389
|
+
this.optsView = drawOptions();
|
|
390
|
+
|
|
391
|
+
// put UI together
|
|
392
|
+
domViewContent.appendChild(domTree);
|
|
393
|
+
this.domView.appendChild(this.menuView);
|
|
394
|
+
this.domView.appendChild(domViewContent);
|
|
395
|
+
|
|
396
|
+
domPathWrap.appendChild(domPathScrollLeft);
|
|
397
|
+
domPathWrap.appendChild(domPathScrollRight);
|
|
398
|
+
naviButtons.appendChild(naviLookup);
|
|
399
|
+
naviButtons.appendChild(naviConfig);
|
|
400
|
+
this.menuView.appendChild(domPathWrap);
|
|
401
|
+
this.menuView.appendChild(naviButtons);
|
|
402
|
+
// this.uiView.appendChild(this.menuView);
|
|
403
|
+
this.uiView.appendChild(this.optsView);
|
|
404
|
+
this.uiView.appendChild(this.domView);
|
|
405
|
+
if (!this.isInstanceViewer) {
|
|
406
|
+
this.attrView = newElement('div', { id: 'adi-attr-view' });
|
|
407
|
+
const attrViewContent = newElement('div', { class: 'adi-content' });
|
|
408
|
+
this.attrView.appendChild(attrViewContent);
|
|
409
|
+
this.uiView.appendChild(this.attrView);
|
|
360
410
|
}
|
|
361
411
|
|
|
362
|
-
//
|
|
363
|
-
|
|
364
|
-
this.uiView = newElement('div', {
|
|
365
|
-
id: 'adi-wrapper',
|
|
366
|
-
class: this.options.transparent ? 'transparent' : '',
|
|
367
|
-
});
|
|
368
|
-
this.domView = newElement('div', {id: 'adi-dom-view'});
|
|
369
|
-
const domViewContent = newElement('div', {class: 'adi-content', id: 'detailsView'});
|
|
370
|
-
// this.attrView.appendChild(newElement('fx-fore', {src: './lab/inspector-view.html'}));
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
// const horizSplit = newElement('div', {id: 'adi-horiz-split'});
|
|
374
|
-
const domTree = newElement('ul', {class: 'adi-tree-view'});
|
|
375
|
-
const domPathWrap = newElement('div', {class: 'adi-path-wrap'});
|
|
376
|
-
const domPathScrollLeft = newElement('span', {class: 'adi-path-left'});
|
|
377
|
-
const domPathScrollRight = newElement('span', {class: 'adi-path-right'});
|
|
378
|
-
this.menuView = newElement('div', {id: 'adi-panel'});
|
|
379
|
-
const naviButtons = newElement('div', {class: 'adi-menu-wrap'});
|
|
380
|
-
const naviConfig = newElement('a', {class: 'adi-menu-config', title: 'Settings'});
|
|
381
|
-
const naviLookup = newElement('a', {class: 'adi-menu-lookup', title: 'Lookup tool'});
|
|
382
|
-
|
|
383
|
-
// this.horizSplit = horizSplit;
|
|
384
|
-
|
|
385
|
-
this.optsView = drawOptions();
|
|
386
|
-
|
|
387
|
-
// put UI together
|
|
388
|
-
domViewContent.appendChild(domTree);
|
|
389
|
-
this.domView.appendChild(this.menuView);
|
|
390
|
-
this.domView.appendChild(domViewContent);
|
|
391
|
-
|
|
392
|
-
domPathWrap.appendChild(domPathScrollLeft);
|
|
393
|
-
domPathWrap.appendChild(domPathScrollRight);
|
|
394
|
-
naviButtons.appendChild(naviLookup);
|
|
395
|
-
naviButtons.appendChild(naviConfig);
|
|
396
|
-
this.menuView.appendChild(domPathWrap);
|
|
397
|
-
this.menuView.appendChild(naviButtons);
|
|
398
|
-
// this.uiView.appendChild(this.menuView);
|
|
399
|
-
this.uiView.appendChild(this.optsView);
|
|
400
|
-
this.uiView.appendChild(this.domView);
|
|
401
|
-
if (!this.isInstanceViewer) {
|
|
402
|
-
this.attrView = newElement('div', {id: 'adi-attr-view'});
|
|
403
|
-
const attrViewContent = newElement('div', {class: 'adi-content'});
|
|
404
|
-
this.attrView.appendChild(attrViewContent);
|
|
405
|
-
this.uiView.appendChild(this.attrView);
|
|
406
|
-
}
|
|
412
|
+
// this.uiView.appendChild(horizSplit);
|
|
413
|
+
// wrapper.appendChild(naviWrap);
|
|
407
414
|
|
|
408
|
-
|
|
409
|
-
// wrapper.appendChild(naviWrap);
|
|
415
|
+
// cache UI object and append to the DOM
|
|
410
416
|
|
|
411
|
-
|
|
417
|
+
rootElement.appendChild(this.uiView);
|
|
418
|
+
// document.querySelector('#inspector').appendChild(wrapper);
|
|
412
419
|
|
|
413
|
-
|
|
414
|
-
|
|
420
|
+
this.refreshUI(true);
|
|
421
|
+
}
|
|
415
422
|
|
|
416
|
-
|
|
423
|
+
// Refreshes the global UI
|
|
424
|
+
refreshUI(refreshOpts) {
|
|
425
|
+
if (this.uiView === null) {
|
|
426
|
+
return;
|
|
417
427
|
}
|
|
418
428
|
|
|
419
|
-
//
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
}
|
|
429
|
+
// load options if requested (e.g. before the first UI refresh)
|
|
430
|
+
if (refreshOpts) {
|
|
431
|
+
this.loadOptions();
|
|
432
|
+
}
|
|
424
433
|
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
434
|
+
// Options view refresh
|
|
435
|
+
if (refreshOpts) {
|
|
436
|
+
this.optsView.querySelector('[data-opt="transparent"]').checked = this.options.transparent;
|
|
437
|
+
this.optsView.querySelector('[data-opt="saving"]').checked = this.options.saving;
|
|
438
|
+
this.optsView.querySelector('[data-opt="omitEmptyText"]').checked =
|
|
439
|
+
this.options.omitEmptyText;
|
|
440
|
+
this.optsView.querySelector('[data-opt="makeVisible"]').checked = this.options.makeVisible;
|
|
441
|
+
this.optsView.querySelector('[data-opt="foldText"]').checked = this.options.foldText;
|
|
442
|
+
this.optsView.querySelector('[data-opt="nodeTypes-3"]').checked =
|
|
443
|
+
this.options.nodeTypes.indexOf(3) !== -1;
|
|
444
|
+
this.optsView.querySelector('[data-opt="nodeTypes-8"]').checked =
|
|
445
|
+
this.options.nodeTypes.indexOf(8) !== -1;
|
|
446
|
+
// this.optsView.querySelector('[data-opt="nodeTypes-1"]').checked = this.options.nodeTypes.indexOf(1) !== -1;
|
|
447
|
+
// this.optsView.querySelector('[data-opt="nodeTypes-9"]').checked = this.options.nodeTypes.indexOf(9) !== -1;
|
|
448
|
+
}
|
|
429
449
|
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
this.optsView.querySelector('[data-opt="nodeTypes-8"]').checked =
|
|
442
|
-
this.options.nodeTypes.indexOf(8) !== -1;
|
|
443
|
-
// this.optsView.querySelector('[data-opt="nodeTypes-1"]').checked = this.options.nodeTypes.indexOf(1) !== -1;
|
|
444
|
-
// this.optsView.querySelector('[data-opt="nodeTypes-9"]').checked = this.options.nodeTypes.indexOf(9) !== -1;
|
|
445
|
-
}
|
|
450
|
+
// UI appearance refresh
|
|
451
|
+
this.uiView.className = this.options.transparent ? 'transparent' : '';
|
|
452
|
+
// this.uiView.style.display = this.options.visible ? 'grid' : 'none';
|
|
453
|
+
// this.domView.style.height = `${this.options.split}%`;
|
|
454
|
+
// this.attrView.style.height = `${100 - this.options.split}%`;
|
|
455
|
+
this.domView.querySelector('.adi-content').style.height = `${this.domView.clientHeight}px`;
|
|
456
|
+
if (!this.isInstanceViewer) {
|
|
457
|
+
this.attrView.querySelector('.adi-content').style.height = `${
|
|
458
|
+
this.attrView.clientHeight - this.menuView.clientHeight
|
|
459
|
+
}px`;
|
|
460
|
+
}
|
|
446
461
|
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
// this.uiView.style.display = this.options.visible ? 'grid' : 'none';
|
|
450
|
-
// this.domView.style.height = `${this.options.split}%`;
|
|
451
|
-
// this.attrView.style.height = `${100 - this.options.split}%`;
|
|
452
|
-
this.domView.querySelector('.adi-content').style.height = `${this.domView.clientHeight}px`;
|
|
453
|
-
if (!this.isInstanceViewer) {
|
|
454
|
-
this.attrView.querySelector('.adi-content').style.height = `${this.attrView.clientHeight -
|
|
455
|
-
this.menuView.clientHeight}px`
|
|
456
|
-
}
|
|
462
|
+
addClass(this.uiView, this.options.align);
|
|
463
|
+
}
|
|
457
464
|
|
|
458
|
-
|
|
465
|
+
// UI visibility toggle handler
|
|
466
|
+
toggleVisibilityUI() {
|
|
467
|
+
if (this.uiView === null) {
|
|
468
|
+
return;
|
|
459
469
|
}
|
|
460
470
|
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
}
|
|
471
|
+
this.uiView.style.display = this.options.visible ? 'none' : 'block';
|
|
472
|
+
this.options.visible = !this.options.visible;
|
|
473
|
+
this.saveOptions();
|
|
474
|
+
}
|
|
466
475
|
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
476
|
+
// Renders the attribute view
|
|
477
|
+
drawAttrs(elem) {
|
|
478
|
+
if (this.isInstanceViewer) {
|
|
479
|
+
return;
|
|
470
480
|
}
|
|
481
|
+
const content = this.attrView.querySelector('.adi-content');
|
|
482
|
+
// prepare attributes
|
|
483
|
+
content.innerHTML = '';
|
|
471
484
|
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
return;
|
|
476
|
-
}
|
|
477
|
-
const content = this.attrView.querySelector('.adi-content');
|
|
478
|
-
// prepare attributes
|
|
479
|
-
content.innerHTML = '';
|
|
480
|
-
|
|
481
|
-
const header = document.createElement('header');
|
|
482
|
-
header.innerText = 'Attributes';
|
|
483
|
-
content.appendChild(header);
|
|
485
|
+
const header = document.createElement('header');
|
|
486
|
+
header.innerText = 'Attributes';
|
|
487
|
+
content.appendChild(header);
|
|
484
488
|
|
|
485
|
-
|
|
486
|
-
/*
|
|
489
|
+
// todo: hook element-def.json in here
|
|
490
|
+
/*
|
|
487
491
|
if (elem.nodeName.startsWith('FX-')) {
|
|
488
492
|
console.log('got a fore element');
|
|
489
493
|
const {properties} = elem.constructor;
|
|
@@ -547,121 +551,120 @@ class ADI {
|
|
|
547
551
|
});
|
|
548
552
|
} else {
|
|
549
553
|
*/
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
554
|
+
[...elem.attributes].forEach(attr => {
|
|
555
|
+
if (attr.name !== 'style') {
|
|
556
|
+
content.appendChild(drawAttrRow(attr.name, attr.value));
|
|
557
|
+
}
|
|
558
|
+
});
|
|
559
|
+
// }
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
// Handles attribute changes
|
|
563
|
+
changeAttribute(e) {
|
|
564
|
+
const target = e ? e.target : window.event.srcElement;
|
|
565
|
+
const attr = target.getAttribute('data-attr');
|
|
566
|
+
const val = target.value;
|
|
567
|
+
const elem = this.getSelected();
|
|
568
|
+
|
|
569
|
+
// remove attribute if the new value is empty
|
|
570
|
+
if (val === '') {
|
|
571
|
+
elem.removeAttribute(attr);
|
|
572
|
+
} else {
|
|
573
|
+
elem.setAttribute(attr, val);
|
|
556
574
|
}
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
// Handles option changes
|
|
578
|
+
changeOption(e) {
|
|
579
|
+
const target = e ? e.target : window.event.srcElement;
|
|
580
|
+
const data = target.getAttribute('data-opt');
|
|
581
|
+
const val = target.checked;
|
|
582
|
+
|
|
583
|
+
if (data.indexOf('nodeTypes') !== -1) {
|
|
584
|
+
const type = parseInt(data.match(/\d+/)[0], 10);
|
|
585
|
+
|
|
586
|
+
if (val) {
|
|
587
|
+
this.options.nodeTypes.push(type);
|
|
588
|
+
} else {
|
|
589
|
+
this.options.nodeTypes.splice(this.options.nodeTypes.indexOf(type), 1);
|
|
590
|
+
}
|
|
591
|
+
} else {
|
|
592
|
+
this.options[data] = val;
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
// Key events processing
|
|
597
|
+
processKey(e) {
|
|
598
|
+
e = e || window.event;
|
|
599
|
+
const code = e.keyCode || e.which;
|
|
600
|
+
|
|
601
|
+
switch (code) {
|
|
602
|
+
case 272: // ctrl + alt + d
|
|
603
|
+
this.toggleVisibilityUI();
|
|
604
|
+
break;
|
|
605
|
+
default:
|
|
606
|
+
break;
|
|
571
607
|
}
|
|
608
|
+
}
|
|
572
609
|
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
610
|
+
// Vertical splitter resize handler
|
|
611
|
+
verticalResize(e) {
|
|
612
|
+
if (!this.vertResizing) {
|
|
613
|
+
return;
|
|
614
|
+
}
|
|
578
615
|
|
|
579
|
-
|
|
580
|
-
|
|
616
|
+
e = e || window.event;
|
|
617
|
+
document.documentElement.style.cursor = 'e-resize';
|
|
618
|
+
const nWidth = this.options.width + this.xPos - e.clientX;
|
|
581
619
|
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
} else {
|
|
588
|
-
this.options[data] = val;
|
|
589
|
-
}
|
|
620
|
+
if (nWidth >= this.options.minWidth) {
|
|
621
|
+
this.options.width = nWidth;
|
|
622
|
+
this.xPos = e.clientX;
|
|
623
|
+
this.refreshUI();
|
|
624
|
+
this.saveOptions();
|
|
590
625
|
}
|
|
626
|
+
}
|
|
591
627
|
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
switch (code) {
|
|
598
|
-
case 272: // ctrl + alt + d
|
|
599
|
-
this.toggleVisibilityUI();
|
|
600
|
-
break;
|
|
601
|
-
default:
|
|
602
|
-
break;
|
|
603
|
-
}
|
|
628
|
+
// Horizontal splitter resize handler
|
|
629
|
+
horizontalResize(e) {
|
|
630
|
+
if (!this.horizResizing) {
|
|
631
|
+
return;
|
|
604
632
|
}
|
|
605
633
|
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
return;
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
e = e || window.event;
|
|
613
|
-
document.documentElement.style.cursor = 'e-resize';
|
|
614
|
-
const nWidth = this.options.width + this.xPos - e.clientX;
|
|
615
|
-
|
|
616
|
-
if (nWidth >= this.options.minWidth) {
|
|
617
|
-
this.options.width = nWidth;
|
|
618
|
-
this.xPos = e.clientX;
|
|
619
|
-
this.refreshUI();
|
|
620
|
-
this.saveOptions();
|
|
621
|
-
}
|
|
634
|
+
e = e || window.event;
|
|
635
|
+
document.documentElement.style.cursor = 'n-resize';
|
|
636
|
+
const nSplit = Math.floor((e.clientY / this.uiView.clientHeight) * 100);
|
|
622
637
|
|
|
638
|
+
if (nSplit >= this.options.minSplit && nSplit <= 100 - this.options.minSplit) {
|
|
639
|
+
this.options.split = nSplit;
|
|
640
|
+
this.refreshUI();
|
|
641
|
+
this.saveOptions();
|
|
623
642
|
}
|
|
643
|
+
}
|
|
624
644
|
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
return;
|
|
629
|
-
}
|
|
645
|
+
processExecuteAction(e) {
|
|
646
|
+
this.refreshUI();
|
|
647
|
+
}
|
|
630
648
|
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
649
|
+
// Handles active element selection
|
|
650
|
+
handleActive(e) {
|
|
651
|
+
let target = e ? e.detail?.target || e.target : window.event.srcElement;
|
|
652
|
+
const active = this.domView.querySelector('.adi-active-node');
|
|
634
653
|
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
this.refreshUI();
|
|
638
|
-
this.saveOptions();
|
|
639
|
-
}
|
|
654
|
+
if (active) {
|
|
655
|
+
removeClass(active, 'adi-active-node');
|
|
640
656
|
}
|
|
641
657
|
|
|
642
|
-
|
|
643
|
-
|
|
658
|
+
// clicked on normal-node or end-node?
|
|
659
|
+
if (!target || target.nodeType === Node.DOCUMENT_NODE) return;
|
|
660
|
+
if (target && target.classList && target.classList.contains('adi-end-node')) {
|
|
661
|
+
target = target.parentNode.querySelector('.adi-normal-node');
|
|
644
662
|
}
|
|
645
663
|
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
let target = e ? e.detail?.target || e.target : window.event.srcElement;
|
|
649
|
-
const active = this.domView.querySelector('.adi-active-node');
|
|
650
|
-
|
|
651
|
-
if (active) {
|
|
652
|
-
removeClass(active, 'adi-active-node');
|
|
653
|
-
}
|
|
654
|
-
|
|
655
|
-
// clicked on normal-node or end-node?
|
|
656
|
-
if(!target || target.nodeType === Node.DOCUMENT_NODE) return;
|
|
657
|
-
if (target && target.classList && target.classList.contains('adi-end-node')) {
|
|
658
|
-
target = target.parentNode.querySelector('.adi-normal-node');
|
|
659
|
-
}
|
|
664
|
+
this.activeElement = target;
|
|
665
|
+
addClass(target, 'adi-active-node');
|
|
660
666
|
|
|
661
|
-
|
|
662
|
-
addClass(target, 'adi-active-node');
|
|
663
|
-
|
|
664
|
-
/*
|
|
667
|
+
/*
|
|
665
668
|
e.target.dispatchEvent(
|
|
666
669
|
new CustomEvent('handle-active', {
|
|
667
670
|
composed: true,
|
|
@@ -671,242 +674,253 @@ class ADI {
|
|
|
671
674
|
);
|
|
672
675
|
*/
|
|
673
676
|
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
677
|
+
// make it visible (scroll)
|
|
678
|
+
if (this.options.makeVisible) {
|
|
679
|
+
const wrap = this.domView.querySelector('.adi-content');
|
|
680
|
+
wrap.scrollIntoView({ block: 'center', behavior: 'instant' });
|
|
681
|
+
}
|
|
682
|
+
const selected = this.getSelected();
|
|
683
|
+
this.drawAttrs(selected);
|
|
684
|
+
|
|
685
|
+
if (selected && typeof selected.getModelItem === 'function' && selected.getModelItem()?.node) {
|
|
686
|
+
let selectedElement = selected.modelItem.node;
|
|
687
|
+
if (selectedElement?.nodeType === Node.ATTRIBUTE_NODE) {
|
|
688
|
+
selectedElement = selectedElement.ownerElement;
|
|
689
|
+
}
|
|
690
|
+
window.document.dispatchEvent(
|
|
691
|
+
new CustomEvent('log-active-element', { detail: { target: selectedElement } }),
|
|
692
|
+
);
|
|
690
693
|
}
|
|
694
|
+
// window.document.dispatchEvent(new CustomEvent('log-active-element', {detail: {target: selected}}));
|
|
695
|
+
}
|
|
691
696
|
|
|
697
|
+
// Highlights an element on page
|
|
698
|
+
highlightElement(event) {
|
|
699
|
+
// console.log('highlight',e);
|
|
700
|
+
let sourceNode = event ? event.target : window.event.srcElement;
|
|
692
701
|
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
let sourceNode = event ? event.target : window.event.srcElement;
|
|
702
|
+
if (sourceNode.classList.contains('adi-end-node')) {
|
|
703
|
+
sourceNode = sourceNode.parentNode.querySelector('.adi-normal-node');
|
|
704
|
+
}
|
|
697
705
|
|
|
698
|
-
|
|
699
|
-
sourceNode = sourceNode.parentNode.querySelector('.adi-normal-node');
|
|
700
|
-
}
|
|
706
|
+
const inspectorNode = this.sourceNodeByInspectorNodeLookup.get(sourceNode);
|
|
701
707
|
|
|
702
|
-
|
|
708
|
+
if (!inspectorNode || inspectorNode.ownerDocument !== window.document) {
|
|
709
|
+
// Not in HTML: ignore
|
|
710
|
+
return;
|
|
711
|
+
}
|
|
703
712
|
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
}
|
|
713
|
+
if (inspectorNode) {
|
|
714
|
+
if (event.type === 'mouseover') {
|
|
715
|
+
this.styleBackup = inspectorNode.getAttribute('style') || '';
|
|
716
|
+
inspectorNode.setAttribute('style', `outline: 2px solid blue; ${this.styleBackup}`);
|
|
717
|
+
} else if (this.styleBackup === '') {
|
|
718
|
+
inspectorNode.removeAttribute('style');
|
|
719
|
+
} else {
|
|
720
|
+
inspectorNode.setAttribute('style', this.styleBackup);
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
}
|
|
708
724
|
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
725
|
+
// Handles element lookup on page
|
|
726
|
+
handleLookup(e) {
|
|
727
|
+
const target = e ? e.detail?.target || e.target : window.event.srcElement;
|
|
728
|
+
|
|
729
|
+
if (!this.document.contains(target)) {
|
|
730
|
+
// Targetted at somewhere else!!!
|
|
731
|
+
return;
|
|
732
|
+
}
|
|
733
|
+
if (target.nodeType === Node.DOCUMENT_NODE) {
|
|
734
|
+
// Targetted at the document node. Nothing to highlight
|
|
735
|
+
return;
|
|
719
736
|
}
|
|
720
737
|
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
if (!this.document.contains(target)) {
|
|
726
|
-
// Targetted at somewhere else!!!
|
|
727
|
-
return;
|
|
728
|
-
}
|
|
729
|
-
if (target.nodeType === Node.DOCUMENT_NODE) {
|
|
730
|
-
// Targetted at the document node. Nothing to highlight
|
|
731
|
-
return;
|
|
732
|
-
}
|
|
733
|
-
|
|
734
|
-
if (target.className.indexOf('adi-menu-lookup') !== -1) {
|
|
735
|
-
// enable/disable interactive lookup
|
|
736
|
-
if (this.elemLookup) {
|
|
737
|
-
removeClass(target, 'adi-active');
|
|
738
|
-
this.elemLookup = false;
|
|
739
|
-
this.removeEvent(document.body, 'mouseover', this.handleLookup, true);
|
|
740
|
-
this.removeEvent(document.body, 'mouseout', this.handleLookup, true);
|
|
741
|
-
this.removeEvent(document.body, 'click', this.handleLookup, true);
|
|
742
|
-
return;
|
|
743
|
-
}
|
|
744
|
-
addClass(target, 'adi-active');
|
|
745
|
-
this.elemLookup = true;
|
|
746
|
-
this.addEventDelegate(document.body,
|
|
747
|
-
'mouseover',
|
|
748
|
-
this.handleLookup,
|
|
749
|
-
false,
|
|
750
|
-
'*',
|
|
751
|
-
true,
|
|
752
|
-
'adi-wrapper',
|
|
753
|
-
);
|
|
754
|
-
this.addEventDelegate(document.body,
|
|
755
|
-
'mouseout',
|
|
756
|
-
this.handleLookup,
|
|
757
|
-
false,
|
|
758
|
-
'*',
|
|
759
|
-
true,
|
|
760
|
-
'adi-wrapper',
|
|
761
|
-
);
|
|
762
|
-
this.addEventDelegate(document.body, 'click', this.handleLookup, false, '*', true, 'adi-wrapper');
|
|
763
|
-
return;
|
|
764
|
-
}
|
|
765
|
-
// handle lookup events
|
|
766
|
-
if (e.type === 'mouseover') {
|
|
767
|
-
this.styleBackup = target.getAttribute('style') || '';
|
|
768
|
-
target.setAttribute('style', `outline: 1px dashed red; ${this.styleBackup}`);
|
|
769
|
-
return;
|
|
770
|
-
}
|
|
771
|
-
if (e.type === 'mouseout') {
|
|
772
|
-
target.setAttribute('style', this.styleBackup);
|
|
773
|
-
return;
|
|
774
|
-
}
|
|
738
|
+
if (target.className.indexOf('adi-menu-lookup') !== -1) {
|
|
739
|
+
// enable/disable interactive lookup
|
|
740
|
+
if (this.elemLookup) {
|
|
741
|
+
removeClass(target, 'adi-active');
|
|
775
742
|
this.elemLookup = false;
|
|
776
|
-
removeClass(this.menuView.querySelector('.adi-menu-lookup'), 'adi-active');
|
|
777
|
-
target.setAttribute('style', this.styleBackup);
|
|
778
743
|
this.removeEvent(document.body, 'mouseover', this.handleLookup, true);
|
|
779
744
|
this.removeEvent(document.body, 'mouseout', this.handleLookup, true);
|
|
780
745
|
this.removeEvent(document.body, 'click', this.handleLookup, true);
|
|
781
|
-
|
|
746
|
+
return;
|
|
747
|
+
}
|
|
748
|
+
addClass(target, 'adi-active');
|
|
749
|
+
this.elemLookup = true;
|
|
750
|
+
this.addEventDelegate(
|
|
751
|
+
document.body,
|
|
752
|
+
'mouseover',
|
|
753
|
+
this.handleLookup,
|
|
754
|
+
false,
|
|
755
|
+
'*',
|
|
756
|
+
true,
|
|
757
|
+
'adi-wrapper',
|
|
758
|
+
);
|
|
759
|
+
this.addEventDelegate(
|
|
760
|
+
document.body,
|
|
761
|
+
'mouseout',
|
|
762
|
+
this.handleLookup,
|
|
763
|
+
false,
|
|
764
|
+
'*',
|
|
765
|
+
true,
|
|
766
|
+
'adi-wrapper',
|
|
767
|
+
);
|
|
768
|
+
this.addEventDelegate(
|
|
769
|
+
document.body,
|
|
770
|
+
'click',
|
|
771
|
+
this.handleLookup,
|
|
772
|
+
false,
|
|
773
|
+
'*',
|
|
774
|
+
true,
|
|
775
|
+
'adi-wrapper',
|
|
776
|
+
);
|
|
777
|
+
return;
|
|
778
|
+
}
|
|
779
|
+
// handle lookup events
|
|
780
|
+
if (e.type === 'mouseover') {
|
|
781
|
+
this.styleBackup = target.getAttribute('style') || '';
|
|
782
|
+
target.setAttribute('style', `outline: 1px dashed red; ${this.styleBackup}`);
|
|
783
|
+
return;
|
|
784
|
+
}
|
|
785
|
+
if (e.type === 'mouseout') {
|
|
786
|
+
target.setAttribute('style', this.styleBackup);
|
|
787
|
+
return;
|
|
788
|
+
}
|
|
789
|
+
this.elemLookup = false;
|
|
790
|
+
removeClass(this.menuView.querySelector('.adi-menu-lookup'), 'adi-active');
|
|
791
|
+
target.setAttribute('style', this.styleBackup);
|
|
792
|
+
this.removeEvent(document.body, 'mouseover', this.handleLookup, true);
|
|
793
|
+
this.removeEvent(document.body, 'mouseout', this.handleLookup, true);
|
|
794
|
+
this.removeEvent(document.body, 'click', this.handleLookup, true);
|
|
795
|
+
pauseEvent(e);
|
|
796
|
+
|
|
797
|
+
// find corresponding node in the DOM view
|
|
798
|
+
const active = this.sourceNodeByInspectorNodeLookup.get(target);
|
|
799
|
+
|
|
800
|
+
// activate it
|
|
801
|
+
if (!active) return;
|
|
802
|
+
if (active) {
|
|
803
|
+
active.click();
|
|
804
|
+
}
|
|
782
805
|
|
|
783
|
-
|
|
784
|
-
|
|
806
|
+
// open the whole path in DOM view
|
|
807
|
+
if (!active.parentNode) return;
|
|
808
|
+
let node = active.parentNode;
|
|
809
|
+
let tmp;
|
|
785
810
|
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
811
|
+
if (node.querySelector('ul')) {
|
|
812
|
+
node.querySelector('ul').setAttribute('data-open', 'true');
|
|
813
|
+
}
|
|
814
|
+
while (node !== this.domView.querySelector('.adi-content')) {
|
|
815
|
+
if (node.className.indexOf('adi-node') !== -1) {
|
|
816
|
+
tmp = node.querySelector('.adi-trigger');
|
|
817
|
+
if (tmp) {
|
|
818
|
+
removeClass(tmp, 'closed');
|
|
819
|
+
addClass(tmp, 'opened');
|
|
790
820
|
}
|
|
791
821
|
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
let tmp;
|
|
796
|
-
|
|
797
|
-
if (node.querySelector('ul')) {
|
|
798
|
-
node.querySelector('ul').setAttribute('data-open', 'true');
|
|
799
|
-
}
|
|
800
|
-
while (node !== this.domView.querySelector('.adi-content')) {
|
|
801
|
-
if (node.className.indexOf('adi-node') !== -1) {
|
|
802
|
-
tmp = node.querySelector('.adi-trigger');
|
|
803
|
-
if (tmp) {
|
|
804
|
-
removeClass(tmp, 'closed');
|
|
805
|
-
addClass(tmp, 'opened');
|
|
806
|
-
}
|
|
822
|
+
node = node.parentNode; // ul node
|
|
823
|
+
node.setAttribute('data-open', 'true');
|
|
824
|
+
}
|
|
807
825
|
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
}
|
|
826
|
+
node = node.parentNode;
|
|
827
|
+
}
|
|
811
828
|
|
|
812
|
-
|
|
813
|
-
|
|
829
|
+
// make it visible (scroll)
|
|
830
|
+
if (this.options.makeVisible) {
|
|
831
|
+
active.scrollIntoView({ behavior: 'instant', block: 'nearest', inline: 'nearest' });
|
|
832
|
+
}
|
|
833
|
+
target.scrollIntoView({ behavior: 'instant', block: 'nearest', inline: 'nearest' });
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
// Simple cross-browser event handler that enables simple event delegation.
|
|
837
|
+
// Note that the selector must be a string and no nesting is supported.
|
|
838
|
+
// Selector is expected to be in one of formats listed below and works for all children
|
|
839
|
+
// in the particular element.
|
|
840
|
+
// Store parameter enables storing the reference to custom event handler.
|
|
841
|
+
// Exclude parameter will exclude the particular element and all of its children, this works
|
|
842
|
+
// only for id selectors.
|
|
843
|
+
// Selector formats: tag name ("div"), class name (".my-class"), id ("#my-id") and any ("*").
|
|
844
|
+
|
|
845
|
+
addEventDelegate(elem, evt, fn, capture, selector, store, exclude) {
|
|
846
|
+
// custom event handler is registered
|
|
847
|
+
const handler = e => {
|
|
848
|
+
// check if target corresponds to the selector
|
|
849
|
+
const target = e ? e.target : window.event.srcElement;
|
|
850
|
+
const sel = selector.substr(1);
|
|
851
|
+
let delegate = false;
|
|
852
|
+
|
|
853
|
+
if (exclude) {
|
|
854
|
+
let node = target;
|
|
855
|
+
|
|
856
|
+
while (node !== document) {
|
|
857
|
+
if (node.id === exclude) {
|
|
858
|
+
return;
|
|
859
|
+
}
|
|
814
860
|
|
|
815
|
-
|
|
816
|
-
if (this.options.makeVisible) {
|
|
817
|
-
active.scrollIntoView({behavior: "instant", block: "nearest", inline: "nearest"});
|
|
861
|
+
node = node.parentNode;
|
|
818
862
|
}
|
|
819
|
-
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
// should the event be delegated?
|
|
866
|
+
if (selector.indexOf('#') === 0) {
|
|
867
|
+
// ID
|
|
868
|
+
delegate = target.id === sel;
|
|
869
|
+
} else if (selector.indexOf('.') === 0) {
|
|
870
|
+
// class
|
|
871
|
+
delegate = target.className.indexOf(sel) !== -1;
|
|
872
|
+
} else if (selector === '*') {
|
|
873
|
+
// any
|
|
874
|
+
delegate = true;
|
|
875
|
+
} else {
|
|
876
|
+
// tag name
|
|
877
|
+
delegate = target.nodeName.toLowerCase() === selector;
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
// delegate the event handling
|
|
881
|
+
if (delegate) {
|
|
882
|
+
fn(e);
|
|
883
|
+
}
|
|
884
|
+
};
|
|
885
|
+
// save the reference
|
|
886
|
+
if (store) {
|
|
887
|
+
this.delegatedEvents.push({
|
|
888
|
+
handle: handler,
|
|
889
|
+
elem,
|
|
890
|
+
fn,
|
|
891
|
+
evt,
|
|
892
|
+
});
|
|
820
893
|
}
|
|
821
894
|
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
// Selector is expected to be in one of formats listed below and works for all children
|
|
825
|
-
// in the particular element.
|
|
826
|
-
// Store parameter enables storing the reference to custom event handler.
|
|
827
|
-
// Exclude parameter will exclude the particular element and all of its children, this works
|
|
828
|
-
// only for id selectors.
|
|
829
|
-
// Selector formats: tag name ("div"), class name (".my-class"), id ("#my-id") and any ("*").
|
|
830
|
-
|
|
831
|
-
addEventDelegate(elem, evt, fn, capture, selector, store, exclude) {
|
|
832
|
-
// custom event handler is registered
|
|
833
|
-
const handler = e => {
|
|
834
|
-
// check if target corresponds to the selector
|
|
835
|
-
const target = e ? e.target : window.event.srcElement;
|
|
836
|
-
const sel = selector.substr(1);
|
|
837
|
-
let delegate = false;
|
|
838
|
-
|
|
839
|
-
if (exclude) {
|
|
840
|
-
let node = target;
|
|
841
|
-
|
|
842
|
-
while (node !== document) {
|
|
843
|
-
if (node.id === exclude) {
|
|
844
|
-
return;
|
|
845
|
-
}
|
|
846
|
-
|
|
847
|
-
node = node.parentNode;
|
|
848
|
-
}
|
|
849
|
-
}
|
|
850
|
-
|
|
851
|
-
// should the event be delegated?
|
|
852
|
-
if (selector.indexOf('#') === 0) {
|
|
853
|
-
// ID
|
|
854
|
-
delegate = target.id === sel;
|
|
855
|
-
} else if (selector.indexOf('.') === 0) {
|
|
856
|
-
// class
|
|
857
|
-
delegate = target.className.indexOf(sel) !== -1;
|
|
858
|
-
} else if (selector === '*') {
|
|
859
|
-
// any
|
|
860
|
-
delegate = true;
|
|
861
|
-
} else {
|
|
862
|
-
// tag name
|
|
863
|
-
delegate = target.nodeName.toLowerCase() === selector;
|
|
864
|
-
}
|
|
865
|
-
|
|
866
|
-
// delegate the event handling
|
|
867
|
-
if (delegate) {
|
|
868
|
-
fn(e);
|
|
869
|
-
}
|
|
870
|
-
};
|
|
871
|
-
// save the reference
|
|
872
|
-
if (store) {
|
|
873
|
-
this.delegatedEvents.push({
|
|
874
|
-
handle: handler,
|
|
875
|
-
elem,
|
|
876
|
-
fn,
|
|
877
|
-
evt,
|
|
878
|
-
});
|
|
879
|
-
}
|
|
895
|
+
elem.addEventListener(evt, handler, capture);
|
|
896
|
+
}
|
|
880
897
|
|
|
881
|
-
|
|
898
|
+
// Simple cross-browser event removing
|
|
899
|
+
removeEvent(elem, evt, fn, wasDelegated) {
|
|
900
|
+
if (typeof elem !== 'object') {
|
|
901
|
+
throw new Error(`addEvent: Expected argument elem of type object, ${typeof elem} given.`);
|
|
882
902
|
}
|
|
883
903
|
|
|
884
|
-
//
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
904
|
+
// try to find stored delegated event
|
|
905
|
+
let stored = null;
|
|
906
|
+
if (wasDelegated) {
|
|
907
|
+
for (let i = 0, len = this.delegatedEvents.length; i < len; i += 1) {
|
|
908
|
+
stored = this.delegatedEvents[i];
|
|
909
|
+
if (stored.elem === elem && stored.evt === evt && stored.fn === fn) {
|
|
910
|
+
fn = stored.handle;
|
|
911
|
+
this.delegatedEvents.splice(i, 1);
|
|
912
|
+
break;
|
|
888
913
|
}
|
|
889
|
-
|
|
890
|
-
// try to find stored delegated event
|
|
891
|
-
let stored = null;
|
|
892
|
-
if (wasDelegated) {
|
|
893
|
-
for (let i = 0, len = this.delegatedEvents.length; i < len; i += 1) {
|
|
894
|
-
stored = this.delegatedEvents[i];
|
|
895
|
-
if (stored.elem === elem && stored.evt === evt && stored.fn === fn) {
|
|
896
|
-
fn = stored.handle;
|
|
897
|
-
this.delegatedEvents.splice(i, 1);
|
|
898
|
-
break;
|
|
899
|
-
}
|
|
900
|
-
}
|
|
901
|
-
}
|
|
902
|
-
|
|
903
|
-
// elem.detachEvent(`on${evt}`, fn);
|
|
914
|
+
}
|
|
904
915
|
}
|
|
905
916
|
|
|
906
|
-
//
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
917
|
+
// elem.detachEvent(`on${evt}`, fn);
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
// Event registration
|
|
921
|
+
registerEvents() {
|
|
922
|
+
// events for splitters
|
|
923
|
+
/*
|
|
910
924
|
this.horizSplit.addEventListener(
|
|
911
925
|
'mousedown',
|
|
912
926
|
e => {
|
|
@@ -918,148 +932,180 @@ class ADI {
|
|
|
918
932
|
);
|
|
919
933
|
*/
|
|
920
934
|
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
this.
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
935
|
+
const redrawUi = () => {
|
|
936
|
+
if (this.instanceId !== '#document') {
|
|
937
|
+
const instance = window.document.querySelector(`#${this.instanceId}`);
|
|
938
|
+
this.document = instance.getInstanceData();
|
|
939
|
+
}
|
|
940
|
+
this.drawDOM(this.document, this.domView.querySelector('.adi-tree-view'), true);
|
|
941
|
+
};
|
|
942
|
+
|
|
943
|
+
// Update UI when something with instances changed
|
|
944
|
+
document.addEventListener('instance-loaded', redrawUi);
|
|
945
|
+
// Update UI when some value changes
|
|
946
|
+
document.addEventListener('value-changed', redrawUi);
|
|
947
|
+
// Update UI when we're done loading and all repeats are done
|
|
948
|
+
document.addEventListener('ready', redrawUi);
|
|
949
|
+
|
|
950
|
+
document.addEventListener(
|
|
951
|
+
'mouseup',
|
|
952
|
+
() => {
|
|
953
|
+
document.documentElement.style.cursor = 'default';
|
|
954
|
+
this.vertResizing = false;
|
|
955
|
+
this.horizResizing = false;
|
|
956
|
+
},
|
|
957
|
+
false,
|
|
958
|
+
);
|
|
959
|
+
|
|
960
|
+
document.addEventListener('mousemove', event => this.verticalResize(event), false);
|
|
961
|
+
document.addEventListener('mousemove', event => this.horizontalResize(event), false);
|
|
962
|
+
// window resize
|
|
963
|
+
window.addEventListener('resize', event => this.refreshUI(event), false);
|
|
964
|
+
|
|
965
|
+
// keypress events
|
|
966
|
+
document.addEventListener('keypress', event => this.processKey(event), false);
|
|
967
|
+
|
|
968
|
+
// fore action events
|
|
969
|
+
document.addEventListener('log-active-element', event => this.handleLookup(event), false);
|
|
970
|
+
|
|
971
|
+
// Dom view folding handler
|
|
972
|
+
const handleFolding = e => {
|
|
973
|
+
const target = e ? e.target : window.event.srcElement;
|
|
974
|
+
const ul = target.parentNode.querySelector('ul');
|
|
975
|
+
|
|
976
|
+
if (ul.getAttribute('data-open') === 'true') {
|
|
977
|
+
removeClass(target, 'opened');
|
|
978
|
+
addClass(target, 'closed');
|
|
979
|
+
ul.setAttribute('data-open', 'false');
|
|
980
|
+
} else {
|
|
981
|
+
removeClass(target, 'closed');
|
|
982
|
+
addClass(target, 'opened');
|
|
983
|
+
ul.setAttribute('data-open', 'true');
|
|
984
|
+
}
|
|
985
|
+
};
|
|
986
|
+
|
|
987
|
+
// dom tree view folding
|
|
988
|
+
this.addEventDelegate(this.domView, 'click', handleFolding, false, '.adi-trigger');
|
|
989
|
+
|
|
990
|
+
// active element
|
|
991
|
+
this.addEventDelegate(
|
|
992
|
+
this.domView,
|
|
993
|
+
'click',
|
|
994
|
+
event => this.handleActive(event),
|
|
995
|
+
false,
|
|
996
|
+
'.adi-normal-node',
|
|
997
|
+
);
|
|
998
|
+
this.addEventDelegate(
|
|
999
|
+
this.domView,
|
|
1000
|
+
'click',
|
|
1001
|
+
event => this.handleActive(event),
|
|
1002
|
+
false,
|
|
1003
|
+
'.adi-end-node',
|
|
1004
|
+
);
|
|
1005
|
+
|
|
1006
|
+
// matching tag highlighting
|
|
1007
|
+
this.addEventDelegate(
|
|
1008
|
+
this.domView,
|
|
1009
|
+
'mouseover',
|
|
1010
|
+
e => {
|
|
1011
|
+
const target = e ? e.target : window.event.srcElement;
|
|
1012
|
+
addClass(target.parentNode.querySelector('.adi-normal-node'), 'hover');
|
|
1013
|
+
},
|
|
1014
|
+
false,
|
|
1015
|
+
'.adi-end-node',
|
|
1016
|
+
);
|
|
1017
|
+
this.addEventDelegate(
|
|
1018
|
+
this.domView,
|
|
1019
|
+
'mouseout',
|
|
1020
|
+
e => {
|
|
1021
|
+
const target = e ? e.target : window.event.srcElement;
|
|
1022
|
+
removeClass(target.parentNode.querySelector('.adi-normal-node'), 'hover');
|
|
1023
|
+
},
|
|
1024
|
+
false,
|
|
1025
|
+
'.adi-end-node',
|
|
1026
|
+
);
|
|
1027
|
+
|
|
1028
|
+
// page element highlighting
|
|
1029
|
+
this.addEventDelegate(
|
|
1030
|
+
this.domView,
|
|
1031
|
+
'mouseover',
|
|
1032
|
+
event => this.highlightElement(event),
|
|
1033
|
+
false,
|
|
1034
|
+
'.adi-end-node',
|
|
1035
|
+
);
|
|
1036
|
+
this.addEventDelegate(
|
|
1037
|
+
this.domView,
|
|
1038
|
+
'mouseover',
|
|
1039
|
+
event => this.highlightElement(event),
|
|
1040
|
+
false,
|
|
1041
|
+
'.adi-normal-node',
|
|
1042
|
+
);
|
|
1043
|
+
this.addEventDelegate(
|
|
1044
|
+
this.domView,
|
|
1045
|
+
'mouseout',
|
|
1046
|
+
event => this.highlightElement(event),
|
|
1047
|
+
false,
|
|
1048
|
+
'.adi-end-node',
|
|
1049
|
+
);
|
|
1050
|
+
this.addEventDelegate(
|
|
1051
|
+
this.domView,
|
|
1052
|
+
'mouseout',
|
|
1053
|
+
event => this.highlightElement(event),
|
|
1054
|
+
false,
|
|
1055
|
+
'.adi-normal-node',
|
|
1056
|
+
);
|
|
1057
|
+
|
|
1058
|
+
// element lookup
|
|
1059
|
+
this.menuView
|
|
1060
|
+
.querySelector('.adi-menu-lookup')
|
|
1061
|
+
.addEventListener('click', event => this.handleLookup(event), false);
|
|
1062
|
+
|
|
1063
|
+
document.addEventListener('handle-active', e => {
|
|
1064
|
+
if (e.detail.selected === this.getSelected()) {
|
|
1065
|
+
// We caused this. ignore
|
|
1066
|
+
return;
|
|
1067
|
+
}
|
|
1068
|
+
const { selected } = e.detail;
|
|
1069
|
+
const target = this.sourceNodeByInspectorNodeLookup.get(selected);
|
|
1070
|
+
// make it visible (scroll)
|
|
1071
|
+
if (this.options.makeVisible) {
|
|
1072
|
+
const wrap = this.domView.querySelector('.adi-content');
|
|
1073
|
+
if (target.offsetTop >= wrap.clientHeight || target.offsetTop <= wrap.scrollTop) {
|
|
1074
|
+
wrap.scrollTop = target.offsetTop - Math.floor(wrap.clientHeight / 2);
|
|
1060
1075
|
}
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
this.drawAttrs(this.getSelected());
|
|
1079
|
+
});
|
|
1080
|
+
|
|
1081
|
+
document.addEventListener('execute-action', e => this.processExecuteAction(event), {
|
|
1082
|
+
capture: true,
|
|
1083
|
+
});
|
|
1084
|
+
|
|
1085
|
+
// options events
|
|
1086
|
+
this.addEventDelegate(
|
|
1087
|
+
this.optsView,
|
|
1088
|
+
'change',
|
|
1089
|
+
event => this.changeOption(event),
|
|
1090
|
+
false,
|
|
1091
|
+
'input',
|
|
1092
|
+
);
|
|
1093
|
+
this.addEventDelegate(
|
|
1094
|
+
this.optsView,
|
|
1095
|
+
'click',
|
|
1096
|
+
event => this.toggleOptions(event),
|
|
1097
|
+
false,
|
|
1098
|
+
'.adi-opt-close',
|
|
1099
|
+
);
|
|
1100
|
+
this.menuView
|
|
1101
|
+
.querySelector('.adi-menu-config')
|
|
1102
|
+
.addEventListener('click', event => this.toggleOptions(event), false);
|
|
1103
|
+
|
|
1104
|
+
// attributes events
|
|
1105
|
+
if (!this.isInstanceViewer) {
|
|
1106
|
+
this.addEventDelegate(this.attrView, 'change', this.changeAttribute, false, 'input');
|
|
1061
1107
|
}
|
|
1108
|
+
}
|
|
1062
1109
|
}
|
|
1063
1110
|
|
|
1064
1111
|
export default ADI;
|
|
1065
|
-
|