@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.
Files changed (88) hide show
  1. package/README.md +2 -2
  2. package/dist/fore-dev.js +2 -2
  3. package/dist/fore-dev.js.map +1 -1
  4. package/dist/fore.js +2 -2
  5. package/dist/fore.js.map +1 -1
  6. package/index.js +4 -2
  7. package/package.json +10 -38
  8. package/resources/fore.css +263 -262
  9. package/resources/vars.css +8 -0
  10. package/src/DependencyNotifyingDomFacade.js +1 -0
  11. package/src/ForeElementMixin.js +243 -228
  12. package/src/actions/abstract-action.js +407 -398
  13. package/src/actions/fx-action.js +6 -6
  14. package/src/actions/fx-append.js +1 -1
  15. package/src/actions/fx-call.js +63 -62
  16. package/src/actions/fx-confirm.js +11 -11
  17. package/src/actions/fx-construct-done.js +4 -4
  18. package/src/actions/fx-copy.js +36 -36
  19. package/src/actions/fx-delete.js +77 -79
  20. package/src/actions/fx-dispatch.js +14 -14
  21. package/src/actions/fx-hide.js +15 -15
  22. package/src/actions/fx-insert.js +9 -12
  23. package/src/actions/fx-insertchild.js +88 -0
  24. package/src/actions/fx-load.js +188 -185
  25. package/src/actions/fx-message.js +18 -19
  26. package/src/actions/fx-refresh.js +10 -10
  27. package/src/actions/fx-reload.js +16 -14
  28. package/src/actions/fx-replace.js +0 -1
  29. package/src/actions/fx-reset.js +31 -31
  30. package/src/actions/fx-send.js +59 -52
  31. package/src/actions/fx-setattribute.js +48 -49
  32. package/src/actions/fx-setfocus.js +54 -58
  33. package/src/actions/fx-setvalue.js +85 -81
  34. package/src/actions/fx-show.js +11 -11
  35. package/src/actions/fx-toggle.js +2 -2
  36. package/src/actions/fx-toggleboolean.js +38 -39
  37. package/src/actions/fx-unmodified.js +27 -0
  38. package/src/actions/fx-update.js +6 -6
  39. package/src/dep_graph.js +1 -1
  40. package/src/drawdown.js +23 -30
  41. package/src/events.js +19 -19
  42. package/src/fore.js +143 -125
  43. package/src/functions/common-function.js +24 -25
  44. package/src/functions/fx-function.js +6 -99
  45. package/src/functions/fx-functionlib.js +56 -0
  46. package/src/functions/registerFunction.js +112 -0
  47. package/src/fx-bind.js +19 -24
  48. package/src/fx-connection.js +226 -0
  49. package/src/fx-fore.js +844 -815
  50. package/src/fx-header.js +4 -4
  51. package/src/fx-instance.js +25 -29
  52. package/src/fx-model.js +405 -380
  53. package/src/fx-submission.js +399 -397
  54. package/src/fx-var.js +13 -12
  55. package/src/getInScopeContext.js +102 -89
  56. package/src/json-util.js +24 -24
  57. package/src/lab/fore-component.js +48 -52
  58. package/src/lab/instance-inspector.js +13 -16
  59. package/src/modelitem.js +48 -10
  60. package/src/relevance.js +12 -16
  61. package/src/tools/adi.js +858 -812
  62. package/src/tools/fx-action-log.js +377 -295
  63. package/src/tools/fx-devtools.js +210 -210
  64. package/src/tools/fx-dom-inspector.js +123 -122
  65. package/src/tools/fx-json-instance.js +262 -253
  66. package/src/tools/fx-log-item.js +6 -11
  67. package/src/tools/fx-log-settings.js +358 -301
  68. package/src/tools/fx-minimap.js +186 -177
  69. package/src/tools/helpers.js +1 -1
  70. package/src/ui/abstract-control.js +73 -53
  71. package/src/ui/fx-case.js +59 -7
  72. package/src/ui/fx-container.js +13 -14
  73. package/src/ui/fx-control.js +572 -538
  74. package/src/ui/fx-dialog.js +3 -3
  75. package/src/ui/fx-droptarget.js +3 -4
  76. package/src/ui/fx-group.js +4 -2
  77. package/src/ui/fx-hint.js +3 -0
  78. package/src/ui/fx-inspector.js +5 -5
  79. package/src/ui/fx-items.js +11 -11
  80. package/src/ui/fx-output.js +10 -12
  81. package/src/ui/fx-repeat-attributes.js +23 -27
  82. package/src/ui/fx-repeat.js +347 -344
  83. package/src/ui/fx-repeatitem.js +75 -68
  84. package/src/ui/fx-switch.js +39 -14
  85. package/src/ui/fx-trigger.js +4 -4
  86. package/src/withDraggability.js +193 -191
  87. package/src/xpath-evaluation.js +969 -958
  88. package/src/xpath-util.js +161 -134
