jqx-es 1.2.4 → 1.2.5
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/Bundle/jqx.browser.min.js +12 -12
- package/Bundle/jqx.min.js +12 -12
- package/README.md +6 -3
- package/index.js +3 -4
- package/package.json +2 -2
- package/src/HandlerFactory.js +4 -4
- package/src/JQxFactory.js +19 -16
- package/src/JQxMethods.js +6 -109
- package/src/Utilities.js +153 -84
- package/src/_JQxX.js +0 -500
package/src/HandlerFactory.js
CHANGED
|
@@ -8,7 +8,7 @@ const getCapture = eventType => !!(shouldCaptureEventTypes.find(t => t === event
|
|
|
8
8
|
export { handlerStore as listeners, HandleFactory as default };
|
|
9
9
|
|
|
10
10
|
function HandleFactory(jqx) {
|
|
11
|
-
return function(spec) {
|
|
11
|
+
return function(spec) {
|
|
12
12
|
let {eventType, selector, callback, name, capture, once, canRemove} = spec;
|
|
13
13
|
|
|
14
14
|
switch(true) {
|
|
@@ -54,10 +54,10 @@ function HandleFactory(jqx) {
|
|
|
54
54
|
function removeHandlerFactory(spec) {
|
|
55
55
|
const {once, abortcontroller, name, eventType} = spec;
|
|
56
56
|
return !name
|
|
57
|
-
? function() { jqx.logger.error(`
|
|
57
|
+
? function() { jqx.logger.error(`JQx: an anonymous listener can not be removed`); }
|
|
58
58
|
: !abortcontroller
|
|
59
59
|
? function(evt) {
|
|
60
|
-
jqx.logger.error(`
|
|
60
|
+
jqx.logger.error(`JQx: listener for event type [${eventType}] with name [${
|
|
61
61
|
name}] is not marked as removable`);
|
|
62
62
|
}
|
|
63
63
|
: function removeHandler() {
|
|
@@ -65,7 +65,7 @@ function HandleFactory(jqx) {
|
|
|
65
65
|
const toRemove = [...handlerStore[eventType].entries()].find(([k, v]) => v.name === name);
|
|
66
66
|
handlerStore[eventType].delete(toRemove[0]);
|
|
67
67
|
setTimeout( () =>
|
|
68
|
-
jqx.logger.log(`Listener for event type [${eventType}] with name [${
|
|
68
|
+
jqx.logger.log(`JQx: Listener for event type [${eventType}] with name [${
|
|
69
69
|
name}] was removed${once ? ` (once active, so handled once).` : ``}`), 100 );
|
|
70
70
|
}
|
|
71
71
|
}
|
package/src/JQxFactory.js
CHANGED
|
@@ -5,7 +5,7 @@ import { listeners, default as HandleFactory } from "./HandlerFactory.js";
|
|
|
5
5
|
import tagLib from "./HTMLTags.js";
|
|
6
6
|
import {
|
|
7
7
|
randomString, toDashedNotation, IS, tagFNFactory as $T, styleFactory, toCamelcase, systemLog, escHtml,
|
|
8
|
-
isNonEmptyString, resolveEventTypeParameter,
|
|
8
|
+
isNonEmptyString, resolveEventTypeParameter, selectedFactoryHelpers, insertPositions
|
|
9
9
|
} from "./Utilities.js";
|
|
10
10
|
|
|
11
11
|
let instanceGetters, instanceMethods;
|
|
@@ -16,15 +16,17 @@ const {
|
|
|
16
16
|
|
|
17
17
|
export { proxify, addJQxStaticMethods };
|
|
18
18
|
|
|
19
|
-
/* region functions */
|
|
20
19
|
function selectedUtilitiesFactory() {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
return {
|
|
21
|
+
...selectedFactoryHelpers(),
|
|
22
|
+
addFn(name, extensionMethod) {
|
|
23
|
+
systemLog.log(`JQx: added extension function [${name}]`);
|
|
24
|
+
return instanceMethods[name] = (self, ...params) => extensionMethod(self, ...params);
|
|
25
|
+
} };
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
function proxify(instance) {
|
|
27
|
-
return new Proxy( instance, { get: (obj, key) => proxyKeyFactory(obj, key, instance) } );
|
|
29
|
+
return new Proxy( instance, Object.freeze({ get: (obj, key) => proxyKeyFactory(obj, key, instance) }) );
|
|
28
30
|
}
|
|
29
31
|
|
|
30
32
|
function wrap(method, instance) {
|
|
@@ -162,25 +164,27 @@ function delegateCaptureFactory(listen) {
|
|
|
162
164
|
let {type, origin, selector, handlers, name, capture, once, canRemove} = spec;
|
|
163
165
|
const typesResolved = resolveEventTypeParameter(type);
|
|
164
166
|
const specifiedName = name;
|
|
165
|
-
if (!IS(handlers, Function, Array)) { return; }
|
|
166
167
|
handlers = IS(handlers, Function) ? [handlers] : handlers;
|
|
167
168
|
canRemove = IS(canRemove, Boolean) ? canRemove : false;
|
|
168
|
-
const params = {
|
|
169
|
+
const params = {
|
|
170
|
+
eventType: typesResolved, selector: selector || origin, capture,
|
|
169
171
|
name: specifiedName, once, canRemove };
|
|
172
|
+
|
|
170
173
|
switch(true) {
|
|
171
174
|
case IS(typesResolved, Array) && typesResolved.length > 0:
|
|
172
175
|
for (const type of typesResolved) {
|
|
173
176
|
params.eventType = type;
|
|
174
|
-
|
|
177
|
+
assignListeners(handlers, params, listen);
|
|
175
178
|
}
|
|
176
|
-
|
|
177
|
-
default:
|
|
179
|
+
break;
|
|
180
|
+
default: return assignListeners(handlers, params, listen);
|
|
178
181
|
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
179
184
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
}
|
|
185
|
+
function assignListeners(handlers, params, listen) {
|
|
186
|
+
for (const handler of handlers) {
|
|
187
|
+
listen({...params, callback: handler});
|
|
184
188
|
}
|
|
185
189
|
}
|
|
186
190
|
|
|
@@ -247,4 +251,3 @@ function staticMethodsFactory(jqx) {
|
|
|
247
251
|
get Popup() { return popupGetter(jqx); },
|
|
248
252
|
};
|
|
249
253
|
}
|
|
250
|
-
/* endregion functions */
|
package/src/JQxMethods.js
CHANGED
|
@@ -1,116 +1,13 @@
|
|
|
1
1
|
import {createElementFromHtmlString, inject2DOMTree} from "./DOM.js";
|
|
2
|
-
import {ATTRS} from "./EmbedResources.js";
|
|
3
2
|
import {
|
|
4
3
|
IS, isNode, truncateHtmlStr, addHandlerId, ExamineElementFeatureFactory,
|
|
5
4
|
isNonEmptyString, toDashedNotation, randomString, escHtml, systemLog,
|
|
6
|
-
insertPositions,
|
|
5
|
+
insertPositions, datasetKeyProxy, loop, cloneAndDestroy, setData, before,
|
|
6
|
+
after, findParentScrollDistance, emptyElement, checkProp, css, assignAttrValues,
|
|
7
|
+
applyStyle,
|
|
7
8
|
} from "./Utilities.js";
|
|
8
9
|
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
/* region functions */
|
|
12
|
-
function emptyElement(el) {
|
|
13
|
-
return el && (el.textContent = "");
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function loop(instance, callback) {
|
|
17
|
-
const cleanCollection = instance.collection.filter(el => !isCommentOrTextNode(el));
|
|
18
|
-
for (let i = 0; i < cleanCollection.length; i += 1) {
|
|
19
|
-
callback(cleanCollection[i], i);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return instance;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function compareCI(key, compareTo) {
|
|
26
|
-
return key.toLowerCase().trim() === compareTo.trim().toLowerCase();
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function cloneAndDestroy(elem) {
|
|
30
|
-
const cloned = elem.cloneNode(true)
|
|
31
|
-
cloned.removeAttribute && cloned.removeAttribute(`id`);
|
|
32
|
-
elem.isConnected ? elem.remove() : elem = null;
|
|
33
|
-
return cloned;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function setData(el, keyValuePairs) {
|
|
37
|
-
if (el && IS(keyValuePairs, Object)) {
|
|
38
|
-
for (const [key, value] of Object.entries(keyValuePairs)) {
|
|
39
|
-
el.setAttribute(`data-${toDashedNotation(key)}`, value);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function before (instance, elem2AddBefore) {
|
|
45
|
-
return instance.andThen(elem2AddBefore, true);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function after(instance, elem2AddAfter) {
|
|
49
|
-
return instance.andThen(elem2AddAfter);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function checkProp(prop) {
|
|
53
|
-
return prop.startsWith(`data`) || ATTRS.html.find(attr => prop.toLowerCase() === attr);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function css(el, keyOrKvPairs, value, jqx) {
|
|
57
|
-
if (value && IS(keyOrKvPairs, String)) {
|
|
58
|
-
keyOrKvPairs = {[keyOrKvPairs]: value === "-" ? "" : value};
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
let nwClass = undefined;
|
|
62
|
-
|
|
63
|
-
if (keyOrKvPairs.className) {
|
|
64
|
-
nwClass = keyOrKvPairs.className;
|
|
65
|
-
delete keyOrKvPairs.className;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const classExists = ([...el.classList].find(c => c.startsWith(`JQxClass-`) || nwClass && c === nwClass));
|
|
69
|
-
nwClass = classExists || nwClass || `JQxClass-${randomString().slice(1)}`;
|
|
70
|
-
jqx.editCssRule(`.${nwClass}`, keyOrKvPairs);
|
|
71
|
-
el.classList.add(nwClass);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function assignAttrValues(/*NODOC*/el, keyValuePairs) {
|
|
75
|
-
if (el) {
|
|
76
|
-
for (let [key, value] of Object.entries(keyValuePairs)) {
|
|
77
|
-
key = toDashedNotation(key);
|
|
78
|
-
if (key.startsWith(`data`)) {
|
|
79
|
-
return setData(el, value);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (IS(value, String) && checkProp(key)) {
|
|
83
|
-
el.setAttribute(key, value.split(/[, ]/)?.join(` `));
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function applyStyle(el, rules) {
|
|
90
|
-
if (IS(rules, Object)) {
|
|
91
|
-
for (let [key, value] of Object.entries(rules)) {
|
|
92
|
-
let priority;
|
|
93
|
-
if (/!important/i.test(value)) {
|
|
94
|
-
value = value.slice(0, value.indexOf(`!`)).trim();
|
|
95
|
-
priority = 'important';
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
el.style.setProperty(toDashedNotation(key), value, priority)
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
function logDebug(...args) {
|
|
104
|
-
debugLog.log(`❗` + args.map(v => String(v)).join(`, `) ) ;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
function findParentScrollDistance(node, distance = 0, top = true) {
|
|
108
|
-
node = node?.parentElement;
|
|
109
|
-
const what = top ? `scrollTop` : `scrollLeft`;
|
|
110
|
-
distance += node ? node[what] : 0;
|
|
111
|
-
return !node ? distance : findParentScrollDistance(node, distance, top);
|
|
112
|
-
}
|
|
113
|
-
/* endregion functions */
|
|
10
|
+
const instanceIs = ExamineElementFeatureFactory();
|
|
114
11
|
|
|
115
12
|
/* region exportfunctions */
|
|
116
13
|
function factoryExtensionsFactory(jqx) {
|
|
@@ -179,7 +76,7 @@ function factoryExtensionsFactory(jqx) {
|
|
|
179
76
|
return instance.HTML.set(content + instance.HTML.get(), false, escape);
|
|
180
77
|
},
|
|
181
78
|
}),
|
|
182
|
-
is: instance =>
|
|
79
|
+
is: instance => instanceIs(instance),
|
|
183
80
|
length: instance => instance.collection.length,
|
|
184
81
|
outerHtml: instance => (instance.first() || {outerHTML: undefined}).outerHTML,
|
|
185
82
|
parent: instance =>{
|
|
@@ -233,7 +130,7 @@ function instanceExtensionsFactory(jqx) {
|
|
|
233
130
|
afterMe: after,
|
|
234
131
|
andThen: (instance, elem2Add, before = false) => {
|
|
235
132
|
if (!elem2Add || !IS(elem2Add, String, Node, Proxy)) {
|
|
236
|
-
|
|
133
|
+
systemLog.log(`[JQx instance].[beforeMe | afterMe | andThen]: insufficient input [${elem2Add}]`, );
|
|
237
134
|
return instance;
|
|
238
135
|
}
|
|
239
136
|
|
package/src/Utilities.js
CHANGED
|
@@ -1,24 +1,34 @@
|
|
|
1
1
|
import {default as tagFNFactory} from "./tinyDOM.js";
|
|
2
2
|
import {default as IS, maybe} from "./TypeofAnything.js";
|
|
3
3
|
import styleFactory from "./LifeCSS.js";
|
|
4
|
+
import {ATTRS} from "./EmbedResources.js";
|
|
4
5
|
|
|
5
6
|
const characters4RandomString = [...Array(26)]
|
|
6
7
|
.map((x, i) => String.fromCharCode(i + 65))
|
|
7
8
|
.concat([...Array(26)].map((x, i) => String.fromCharCode(i + 97)))
|
|
8
9
|
.concat([...Array(10)].map((x, i) => `${i}`));
|
|
9
10
|
const systemLog = systemLogFactory();
|
|
10
|
-
const datasetKeyProxy = {
|
|
11
|
+
const datasetKeyProxy = Object.freeze({
|
|
11
12
|
get(obj, key) { return obj[toCamelcase(key)] || obj[key]; },
|
|
12
13
|
enumerable: false,
|
|
13
14
|
configurable: false
|
|
14
|
-
};
|
|
15
|
-
const insertPositions = new Proxy({
|
|
15
|
+
});
|
|
16
|
+
const insertPositions = Object.freeze(new Proxy({
|
|
16
17
|
start: "afterbegin", afterbegin: "afterbegin",
|
|
17
18
|
end: "beforeend", beforeend: "beforeend",
|
|
18
19
|
before: "beforebegin", beforebegin: "beforebegin",
|
|
19
20
|
after: "afterend", afterend: "afterend" }, {
|
|
20
21
|
get(obj, key) { return obj[String(key).toLowerCase()] ?? obj[key]; }
|
|
21
|
-
});
|
|
22
|
+
}));
|
|
23
|
+
|
|
24
|
+
export {
|
|
25
|
+
addHandlerId, after, applyStyle, assignAttrValues, before, checkProp, cloneAndDestroy, css, datasetKeyProxy,
|
|
26
|
+
ElemArray2HtmlString, emptyElement, escHtml, ExamineElementFeatureFactory, findParentScrollDistance,
|
|
27
|
+
input2Collection, insertPositions, IS, isArrayOfHtmlElements, isArrayOfHtmlStrings, isCommentOrTextNode,
|
|
28
|
+
isHtmlString, isNode, isNonEmptyString, logTime, loop, maybe, randomNr, randomString, resolveEventTypeParameter,
|
|
29
|
+
selectedFactoryHelpers, setCollectionFromCssSelector, setData, styleFactory, systemLog, tagFNFactory,
|
|
30
|
+
toCamelcase, toDashedNotation, truncate2SingleStr, truncateHtmlStr,
|
|
31
|
+
};
|
|
22
32
|
|
|
23
33
|
function pad0(nr, n=2) {
|
|
24
34
|
return `${nr}`.padStart(n, `0`);
|
|
@@ -41,6 +51,15 @@ function resolveEventTypeParameter (maybeTypes) {
|
|
|
41
51
|
: IS(maybeTypes, String) && maybeTypes?.trim().toLowerCase() || ``;
|
|
42
52
|
}
|
|
43
53
|
|
|
54
|
+
function loop(instance, callback) {
|
|
55
|
+
const cleanCollection = instance.collection.filter(el => !isCommentOrTextNode(el));
|
|
56
|
+
for (let i = 0; i < cleanCollection.length; i += 1) {
|
|
57
|
+
callback(cleanCollection[i], i);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return instance;
|
|
61
|
+
}
|
|
62
|
+
|
|
44
63
|
function shuffle(array) {
|
|
45
64
|
let i = array.length;
|
|
46
65
|
while (i--) {
|
|
@@ -50,11 +69,6 @@ function shuffle(array) {
|
|
|
50
69
|
return array;
|
|
51
70
|
}
|
|
52
71
|
|
|
53
|
-
function hex2Full(hex) {
|
|
54
|
-
hex = (hex.trim().startsWith("#") ? hex.slice(1) : hex).trim();
|
|
55
|
-
return hex.length === 3 ? [...hex].map(v => v + v).join("") : hex;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
72
|
function truncateHtmlStr(str, maxLength = 120) {
|
|
59
73
|
return `${str}`
|
|
60
74
|
.trim()
|
|
@@ -96,17 +110,14 @@ function logTime() {
|
|
|
96
110
|
pad0(d.getSeconds())}.${pad0(d.getMilliseconds(), 3)}]`)(new Date());
|
|
97
111
|
}
|
|
98
112
|
|
|
99
|
-
function hex2RGBA(hex, opacity = 100) {
|
|
100
|
-
hex = hex2Full(hex.slice(1));
|
|
101
|
-
const op = opacity % 100 !== 0;
|
|
102
|
-
return `rgb${op ? "a" : ""}(${
|
|
103
|
-
parseInt(hex.slice(0, 2), 16)}, ${
|
|
104
|
-
parseInt(hex.slice(2, 4), 16)}, ${
|
|
105
|
-
parseInt(hex.slice(-2), 16)}${op ? `, ${opacity / 100}` : ""})`;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
113
|
function escHtml(html) {
|
|
109
|
-
|
|
114
|
+
switch(true) {
|
|
115
|
+
case IS(html, String):
|
|
116
|
+
const tmpDiv = document.createElement("div");
|
|
117
|
+
tmpDiv.append(html);
|
|
118
|
+
return tmpDiv.innerHTML;
|
|
119
|
+
default: return html;
|
|
120
|
+
}
|
|
110
121
|
}
|
|
111
122
|
|
|
112
123
|
function isCommentOrTextNode(node) {
|
|
@@ -171,11 +182,11 @@ function addHandlerId(instance) {
|
|
|
171
182
|
return `[data-hid="${handleId}"]`;
|
|
172
183
|
}
|
|
173
184
|
|
|
174
|
-
function
|
|
185
|
+
function selectedFactoryHelpers() {
|
|
175
186
|
return {
|
|
176
187
|
isCommentOrTextNode, isNode, isComment, isText, isHtmlString, isArrayOfHtmlElements,
|
|
177
188
|
isArrayOfHtmlStrings, ElemArray2HtmlString, input2Collection, setCollectionFromCssSelector,
|
|
178
|
-
addHandlerId };
|
|
189
|
+
addHandlerId, cssRuleEdit: styleFactory({createWithId: `JQxStylesheet`}) };
|
|
179
190
|
}
|
|
180
191
|
|
|
181
192
|
function isVisible(el) {
|
|
@@ -200,45 +211,49 @@ function isModal(elem) {
|
|
|
200
211
|
|
|
201
212
|
function ExamineElementFeatureFactory() {
|
|
202
213
|
const notApplicable = `n/a`;
|
|
203
|
-
const noElements = {
|
|
214
|
+
const noElements = Object.freeze({
|
|
204
215
|
notInDOM: true, writable: notApplicable, modal: notApplicable, empty: true,
|
|
205
|
-
open: notApplicable, visible: notApplicable, };
|
|
216
|
+
open: notApplicable, visible: notApplicable, });
|
|
206
217
|
|
|
207
218
|
return self => {
|
|
208
219
|
const firstElem = self.node;
|
|
209
220
|
|
|
210
|
-
return IS(firstElem, Node)
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
221
|
+
return IS(firstElem, Node)
|
|
222
|
+
? Object.freeze({
|
|
223
|
+
get writable() {
|
|
224
|
+
return isWritable(firstElem);
|
|
225
|
+
},
|
|
226
|
+
get modal() {
|
|
227
|
+
return isModal(firstElem);
|
|
228
|
+
},
|
|
229
|
+
get inDOM() {
|
|
230
|
+
return firstElem.isConnected;
|
|
231
|
+
},
|
|
232
|
+
get open() {
|
|
233
|
+
return firstElem.open ?? false;
|
|
234
|
+
},
|
|
235
|
+
get visible() {
|
|
236
|
+
return isVisible(firstElem);
|
|
237
|
+
},
|
|
238
|
+
get disabled() {
|
|
239
|
+
return firstElem.hasAttribute("readonly") || firstElem.hasAttribute("disabled");
|
|
240
|
+
},
|
|
241
|
+
get empty() {
|
|
242
|
+
return self.collection.length < 1;
|
|
243
|
+
},
|
|
244
|
+
get virtual() {
|
|
245
|
+
return self.isVirtual;
|
|
246
|
+
}
|
|
247
|
+
})
|
|
248
|
+
: noElements;
|
|
236
249
|
};
|
|
237
250
|
}
|
|
238
251
|
|
|
239
252
|
function decodeForConsole(something) {
|
|
240
253
|
return IS(something, String) &&
|
|
241
|
-
Object.assign(
|
|
254
|
+
Object.assign(
|
|
255
|
+
document.createElement(`textarea`),
|
|
256
|
+
{innerHTML: something}).textContent || something;
|
|
242
257
|
}
|
|
243
258
|
|
|
244
259
|
function systemLogFactory() {
|
|
@@ -258,9 +273,10 @@ function systemLogFactory() {
|
|
|
258
273
|
|
|
259
274
|
function log(...args) {
|
|
260
275
|
backLog.unshift(...args.map(arg => `${logTime()} ✔ ${decodeForConsole(arg)}`));
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
276
|
+
switch(on) {
|
|
277
|
+
case true: console.log(backLog.slice(0, args.length).join(`\n`));
|
|
278
|
+
default: return systemLogger;
|
|
279
|
+
}
|
|
264
280
|
}
|
|
265
281
|
|
|
266
282
|
Object.defineProperties(systemLogger, {
|
|
@@ -271,34 +287,87 @@ function systemLogFactory() {
|
|
|
271
287
|
return Object.freeze(systemLogger);
|
|
272
288
|
}
|
|
273
289
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
290
|
+
function cloneAndDestroy(elem) {
|
|
291
|
+
const cloned = elem.cloneNode(true)
|
|
292
|
+
cloned.removeAttribute && cloned.removeAttribute(`id`);
|
|
293
|
+
elem.isConnected ? elem.remove() : elem = null;
|
|
294
|
+
return cloned;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
function setData(el, keyValuePairs) {
|
|
298
|
+
if (el && IS(keyValuePairs, Object)) {
|
|
299
|
+
for (const [key, value] of Object.entries(keyValuePairs)) {
|
|
300
|
+
el.setAttribute(`data-${toDashedNotation(key)}`, value);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
function before (instance, elem2AddBefore) {
|
|
306
|
+
return instance.andThen(elem2AddBefore, true);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
function after(instance, elem2AddAfter) {
|
|
310
|
+
return instance.andThen(elem2AddAfter);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
function findParentScrollDistance(node, distance = 0, top = true) {
|
|
314
|
+
node = node?.parentElement;
|
|
315
|
+
const what = top ? `scrollTop` : `scrollLeft`;
|
|
316
|
+
distance += node ? node[what] : 0;
|
|
317
|
+
return !node ? distance : findParentScrollDistance(node, distance, top);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
function emptyElement(el) {
|
|
321
|
+
return el && (el.textContent = "");
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
function checkProp(prop) {
|
|
325
|
+
return prop.startsWith(`data`) || ATTRS.html.find(attr => prop.toLowerCase() === attr);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
function css(el, keyOrKvPairs, value, jqx) {
|
|
329
|
+
if (value && IS(keyOrKvPairs, String)) {
|
|
330
|
+
keyOrKvPairs = {[keyOrKvPairs]: value === "-" ? "" : value};
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
let nwClass = undefined;
|
|
334
|
+
|
|
335
|
+
if (keyOrKvPairs.className) {
|
|
336
|
+
nwClass = keyOrKvPairs.className;
|
|
337
|
+
delete keyOrKvPairs.className;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
const classExists = ([...el.classList].find(c => c.startsWith(`JQxClass-`) || nwClass && c === nwClass));
|
|
341
|
+
nwClass = classExists || nwClass || `JQxClass-${randomString().slice(1)}`;
|
|
342
|
+
jqx.editCssRule(`.${nwClass}`, keyOrKvPairs);
|
|
343
|
+
el.classList.add(nwClass);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
function assignAttrValues(/*NODOC*/el, keyValuePairs) {
|
|
347
|
+
if (el) {
|
|
348
|
+
for (let [key, value] of Object.entries(keyValuePairs)) {
|
|
349
|
+
key = toDashedNotation(key);
|
|
350
|
+
if (key.startsWith(`data`)) {
|
|
351
|
+
return setData(el, value);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
if (IS(value, String) && checkProp(key)) {
|
|
355
|
+
el.setAttribute(key, value.split(/[, ]/)?.join(` `));
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
function applyStyle(el, rules) {
|
|
362
|
+
if (IS(rules, Object)) {
|
|
363
|
+
for (let [key, value] of Object.entries(rules)) {
|
|
364
|
+
let priority;
|
|
365
|
+
if (/!important/i.test(value)) {
|
|
366
|
+
value = value.slice(0, value.indexOf(`!`)).trim();
|
|
367
|
+
priority = 'important';
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
el.style.setProperty(toDashedNotation(key), value, priority)
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
}
|