jqx-es 1.2.0 → 1.2.1
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 +15 -19
- package/Bundle/jqx.min.js +15 -19
- package/index.js +8 -8
- package/package.json +1 -1
- package/src/DOMCleanup.js +5 -5
- package/src/EmbedResources.js +1 -16
- package/src/HandlerFactory.js +23 -12
- package/src/JQxExtensionHelpers.js +51 -105
- package/src/JQxMethods.js +5 -5
- package/src/Utilities.js +146 -33
- package/src/JQxLog.js +0 -172
package/index.js
CHANGED
|
@@ -17,9 +17,9 @@ import {
|
|
|
17
17
|
addJQxStaticMethods,
|
|
18
18
|
createElementFromHtmlString,
|
|
19
19
|
insertPositions,
|
|
20
|
-
systemLog,
|
|
21
20
|
IS,
|
|
22
21
|
} from "./src/JQxExtensionHelpers.js";
|
|
22
|
+
import { systemLog, } from "./src/Utilities.js";
|
|
23
23
|
|
|
24
24
|
export default addJQxStaticMethods(JQxFactory());
|
|
25
25
|
|
|
@@ -34,7 +34,7 @@ function JQxFactory() {
|
|
|
34
34
|
const isRawHtml = isHtmlString(input);
|
|
35
35
|
const isRawHtmlArray = !isRawHtml && isArrayOfHtmlStrings(input);
|
|
36
36
|
const shouldCreateElements = isRawHtmlArray || isRawHtml;
|
|
37
|
-
|
|
37
|
+
|
|
38
38
|
let instance = {
|
|
39
39
|
collection: input2Collection(input) ?? [],
|
|
40
40
|
isVirtual,
|
|
@@ -42,7 +42,7 @@ function JQxFactory() {
|
|
|
42
42
|
};
|
|
43
43
|
|
|
44
44
|
const isRawElemCollection = isArrayOfHtmlElements(instance.collection);
|
|
45
|
-
|
|
45
|
+
|
|
46
46
|
const logStr = `input => ${
|
|
47
47
|
isRawHtmlArray
|
|
48
48
|
? `"${truncateHtmlStr(input.join(`, `), logLineLength)}"`
|
|
@@ -53,7 +53,7 @@ function JQxFactory() {
|
|
|
53
53
|
: `"${truncateHtmlStr(input, logLineLength)}"`}`;
|
|
54
54
|
|
|
55
55
|
if (instance.collection.length && isRawElemCollection) {
|
|
56
|
-
systemLog(logStr);
|
|
56
|
+
systemLog.log(logStr);
|
|
57
57
|
|
|
58
58
|
if (!isVirtual) {
|
|
59
59
|
instance.collection.forEach(el => {
|
|
@@ -74,13 +74,13 @@ function JQxFactory() {
|
|
|
74
74
|
const errors = instance.collection.filter( el => el?.dataset?.jqxcreationerror );
|
|
75
75
|
instance.collection = instance.collection.filter(el => !el?.dataset?.jqxcreationerror);
|
|
76
76
|
|
|
77
|
-
systemLog(`${logStr}`);
|
|
78
|
-
systemLog(`*Created ${instance.isVirtual ? `VIRTUAL ` : ``}[${
|
|
77
|
+
systemLog.log(`${logStr}`);
|
|
78
|
+
systemLog.log(`*Created ${instance.isVirtual ? `VIRTUAL ` : ``}[${
|
|
79
79
|
truncateHtmlStr(ElemArray2HtmlString(instance.collection) ||
|
|
80
80
|
"sanitized: no elements remaining", logLineLength)}]`);
|
|
81
81
|
|
|
82
82
|
if (errors.length) {
|
|
83
|
-
|
|
83
|
+
systemLog.error(`JQx: illegal html, not rendered: "${
|
|
84
84
|
errors.reduce( (acc, el) => acc.concat(`${el.textContent}\n`), ``).trim()}"` );
|
|
85
85
|
}
|
|
86
86
|
|
|
@@ -93,7 +93,7 @@ function JQxFactory() {
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
const forLog = setCollectionFromCssSelector(input, root, instance);
|
|
96
|
-
systemLog(`input => ${forLog}`);
|
|
96
|
+
systemLog.log(`input => ${forLog}`);
|
|
97
97
|
return proxify(instance);
|
|
98
98
|
}
|
|
99
99
|
}
|
package/package.json
CHANGED
package/src/DOMCleanup.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { truncate2SingleStr, IS
|
|
1
|
+
import { truncate2SingleStr, IS/*, debugLog*/ } from "./JQxExtensionHelpers.js";
|
|
2
2
|
import cleanupTagInfo from "./HTMLTags.js";
|
|
3
3
|
import {ATTRS} from "./EmbedResources.js";
|
|
4
|
-
import {escHtml} from "./Utilities.js";
|
|
4
|
+
import {escHtml, systemLog} from "./Utilities.js";
|
|
5
5
|
|
|
6
6
|
let logElementCreationErrors2Console = true;
|
|
7
7
|
const attrRegExpStore = {
|
|
8
8
|
data: /data-[\-\w.\p{L}]/ui, // data-* minimal 1 character after dash
|
|
9
9
|
validURL: /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i,
|
|
10
10
|
whiteSpace: /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g,
|
|
11
|
-
notAllowedValues:
|
|
11
|
+
notAllowedValues: /^javascript|injected|noreferrer|alert|DataURL/gi
|
|
12
12
|
};
|
|
13
13
|
const logContingentErrors = elCreationInfo => {
|
|
14
14
|
if (logElementCreationErrors2Console && Object.keys(elCreationInfo.removed).length) {
|
|
15
15
|
const msgs = Object.entries(elCreationInfo.removed)
|
|
16
16
|
.reduce( (acc, [k, v]) => [...acc, `${escHtml(k)} => ${v}`], [])
|
|
17
17
|
.join(`\\000A`);
|
|
18
|
-
|
|
18
|
+
systemLog.error(`JQx HTML creation errors: ${msgs}`);
|
|
19
19
|
}
|
|
20
20
|
};
|
|
21
21
|
const elementCheck = function(child) {
|
|
@@ -51,7 +51,7 @@ const cleanupHtml = el2Clean => {
|
|
|
51
51
|
if (evilValue || evilAttrib) {
|
|
52
52
|
let val = truncate2SingleStr(attr.value || `none`, 60);
|
|
53
53
|
val += val.length === 60 ? `...` : ``;
|
|
54
|
-
elCreationInfo.removed[`${attr.name}`] = `attribute/property
|
|
54
|
+
elCreationInfo.removed[`${attr.name}`] = `attribute/property/value not allowed, removed. Value: ${
|
|
55
55
|
val}`;
|
|
56
56
|
child.removeAttribute(attr.name);
|
|
57
57
|
}
|
package/src/EmbedResources.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
const svgImg = `url('data:image/svg+xml\\3butf8,%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22iso-8859-1%22%3F%3E%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20xmlns%3Axlink%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink%22%20version%3D%221.1%22%20id%3D%22Layer_1%22%20x%3D%220px%22%20y%3D%220px%22%20viewBox%3D%220%200%20128%20128%22%20style%3D%22enable-background%3Anew%200%200%20128%20128%3B%22%20xml%3Aspace%3D%22preserve%22%3E%3Crect%20x%3D%22-368%22%20y%3D%226%22%20style%3D%22display%3Anone%3Bfill%3A%23E0E0E0%3B%22%20width%3D%22866%22%20height%3D%221018%22%2F%3E%3Ccircle%20style%3D%22fill%3A%23FFFFFF%3B%22%20cx%3D%2264%22%20cy%3D%2264%22%20r%3D%2248%22%2F%3E%3Ccircle%20style%3D%22fill%3A%238CCFB9%3B%22%20cx%3D%2264%22%20cy%3D%2264%22%20r%3D%2239%22%2F%3E%3Ccircle%20style%3D%22fill%3Anone%3Bstroke%3A%23444B54%3Bstroke-width%3A6%3Bstroke-miterlimit%3A10%3B%22%20cx%3D%2264%22%20cy%3D%2264%22%20r%3D%2248%22%2F%3E%3Cpolyline%20style%3D%22fill%3Anone%3Bstroke%3A%23FFFFFF%3Bstroke-width%3A6%3Bstroke-linecap%3Around%3Bstroke-miterlimit%3A10%3B%22%20points%3D%2242%2C69%2055.55%2C81%20%20%2086%2C46%20%22%2F%3E%3C%2Fsvg%3E')`;
|
|
2
|
-
let logStyling = getLogStyling();
|
|
3
2
|
let popupStyling = getPopupStyling();
|
|
4
3
|
const ATTRS = getAttrs();
|
|
5
4
|
const allTags = getPermissions();
|
|
6
|
-
export {
|
|
5
|
+
export {popupStyling, ATTRS, allTags};
|
|
7
6
|
|
|
8
7
|
function getAttrs() {
|
|
9
8
|
return {
|
|
@@ -18,20 +17,6 @@ function getPermissions() {
|
|
|
18
17
|
return {a:true,area:true,audio:false,br:true,base:true,body:true,button:true,canvas:true,comment:true,dl:true,data:true,datalist:true,div:true,em:true, embed:false,fieldset:true,font:true,footer:true,form:false,hr:true,head:true,header:true,output:true,iframe:false,frameset:false,img:true,input:true,li:true,label:true,legend:true,link:true,map:true,mark:true,menu:true,media:true,meta:true,nav:true,meter:true,ol:true,object:false,optgroup:true,option:true,p:true,param:true,picture:true,pre:true,progress:false,quote:true,script:false,select:true,source:true,span:true,style:true,caption:true,td:true,col:true,table:true,tr:true,template:false,textarea:true,time:true,title:true,track:true,details:true,ul:true,video:true,del:true,ins:true,slot:true,blockquote:true,svg:true,dialog:true,summary:true,main:true,address:true,colgroup:true,tbody:true,tfoot:true,thead:true,th:true,dd:true,dt:true,figcaption:true,figure:true,i:true,b:true,code:true,h1:true,h2:true,h3:true,h4:true,abbr:true,bdo:true,dfn:true,kbd:true,q:true,rb:true,rp:true,rt:true,ruby:true,s:true,strike:true,samp:true,small:true,strong:true,sup:true,sub:true,u:true,var:true,wbr:true,nobr:true,tt:true,noscript:true};
|
|
19
18
|
}
|
|
20
19
|
|
|
21
|
-
function getLogStyling() {
|
|
22
|
-
return [
|
|
23
|
-
"#logBox{min-width:0px;max-width:0px;min-height:0px;max-height:0px;width:0;height:0;z-index:-1;border:none;padding:0px;overflow:hidden;transition:all 0.3s ease;margin-top:-100px;}",
|
|
24
|
-
"#logBox.visible{background-color:rgb(255, 255, 224);z-index:1;position:static;border:1px dotted rgb(153, 153, 153);max-width:50vw;min-width:30vw;min-height:10vh;max-height:90vh;overflow:auto;width:50vw;height:20vh;margin:1rem 0px;padding:0px 8px 19px;resize:both;}",
|
|
25
|
-
"#logBox.visible .legend{position:absolute;}",
|
|
26
|
-
"#logBox .legend{text-align:center;margin-top:-1em;width:inherit;max-width:inherit;}",
|
|
27
|
-
"#logBox .legend div{text-align:center;display:inline-block;max-width:inherit;height:1.2rem;background-color:rgb(119, 119, 119);padding:2px 10px;color:rgb(255, 255, 255);box-shadow:rgb(119 119 119) 2px 1px 10px;border-radius:4px;}",
|
|
28
|
-
"#logBox .legend div:before{content:'JQx Logging (chronological)';}",
|
|
29
|
-
"#logBox .legend.reversed div:before{content:'JQx Logging (reversed)';}",
|
|
30
|
-
"#logBox #jqx_logger{marginTop:0.7rem;lineHeight:1.4em;font-family:consolas,monospace;whiteSpace:pre-wrap;maxWidth:inherit;padding-left:100px;}",
|
|
31
|
-
"#logBox #jqx_logger div.entry{text-indent:-100px;whiteSpace:normal;}",
|
|
32
|
-
]
|
|
33
|
-
}
|
|
34
|
-
|
|
35
20
|
function getPopupStyling() {
|
|
36
21
|
return [
|
|
37
22
|
"::backdrop{background-color:grey;opacity:0.2;}",
|
package/src/HandlerFactory.js
CHANGED
|
@@ -17,16 +17,16 @@ function HandleFactory(jqx) {
|
|
|
17
17
|
name = name || (!/handlers$/.test(callback.name) && callback.name) || undefined;
|
|
18
18
|
capture = jqx.IS(capture, Boolean) ? capture : false;
|
|
19
19
|
once = jqx.IS(once, Boolean) ? once : false;
|
|
20
|
-
canRemove = isNonEmptyString(name, 4) && jqx.IS(canRemove, Boolean) ? canRemove :
|
|
21
|
-
const { handler, signal, remove } = wrapHandlerFunction({selector, callback, canRemove, name, eventType});
|
|
20
|
+
canRemove = isNonEmptyString(name, 4) && jqx.IS(canRemove, Boolean) ? canRemove : once;
|
|
21
|
+
const { handler, signal, remove } = wrapHandlerFunction({selector, callback, canRemove, once, name, eventType});
|
|
22
22
|
return addAndStoreListener({eventType, handler, capture, once, signal, remove, name});
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
function wrapHandlerFunction(spec) {
|
|
27
|
-
const {selector, callback, canRemove, name, eventType} = spec;
|
|
28
|
-
const abortcontroller = canRemove && new AbortController();
|
|
29
|
-
const remove = removeHandlerFactory({abortcontroller, name, eventType});
|
|
27
|
+
const {selector, callback, canRemove, name, eventType, once} = spec;
|
|
28
|
+
const abortcontroller = (canRemove || once) && new AbortController();
|
|
29
|
+
const remove = removeHandlerFactory({once, abortcontroller, name, eventType});
|
|
30
30
|
const listener = !selector
|
|
31
31
|
? { handler: evt => callback(evt, evt.target, remove), remove}
|
|
32
32
|
: { handler: evt => {
|
|
@@ -34,17 +34,29 @@ function HandleFactory(jqx) {
|
|
|
34
34
|
return target && callback(evt, jqx(target), remove);
|
|
35
35
|
}, remove
|
|
36
36
|
};
|
|
37
|
-
|
|
37
|
+
|
|
38
|
+
if (abortcontroller) {
|
|
39
|
+
listener.signal = abortcontroller.signal;
|
|
40
|
+
if (once) {
|
|
41
|
+
return {
|
|
42
|
+
handler: (evt, me) => {
|
|
43
|
+
listener.handler(evt, me);
|
|
44
|
+
remove();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
38
50
|
return listener;
|
|
39
51
|
}
|
|
40
52
|
|
|
41
53
|
function removeHandlerFactory(spec) {
|
|
42
|
-
const {abortcontroller, name, eventType} = spec;
|
|
54
|
+
const {once, abortcontroller, name, eventType} = spec;
|
|
43
55
|
return !name
|
|
44
|
-
? function() {
|
|
56
|
+
? function() { jqx.logger.error(`An anonymous listener can not be removed`); }
|
|
45
57
|
: !abortcontroller
|
|
46
58
|
? function(evt) {
|
|
47
|
-
|
|
59
|
+
jqx.logger.error(`Listener for event type [${eventType}] with name [${
|
|
48
60
|
name}] is not marked as removable`);
|
|
49
61
|
}
|
|
50
62
|
: function removeHandler() {
|
|
@@ -52,14 +64,13 @@ function HandleFactory(jqx) {
|
|
|
52
64
|
const toRemove = [...handlerStore[eventType].entries()].find(([k, v]) => v.name === name);
|
|
53
65
|
handlerStore[eventType].delete(toRemove[0]);
|
|
54
66
|
setTimeout( () =>
|
|
55
|
-
|
|
56
|
-
name}] was removed`), 100 );
|
|
67
|
+
jqx.logger.log(`Listener for event type [${eventType}] with name [${
|
|
68
|
+
name}] was removed${once ? ` (once active, so handled once).` : ``}`), 100 );
|
|
57
69
|
}
|
|
58
70
|
}
|
|
59
71
|
|
|
60
72
|
function addAndStoreListener(spec) {
|
|
61
73
|
const {eventType, handler, capture, once, signal, remove, name} = spec;
|
|
62
|
-
if (once) { return addEventListener(eventType, handler, {once}); }
|
|
63
74
|
if (!handlerStore[eventType]) { handlerStore[eventType] = new Map(); }
|
|
64
75
|
const delegateExists = handlerStore[eventType].has(handler) ||
|
|
65
76
|
[...handlerStore[eventType].values()].find(h => (h.name || ``) === name);
|
|
@@ -1,68 +1,33 @@
|
|
|
1
1
|
import { createElementFromHtmlString, insertPositions, inject2DOMTree, cleanupHtml } from "./DOM.js";
|
|
2
|
-
import logFactory from "./JQxLog.js";
|
|
3
2
|
import allMethodsFactory from "./JQxMethods.js";
|
|
4
3
|
import PopupFactory from "./Popup.js";
|
|
5
4
|
import { listeners, default as HandleFactory } from "./HandlerFactory.js";
|
|
6
5
|
import tagLib from "./HTMLTags.js";
|
|
7
6
|
import {
|
|
8
7
|
randomString, toDashedNotation, IS, truncateHtmlStr, tagFNFactory as $T,
|
|
9
|
-
truncate2SingleStr,
|
|
10
|
-
isNonEmptyString, resolveEventTypeParameter,
|
|
8
|
+
truncate2SingleStr, styleFactory, toCamelcase, systemLog, escHtml,
|
|
9
|
+
isNonEmptyString, resolveEventTypeParameter, extensionHelpers,
|
|
11
10
|
} from "./Utilities.js";
|
|
12
|
-
let static4Docs = {};
|
|
13
|
-
let instanceGetters, instanceMethods, $, systemLogger, debugLogger;
|
|
14
11
|
|
|
12
|
+
let instanceGetters, instanceMethods;
|
|
15
13
|
const {
|
|
16
|
-
isCommentOrTextNode, isNode,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
isCommentOrTextNode, isNode, isComment, isText, isHtmlString, isArrayOfHtmlElements,
|
|
15
|
+
isArrayOfHtmlStrings, ElemArray2HtmlString, input2Collection, setCollectionFromCssSelector,
|
|
16
|
+
addHandlerId, cssRuleEdit, addFn
|
|
17
|
+
} = localHelpersFactory();
|
|
18
|
+
|
|
19
|
+
// todo: clean this up
|
|
20
|
+
export {
|
|
21
|
+
addHandlerId, isHtmlString, isNode, isArrayOfHtmlStrings, isArrayOfHtmlElements, isCommentOrTextNode,
|
|
22
|
+
inject2DOMTree, ElemArray2HtmlString, input2Collection, setCollectionFromCssSelector,
|
|
23
|
+
truncateHtmlStr, truncate2SingleStr, proxify, addJQxStaticMethods, createElementFromHtmlString,
|
|
24
|
+
insertPositions, IS, };
|
|
20
25
|
|
|
21
26
|
/* region functions */
|
|
22
|
-
function
|
|
23
|
-
const cssRuleEdit = styleFactory(
|
|
27
|
+
function localHelpersFactory() {
|
|
28
|
+
const cssRuleEdit = styleFactory({createWithId: `JQxStylesheet`});
|
|
24
29
|
const addFn = (name, fn) => instanceMethods[name] = (self, ...params) => fn(self, ...params);
|
|
25
|
-
|
|
26
|
-
const isNode = input => IS(input, Text, HTMLElement, Comment);
|
|
27
|
-
const isComment = input => IS(input, Comment);
|
|
28
|
-
const isText = input => IS(input, Text);
|
|
29
|
-
const isHtmlString = input => IS(input, String) && /^<|>$/.test(`${input}`.trim());
|
|
30
|
-
const isArrayOfHtmlStrings = input => IS(input, Array) && !input?.find(s => !isHtmlString(s));
|
|
31
|
-
const isArrayOfHtmlElements = input => IS(input, Array) && !input?.find(el => !isNode(el));
|
|
32
|
-
const ElemArray2HtmlString = elems => elems?.filter(el => el).reduce((acc, el) =>
|
|
33
|
-
acc.concat(isComment(el) ? `<!--${el.data}-->`
|
|
34
|
-
: isCommentOrTextNode(el) ? el.textContent
|
|
35
|
-
: el.outerHTML), ``);
|
|
36
|
-
const input2Collection = input =>
|
|
37
|
-
!input ? []
|
|
38
|
-
: IS(input, Proxy) ? [input.EL]
|
|
39
|
-
: IS(input, NodeList) ? [...input]
|
|
40
|
-
: isNode(input) ? [input]
|
|
41
|
-
: isArrayOfHtmlElements(input) ? input
|
|
42
|
-
: input.isJQx ? input.collection : undefined;
|
|
43
|
-
const setCollectionFromCssSelector = (input, root, self) => {
|
|
44
|
-
const selectorRoot = root !== document.body && (IS(input, String) && input.toLowerCase() !== "body") ? root : document;
|
|
45
|
-
let errorStr = undefined;
|
|
46
|
-
|
|
47
|
-
try { self.collection = [...selectorRoot.querySelectorAll(input)]; }
|
|
48
|
-
catch (err) { errorStr = `Invalid CSS querySelector. [${!IS(input, String) ? `Nothing valid given!` : input}]`; }
|
|
49
|
-
|
|
50
|
-
return errorStr ?? `CSS querySelector "${input}", output ${self.collection.length} element(s)`;
|
|
51
|
-
};
|
|
52
|
-
const addHandlerId = instance => {
|
|
53
|
-
const handleId = instance.data.get(`hid`) || `HID${randomString()}`;
|
|
54
|
-
instance.data.add({hid: handleId});
|
|
55
|
-
return `[data-hid="${handleId}"]`;
|
|
56
|
-
};
|
|
57
|
-
const elems4Docs = Object.entries(tagLib.tagsRaw)
|
|
58
|
-
.filter( ([,cando]) => cando)
|
|
59
|
-
.map( ([key,]) => key)
|
|
60
|
-
.sort( (a, b) => a.localeCompare(b));
|
|
61
|
-
|
|
62
|
-
return {
|
|
63
|
-
isCommentOrTextNode, isNode, isComment, isText, isHtmlString, isArrayOfHtmlElements,
|
|
64
|
-
isArrayOfHtmlStrings, ElemArray2HtmlString, input2Collection, setCollectionFromCssSelector,
|
|
65
|
-
addHandlerId, cssRuleEdit, addFn, elems4Docs };
|
|
30
|
+
return {...extensionHelpers(), ...{cssRuleEdit, addFn, }};
|
|
66
31
|
}
|
|
67
32
|
|
|
68
33
|
function proxify(instance) {
|
|
@@ -81,17 +46,19 @@ function proxyKeyFactory(self, key, instance) {
|
|
|
81
46
|
switch(true) {
|
|
82
47
|
case IS(key, Symbol): return self;
|
|
83
48
|
case IS(+key, Number): return self.collection?.[key] || undefined;
|
|
84
|
-
case
|
|
85
|
-
case
|
|
49
|
+
case (key in instanceGetters): return wrapGetter(instanceGetters[key], instance)();
|
|
50
|
+
case (key in instanceMethods): return wrapExtension(instanceMethods[key], instance);
|
|
86
51
|
default: return self[key];
|
|
87
52
|
}
|
|
88
53
|
}
|
|
89
54
|
|
|
90
55
|
function addJQxStaticMethods(jqx) {
|
|
91
56
|
const staticMethods = defaultStaticMethodsFactory(jqx);
|
|
57
|
+
|
|
92
58
|
for (const [key, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(staticMethods))) {
|
|
93
59
|
Object.defineProperty(jqx, key, descriptor);
|
|
94
|
-
|
|
60
|
+
}
|
|
61
|
+
|
|
95
62
|
return jqx;
|
|
96
63
|
}
|
|
97
64
|
|
|
@@ -197,14 +164,14 @@ function staticTagsLambda(jqx) {
|
|
|
197
164
|
}
|
|
198
165
|
|
|
199
166
|
function delegateFactory(listen) {
|
|
200
|
-
return function(type,
|
|
167
|
+
return function(type, selector, ...listeners) {
|
|
201
168
|
|
|
202
|
-
if (IS(
|
|
203
|
-
|
|
204
|
-
|
|
169
|
+
if (IS(selector, Function)) {
|
|
170
|
+
listeners.push(selector);
|
|
171
|
+
selector = undefined;
|
|
205
172
|
}
|
|
206
173
|
|
|
207
|
-
listen({type, selector:
|
|
174
|
+
listen({type, selector: selector, handlers: listeners});
|
|
208
175
|
}
|
|
209
176
|
}
|
|
210
177
|
|
|
@@ -254,30 +221,37 @@ function popupGetter(jqx) {
|
|
|
254
221
|
return jqx.activePopup;
|
|
255
222
|
}
|
|
256
223
|
|
|
257
|
-
function
|
|
258
|
-
const { debugLog, Log, systemLog } = logFactory(jqx);
|
|
259
|
-
const { factoryExtensions, instanceExtensions } = allMethodsFactory(jqx);
|
|
260
|
-
systemLogger = systemLog;
|
|
261
|
-
debugLogger = debugLog;
|
|
262
|
-
instanceGetters = factoryExtensions;
|
|
263
|
-
instanceMethods = instanceExtensions;
|
|
264
|
-
$ = jqx;
|
|
224
|
+
function getSelectedStaticMethods(jqx) {
|
|
265
225
|
const editCssRule = (ruleOrSelector, ruleObject) => cssRuleEdit(ruleOrSelector, ruleObject);
|
|
226
|
+
const createStyle = id => styleFactory({createWithId: id || `jqx${randomString()}`});
|
|
227
|
+
const editCssRules = (...rules) => { for (const rule of rules) { cssRuleEdit(rule); } };
|
|
266
228
|
const allowProhibit = allowances(jqx);
|
|
267
229
|
const handle = HandleFactory(jqx);
|
|
268
230
|
const capturedHandling = delegateCaptureFactory(handle);
|
|
231
|
+
const log = (...line) => systemLog.on.log(...line).off;
|
|
232
|
+
return {editCssRule, createStyle, editCssRules, allowProhibit, handle, capturedHandling,log};
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function staticMethodsFactory(jqx) {
|
|
236
|
+
const { factoryExtensions, instanceExtensions } = allMethodsFactory(jqx);
|
|
237
|
+
instanceGetters = factoryExtensions;
|
|
238
|
+
instanceMethods = instanceExtensions;
|
|
239
|
+
const { editCssRule, createStyle, editCssRules, allowProhibit, handle, capturedHandling, log } =
|
|
240
|
+
getSelectedStaticMethods(jqx);
|
|
269
241
|
|
|
270
242
|
return {
|
|
271
|
-
log
|
|
272
|
-
editCssRules
|
|
273
|
-
createStyle
|
|
274
|
-
editStylesheet
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
243
|
+
log,
|
|
244
|
+
editCssRules,
|
|
245
|
+
createStyle,
|
|
246
|
+
editStylesheet: createStyle,
|
|
247
|
+
editCssRule,
|
|
248
|
+
escHtml,
|
|
249
|
+
logger: systemLog,
|
|
250
|
+
text: (str, isComment = false) => isComment ? jqx.comment(str) : document.createTextNode(str),
|
|
251
|
+
node: (selector, root = document) => root.querySelector(selector, root),
|
|
252
|
+
nodes: (selector, root = document) => [...root.querySelectorAll(selector, root)],
|
|
253
|
+
//get logger() { return loggerFactory() },
|
|
279
254
|
get getNamedListener() { return getNamedListener; },
|
|
280
|
-
get debugLog() { return debugLog },
|
|
281
255
|
get virtual() { return virtualFactory(jqx); },
|
|
282
256
|
get allowTag() { return allowProhibit.allow; },
|
|
283
257
|
get prohibitTag() { return allowProhibit.prohibit; },
|
|
@@ -295,31 +269,3 @@ function staticMethodsFactory(jqx) {
|
|
|
295
269
|
};
|
|
296
270
|
}
|
|
297
271
|
/* endregion functions */
|
|
298
|
-
export {
|
|
299
|
-
hex2RGBA,
|
|
300
|
-
addHandlerId,
|
|
301
|
-
isHtmlString,
|
|
302
|
-
isNode,
|
|
303
|
-
logTime,
|
|
304
|
-
toDashedNotation,
|
|
305
|
-
randomString,
|
|
306
|
-
isArrayOfHtmlStrings,
|
|
307
|
-
isArrayOfHtmlElements,
|
|
308
|
-
isCommentOrTextNode,
|
|
309
|
-
inject2DOMTree,
|
|
310
|
-
ElemArray2HtmlString,
|
|
311
|
-
input2Collection,
|
|
312
|
-
setCollectionFromCssSelector,
|
|
313
|
-
truncateHtmlStr,
|
|
314
|
-
truncate2SingleStr,
|
|
315
|
-
proxify,
|
|
316
|
-
addJQxStaticMethods,
|
|
317
|
-
createElementFromHtmlString,
|
|
318
|
-
insertPositions,
|
|
319
|
-
systemLogger as systemLog,
|
|
320
|
-
debugLogger as debugLog,
|
|
321
|
-
IS,
|
|
322
|
-
static4Docs,
|
|
323
|
-
elems4Docs,
|
|
324
|
-
$ as jqx,
|
|
325
|
-
};
|
package/src/JQxMethods.js
CHANGED
|
@@ -3,12 +3,9 @@ import {
|
|
|
3
3
|
IS,
|
|
4
4
|
addHandlerId,
|
|
5
5
|
isNode,
|
|
6
|
-
randomString,
|
|
7
6
|
inject2DOMTree,
|
|
8
7
|
isCommentOrTextNode,
|
|
9
8
|
truncateHtmlStr,
|
|
10
|
-
systemLog,
|
|
11
|
-
debugLog,
|
|
12
9
|
} from "./JQxExtensionHelpers.js";
|
|
13
10
|
import {ATTRS} from "./EmbedResources.js";
|
|
14
11
|
import {
|
|
@@ -16,7 +13,10 @@ import {
|
|
|
16
13
|
isNonEmptyString,
|
|
17
14
|
toDashedNotation,
|
|
18
15
|
toCamelcase,
|
|
19
|
-
|
|
16
|
+
randomString,
|
|
17
|
+
escHtml,
|
|
18
|
+
systemLog,
|
|
19
|
+
} from "./Utilities.js";
|
|
20
20
|
const loop = (instance, callback) => {
|
|
21
21
|
const cleanCollection = instance.collection.filter(el => !isCommentOrTextNode(el));
|
|
22
22
|
for (let i = 0; i < cleanCollection.length; i += 1) {
|
|
@@ -486,7 +486,7 @@ function instanceExtensionsFactory(jqx) {
|
|
|
486
486
|
return instance;
|
|
487
487
|
},
|
|
488
488
|
remove: (instance, selector) => {
|
|
489
|
-
systemLog(`remove ${truncateHtmlStr(instance.HTML.get(1), 40)}${selector ? ` /w selector ${selector}` : ``}`);
|
|
489
|
+
systemLog.log(`remove ${truncateHtmlStr(instance.HTML.get(1), 40)}${selector ? ` /w selector ${selector}` : ``}`);
|
|
490
490
|
const remover = el => el.remove();
|
|
491
491
|
const removeFromCollection = () =>
|
|
492
492
|
instance.collection = instance.collection.filter(el => document.documentElement.contains(el));
|