package/src/tools/adi.js CHANGED
@@ -1,87 +1,87 @@
1
1
  import {
2
- addClass,
3
- removeClass,
4
- isEmptyTextNode,
5
- containsOnlyText,
6
- newElement,
7
- drawOptions,
8
- pauseEvent,
9
- drawAttrRow
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
- if(name === 'style') return false;
16
- return true;
17
- // return name === 'id' || name === 'ref' || name === 'event';
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
- 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);
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
- // Returns selected element or null
76
- getSelected() {
77
- if (!this.activeElement) {
78
- return null;
79
- }
80
-
81
- let elem = document;
81
+ let elem = document;
82
82
 
83
- elem = this.sourceNodeByInspectorNodeLookup.get(this.activeElement);
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
- return elem;
95
- }
94
+ return elem;
95
+ }
96
96
 
97
- // Loads user defined options stored in HTML5 storage (if available)
98
- loadOptions() {
99
- let userOptions = {};
97
+ // Loads user defined options stored in HTML5 storage (if available)
98
+ loadOptions() {
99
+ let userOptions = {};
100
100
 
101
- userOptions = JSON.parse(window.localStorage.getItem('ADI.options')) || {};
101
+ userOptions = JSON.parse(window.localStorage.getItem('ADI.options')) || {};
102
102
 
103
- // merge with defaults
104
- for (const opt of Object.keys(userOptions)) {
105
- this.options[opt] = userOptions[opt];
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
- // 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
- }
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
- // 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
- );
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
- return false;
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
- // Creates a starting markup for a new DOM tree view node
138
- newTreeNode(sourceNode) {
139
- if (typeof sourceNode !== 'object') {
140
- throw new Error(`newTreeNode: Expected argument node of type object, ${typeof sourceNode} given.`);
141
- }
142
-
143
- const withChildren = this.hasRequiredNodes(sourceNode);
144
- let omit = false;
145
- let adiNode = sourceNode.nodeName.startsWith('FX-') ? `adi-node ${sourceNode.nodeName.toLowerCase()}`:'';
146
- if(sourceNode.nodeName.startsWith('FX-')){
147
- adiNode = `adi-node ${sourceNode.nodeName.toLowerCase()}`;
148
- adiNode += Fore.isActionElement(sourceNode.nodeName) ? ' action':'';
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
- // do not show ADI DOM nodes in the DOM view
155
- if (sourceNode === this.uiView) {
156
- return null;
157
- }
157
+ // do not show ADI DOM nodes in the DOM view
158
+ if (sourceNode === this.uiView) {
159
+ return null;
160
+ }
158
161
 
159
- // generate UI for elements with children
160
- if (withChildren) {
161
- elem.appendChild(newElement('span', {class: 'adi-trigger'}));
162
- }
162
+ // generate UI for elements with children
163
+ if (withChildren) {
164
+ elem.appendChild(newElement('span', { class: 'adi-trigger' }));
165
+ }
163
166
 
164
- // we can omit empty text nodes if allowed in options
165
- if (this.options.omitEmptyText && sourceNode.nodeType === Node.TEXT_NODE) {
166
- omit = isEmptyTextNode(sourceNode);
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
- if (!omit) {
170
- const tagStart = newElement('span');
172
+ if (!omit) {
173
+ const tagStart = newElement('span');
171
174
 
172
- this.sourceNodeByInspectorNodeLookup.set(tagStart, sourceNode);
173
- this.sourceNodeByInspectorNodeLookup.set(sourceNode, tagStart);
175
+ this.sourceNodeByInspectorNodeLookup.set(tagStart, sourceNode);
176
+ this.sourceNodeByInspectorNodeLookup.set(sourceNode, tagStart);
174
177
 
175
- let tagEnd = null;
178
+ let tagEnd = null;
176
179
 
177
- if (containsOnlyText(sourceNode)) {
178
- if (sourceNode.nodeType === Node.COMMENT_NODE) {
179
- addClass(tagStart, 'adi-comment-node');
180
- if (typeof tagStart.innerText === 'string') {
181
- tagStart.innerText = `<!-- ${sourceNode.textContent} -->`;
182
- }
183
- } else {
184
- addClass(tagStart, 'adi-text-node');
185
- tagStart.textContent = sourceNode.textContent;
186
- }
187
- } else {
188
- addClass(tagStart, 'adi-normal-node');
189
- if (sourceNode.nodeType !== Node.DOCUMENT_NODE) {
190
- // tagStart.textContent = '<' + node.nodeName.toLowerCase() + '>';
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
- const attrString = Array.from(sourceNode.attributes)
217
- .filter(
218
- attr => this.isInstanceViewer ? true : isAttributeShown(attr.name, sourceNode))
219
- .map(attr => `${attr.name}="${attr.value}"`).join(' ');
220
- tagStart.textContent = `<${
221
- sourceNode.nodeName.toLowerCase()
222
- }${
223
- attrString ? (` ${attrString}`) : ''
224
- }>`;
225
- // }
226
-
227
- if (withChildren) {
228
- tagEnd = newElement('span');
229
- addClass(tagEnd, 'adi-end-node');
230
- tagEnd.textContent = `</${sourceNode.nodeName.toLowerCase()}>`;
231
- }
232
- } else {
233
- tagStart.textContent = sourceNode.nodeName.toLowerCase();
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
- elem.appendChild(tagStart);
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
- if (sourceNode.nodeName.startsWith('FX-')) {
250
- tagStart.classList.add('fore-node');
251
- tagStart.classList.add(sourceNode.nodeName.toLowerCase());
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
- if (sourceNode.nodeName.startsWith('FX-')) {
258
- tagEnd.classList.add('fore-node');
259
- }
260
- }
256
+ if (tagEnd) {
257
+ elem.appendChild(tagEnd);
261
258
 
262
- return elem;
259
+ if (sourceNode.nodeName.startsWith('FX-')) {
260
+ tagEnd.classList.add('fore-node');
263
261
  }
264
- return null;
262
+ }
263
+
264
+ return elem;
265
265
  }
266
+ return null;
267
+ }
266
268
 
267
- // Renders the DOM Tree view
268
- drawDOM(root, elem, isRoot) {
269
- if (typeof root !== 'object') {
270
- throw new Error(`drawDOM: Expected argument root of type object, ${typeof root} given.`);
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
- let newNode = null;
274
- let isOpen = true;
275
+ let newNode = null;
276
+ let isOpen = true;
275
277
 
276
- const adiNode = elem.nodeName.startsWith('FX-') ? `adi-node ${node.nodeName.toLowerCase()}`:'';
278
+ const adiNode = elem.nodeName.startsWith('FX-')
279
+ ? `adi-node ${node.nodeName.toLowerCase()}`
280
+ : '';
277
281
 
278
- if (isRoot && this.options.nodeTypes.indexOf(root.nodeType) !== -1) {
279
- elem.innerHTML = '';
280
- newNode = this.newTreeNode(root);
282
+ if (isRoot && this.options.nodeTypes.indexOf(root.nodeType) !== -1) {
283
+ elem.innerHTML = '';
284
+ newNode = this.newTreeNode(root);
281
285
 
282
- if (this.hasRequiredNodes(root)) {
286
+ if (this.hasRequiredNodes(root)) {
287
+ newNode.appendChild(newElement('ul', { 'data-open': true, class: adiNode }));
283
288
 
284
- newNode.appendChild(newElement('ul', {'data-open': true, class:adiNode}));
289
+ addClass(newNode.querySelector('.adi-trigger'), 'opened');
290
+ }
285
291
 
286
- addClass(newNode.querySelector('.adi-trigger'), 'opened');
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
- // recursive DOM traversal
294
- for (let i = 0, len = root.childNodes.length; i < len; i += 1) {
295
- const node = root.childNodes[i];
296
- const withChildren = this.hasRequiredNodes(node);
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
- if (this.options.nodeTypes.indexOf(node.nodeType) !== -1) {
299
- newNode = this.newTreeNode(node);
301
+ if (this.options.nodeTypes.indexOf(node.nodeType) !== -1) {
302
+ newNode = this.newTreeNode(node);
300
303
 
301
- if (newNode) {
302
- if (withChildren) {
303
- if (this.options.foldText) {
304
- isOpen = !containsOnlyText(node, true);
305
- } else {
306
- isOpen = true;
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
- if (node.nodeName === 'HEAD') isOpen = false;
310
- if (node.nodeName === 'SELECT') isOpen = false;
311
- if (node.nodeName === 'FX-INSTANCE') isOpen = false;
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
- if (node.nodeType === Node.DOCUMENT_NODE) {
319
- newNode.appendChild(newElement('ul', {'data-open': isOpen, class:adiNode}));
320
- } else {
321
- newNode.insertBefore(newElement('ul', {'data-open': isOpen,class:adiNode}), newNode.lastChild);
322
- }
323
-
324
- addClass(newNode.querySelector('.adi-trigger'), isOpen ? 'opened' : 'closed');
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
- elem.appendChild(newNode);
330
+ addClass(newNode.querySelector('.adi-trigger'), isOpen ? 'opened' : 'closed');
331
+ }
328
332
 
329
- if (this.getSelected() === node) {
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
- if (withChildren) {
338
- this.drawDOM(node, newNode.querySelector('ul'), false);
339
- }
340
- }
341
- }
342
+ if (withChildren) {
343
+ this.drawDOM(node, newNode.querySelector('ul'), false);
344
+ }
342
345
  }
346
+ }
343
347
  }
344
-
345
- // Show/hide the options view
346
- toggleOptions() {
347
- if (this.optsView.className.indexOf('adi-hidden') !== -1) {
348
- removeClass(this.optsView, 'adi-hidden');
349
- } else {
350
- addClass(this.optsView, 'adi-hidden');
351
- this.attrView.querySelector('.adi-content').innerHTML = '';
352
- this.refreshUI();
353
- this.drawDOM(document, this.domView.querySelector('.adi-tree-view'), true);
354
- if (this.options.saving) {
355
- this.saveOptions();
356
- } else {
357
- window.localStorage.removeItem('ADI.options');
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
- // Renders the UI
363
- drawUI(rootElement) {
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
- // this.uiView.appendChild(horizSplit);
409
- // wrapper.appendChild(naviWrap);
415
+ // cache UI object and append to the DOM
410
416
 
411
- // cache UI object and append to the DOM
417
+ rootElement.appendChild(this.uiView);
418
+ // document.querySelector('#inspector').appendChild(wrapper);
412
419
 
413
- rootElement.appendChild(this.uiView);
414
- // document.querySelector('#inspector').appendChild(wrapper);
420
+ this.refreshUI(true);
421
+ }
415
422
 
416
- this.refreshUI(true);
423
+ // Refreshes the global UI
424
+ refreshUI(refreshOpts) {
425
+ if (this.uiView === null) {
426
+ return;
417
427
  }
418
428
 
419
- // Refreshes the global UI
420
- refreshUI(refreshOpts) {
421
- if (this.uiView === null) {
422
- return;
423
- }
429
+ // load options if requested (e.g. before the first UI refresh)
430
+ if (refreshOpts) {
431
+ this.loadOptions();
432
+ }
424
433
 
425
- // load options if requested (e.g. before the first UI refresh)
426
- if (refreshOpts) {
427
- this.loadOptions();
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
- // Options view refresh
431
- if (refreshOpts) {
432
- this.optsView.querySelector('[data-opt="transparent"]').checked = this.options.transparent;
433
- this.optsView.querySelector('[data-opt="saving"]').checked = this.options.saving;
434
- this.optsView.querySelector(
435
- '[data-opt="omitEmptyText"]',
436
- ).checked = this.options.omitEmptyText;
437
- this.optsView.querySelector('[data-opt="makeVisible"]').checked = this.options.makeVisible;
438
- this.optsView.querySelector('[data-opt="foldText"]').checked = this.options.foldText;
439
- this.optsView.querySelector('[data-opt="nodeTypes-3"]').checked =
440
- this.options.nodeTypes.indexOf(3) !== -1;
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
- // UI appearance refresh
448
- this.uiView.className = this.options.transparent ? 'transparent' : '';
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
- addClass(this.uiView, this.options.align);
465
+ // UI visibility toggle handler
466
+ toggleVisibilityUI() {
467
+ if (this.uiView === null) {
468
+ return;
459
469
  }
460
470
 
461
- // UI visibility toggle handler
462
- toggleVisibilityUI() {
463
- if (this.uiView === null) {
464
- return;
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
- this.uiView.style.display = this.options.visible ? 'none' : 'block';
468
- this.options.visible = !this.options.visible;
469
- this.saveOptions();
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
- // Renders the attribute view
473
- drawAttrs(elem) {
474
- if (this.isInstanceViewer) {
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
- // todo: hook element-def.json in here
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
- [...elem.attributes].forEach(attr => {
551
- if(attr.name !== 'style'){
552
- content.appendChild(drawAttrRow(attr.name, attr.value));
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
- // Handles attribute changes
559
- changeAttribute(e) {
560
- const target = e ? e.target : window.event.srcElement;
561
- const attr = target.getAttribute('data-attr');
562
- const val = target.value;
563
- const elem = this.getSelected();
564
-
565
- // remove attribute if the new value is empty
566
- if (val === '') {
567
- elem.removeAttribute(attr);
568
- } else {
569
- elem.setAttribute(attr, val);
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
- // Handles option changes
574
- changeOption(e) {
575
- const target = e ? e.target : window.event.srcElement;
576
- const data = target.getAttribute('data-opt');
577
- const val = target.checked;
610
+ // Vertical splitter resize handler
611
+ verticalResize(e) {
612
+ if (!this.vertResizing) {
613
+ return;
614
+ }
578
615
 
579
- if (data.indexOf('nodeTypes') !== -1) {
580
- const type = parseInt(data.match(/\d+/)[0], 10);
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
- if (val) {
583
- this.options.nodeTypes.push(type);
584
- } else {
585
- this.options.nodeTypes.splice(this.options.nodeTypes.indexOf(type), 1);
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
- // Key events processing
593
- processKey(e) {
594
- e = e || window.event;
595
- const code = e.keyCode || e.which;
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
- // Vertical splitter resize handler
607
- verticalResize(e) {
608
- if (!this.vertResizing) {
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
- // Horizontal splitter resize handler
626
- horizontalResize(e) {
627
- if (!this.horizResizing) {
628
- return;
629
- }
645
+ processExecuteAction(e) {
646
+ this.refreshUI();
647
+ }
630
648
 
631
- e = e || window.event;
632
- document.documentElement.style.cursor = 'n-resize';
633
- const nSplit = Math.floor((e.clientY / this.uiView.clientHeight) * 100);
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
- if (nSplit >= this.options.minSplit && nSplit <= 100 - this.options.minSplit) {
636
- this.options.split = nSplit;
637
- this.refreshUI();
638
- this.saveOptions();
639
- }
654
+ if (active) {
655
+ removeClass(active, 'adi-active-node');
640
656
  }
641
657
 
642
- processExecuteAction(e) {
643
- this.refreshUI();
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
- // Handles active element selection
647
- handleActive(e) {
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
- this.activeElement = target;
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
- // make it visible (scroll)
675
- if (this.options.makeVisible) {
676
- const wrap = this.domView.querySelector('.adi-content');
677
- wrap.scrollIntoView({block:'center', behavior: 'instant'})
678
- }
679
- const selected = this.getSelected();
680
- this.drawAttrs(selected);
681
-
682
- if (selected && typeof selected.getModelItem === 'function' && selected.getModelItem()?.node) {
683
- let selectedElement = selected.modelItem.node;
684
- if (selectedElement?.nodeType === Node.ATTRIBUTE_NODE) {
685
- selectedElement = selectedElement.ownerElement;
686
- }
687
- window.document.dispatchEvent(new CustomEvent('log-active-element', {detail: {target: selectedElement}}));
688
- }
689
- // window.document.dispatchEvent(new CustomEvent('log-active-element', {detail: {target: selected}}));
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
- // Highlights an element on page
694
- highlightElement(event) {
695
- // console.log('highlight',e);
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
- if (sourceNode.classList.contains('adi-end-node')) {
699
- sourceNode = sourceNode.parentNode.querySelector('.adi-normal-node');
700
- }
706
+ const inspectorNode = this.sourceNodeByInspectorNodeLookup.get(sourceNode);
701
707
 
702
- const inspectorNode = this.sourceNodeByInspectorNodeLookup.get(sourceNode);
708
+ if (!inspectorNode || inspectorNode.ownerDocument !== window.document) {
709
+ // Not in HTML: ignore
710
+ return;
711
+ }
703
712
 
704
- if (!inspectorNode || inspectorNode.ownerDocument !== window.document) {
705
- // Not in HTML: ignore
706
- return;
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
- if (inspectorNode) {
710
- if (event.type === 'mouseover') {
711
- this.styleBackup = inspectorNode.getAttribute('style') || '';
712
- inspectorNode.setAttribute('style', `outline: 2px solid blue; ${this.styleBackup}`);
713
- } else if (this.styleBackup === '') {
714
- inspectorNode.removeAttribute('style');
715
- } else {
716
- inspectorNode.setAttribute('style', this.styleBackup);
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
- // Handles element lookup on page
722
- handleLookup(e) {
723
- const target = e ? e.detail?.target || e.target : window.event.srcElement;
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
- pauseEvent(e);
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
- // find corresponding node in the DOM view
784
- const active = this.sourceNodeByInspectorNodeLookup.get(target);
806
+ // open the whole path in DOM view
807
+ if (!active.parentNode) return;
808
+ let node = active.parentNode;
809
+ let tmp;
785
810
 
786
- // activate it
787
- if(!active) return;
788
- if (active) {
789
- active.click();
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
- // open the whole path in DOM view
793
- if (!active.parentNode) return;
794
- let node = active.parentNode;
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
- node = node.parentNode; // ul node
809
- node.setAttribute('data-open', 'true');
810
- }
826
+ node = node.parentNode;
827
+ }
811
828
 
812
- node = node.parentNode;
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
- // make it visible (scroll)
816
- if (this.options.makeVisible) {
817
- active.scrollIntoView({behavior: "instant", block: "nearest", inline: "nearest"});
861
+ node = node.parentNode;
818
862
  }
819
- target.scrollIntoView({behavior: "instant", block: "nearest", inline: "nearest"});
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
- // Simple cross-browser event handler that enables simple event delegation.
823
- // Note that the selector must be a string and no nesting is supported.
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
- elem.addEventListener(evt, handler, capture);
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
- // Simple cross-browser event removing
885
- removeEvent(elem, evt, fn, wasDelegated) {
886
- if (typeof elem !== 'object') {
887
- throw new Error(`addEvent: Expected argument elem of type object, ${typeof elem} given.`);
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
- // Event registration
907
- registerEvents() {
908
- // events for splitters
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
- const redrawUi = () => {
922
- if (this.instanceId !== '#document') {
923
- const instance = window.document.querySelector(`#${this.instanceId}`);
924
- this.document = instance.getInstanceData();
925
- }
926
- this.drawDOM(this.document, this.domView.querySelector('.adi-tree-view'), true);
927
- };
928
-
929
- // Update UI when something with instances changed
930
- document.addEventListener('instance-loaded', redrawUi);
931
- // Update UI when some value changes
932
- document.addEventListener('value-changed', redrawUi);
933
- // Update UI when we're done loading and all repeats are done
934
- document.addEventListener('ready', redrawUi);
935
-
936
- document.addEventListener(
937
- 'mouseup',
938
- () => {
939
- document.documentElement.style.cursor = 'default';
940
- this.vertResizing = false;
941
- this.horizResizing = false;
942
- },
943
- false,
944
- );
945
-
946
- document.addEventListener('mousemove', event => this.verticalResize(event), false);
947
- document.addEventListener('mousemove', event => this.horizontalResize(event), false)
948
- ;
949
- // window resize
950
- window.addEventListener('resize', event => this.refreshUI(event), false);
951
-
952
- // keypress events
953
- document.addEventListener('keypress', event => this.processKey(event), false);
954
-
955
- // fore action events
956
- document.addEventListener('log-active-element', event => this.handleLookup(event), false);
957
-
958
- // Dom view folding handler
959
- const handleFolding = e => {
960
- const target = e ? e.target : window.event.srcElement;
961
- const ul = target.parentNode.querySelector('ul');
962
-
963
- if (ul.getAttribute('data-open') === 'true') {
964
- removeClass(target, 'opened');
965
- addClass(target, 'closed');
966
- ul.setAttribute('data-open', 'false');
967
- } else {
968
- removeClass(target, 'closed');
969
- addClass(target, 'opened');
970
- ul.setAttribute('data-open', 'true');
971
- }
972
- };
973
-
974
- // dom tree view folding
975
- this.addEventDelegate(this.domView, 'click', handleFolding, false, '.adi-trigger');
976
-
977
- // active element
978
- this.addEventDelegate(this.domView, 'click', (event) => this.handleActive(event), false, '.adi-normal-node');
979
- this.addEventDelegate(this.domView, 'click', (event) => this.handleActive(event), false, '.adi-end-node');
980
-
981
- // matching tag highlighting
982
- this.addEventDelegate(
983
- this.domView,
984
- 'mouseover',
985
- e => {
986
- const target = e ? e.target : window.event.srcElement;
987
- addClass(target.parentNode.querySelector('.adi-normal-node'), 'hover');
988
- },
989
- false,
990
- '.adi-end-node',
991
- );
992
- this.addEventDelegate(
993
- this.domView,
994
- 'mouseout',
995
- e => {
996
- const target = e ? e.target : window.event.srcElement;
997
- removeClass(target.parentNode.querySelector('.adi-normal-node'), 'hover');
998
- },
999
- false,
1000
- '.adi-end-node',
1001
- );
1002
-
1003
- // page element highlighting
1004
- this.addEventDelegate(this.domView, 'mouseover', (event) => this.highlightElement(event), false, '.adi-end-node');
1005
- this.addEventDelegate(
1006
- this.domView,
1007
- 'mouseover',
1008
- (event) => this.highlightElement(event),
1009
- false,
1010
- '.adi-normal-node',
1011
- );
1012
- this.addEventDelegate(this.domView, 'mouseout', (event) => this.highlightElement(event), false, '.adi-end-node');
1013
- this.addEventDelegate(
1014
- this.domView,
1015
- 'mouseout',
1016
- (event) => this.highlightElement(event),
1017
- false,
1018
- '.adi-normal-node',
1019
- );
1020
-
1021
- // element lookup
1022
- this.menuView.querySelector('.adi-menu-lookup').addEventListener(
1023
- 'click',
1024
- event => this.handleLookup(event),
1025
- false,
1026
- );
1027
-
1028
- document.addEventListener('handle-active', (e) => {
1029
- if (e.detail.selected === this.getSelected()) {
1030
- // We caused this. ignore
1031
- return;
1032
- }
1033
- const {selected} = e.detail;
1034
- const target = this.sourceNodeByInspectorNodeLookup.get(selected);
1035
- // make it visible (scroll)
1036
- if (this.options.makeVisible) {
1037
- const wrap = this.domView.querySelector('.adi-content');
1038
- if (target.offsetTop >= wrap.clientHeight || target.offsetTop <= wrap.scrollTop) {
1039
- wrap.scrollTop = target.offsetTop - Math.floor(wrap.clientHeight / 2);
1040
- }
1041
- }
1042
-
1043
- this.drawAttrs(this.getSelected());
1044
- });
1045
-
1046
- document.addEventListener('execute-action',(e) => this.processExecuteAction(event),{capture:true});
1047
-
1048
- // options events
1049
- this.addEventDelegate(this.optsView, 'change', (event) => this.changeOption(event), false, 'input');
1050
- this.addEventDelegate(this.optsView, 'click', (event) => this.toggleOptions(event), false, '.adi-opt-close');
1051
- this.menuView.querySelector('.adi-menu-config').addEventListener(
1052
- 'click',
1053
- (event) => this.toggleOptions(event),
1054
- false,
1055
- );
1056
-
1057
- // attributes events
1058
- if(!this.isInstanceViewer) {
1059
- this.addEventDelegate(this.attrView, 'change', this.changeAttribute, false, 'input');
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
-