jsquery_node 1.0.14 → 1.0.15
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/jsquery.d.ts +14 -12813
- package/jsquery.js +47 -333
- package/jsquery.ts +2 -287
- package/jsquerymod.d.ts +78 -0
- package/jsquerymod.js +282 -0
- package/jsquerymod.ts +284 -0
- package/package.json +1 -1
- package/tsconfig.json +2 -1
package/jsquery.js
CHANGED
|
@@ -1,335 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
return
|
|
1
|
+
export * as JSQuery from "./jsquerymod.js";
|
|
2
|
+
import * as JSQuery from "./jsquerymod.js";
|
|
3
|
+
function J(q) {
|
|
4
|
+
return JSQuery.Element.from(document.querySelector(q));
|
|
5
|
+
}
|
|
6
|
+
;
|
|
7
|
+
J.from = ((elt) => {
|
|
8
|
+
return JSQuery.Element.from(elt);
|
|
9
|
+
});
|
|
10
|
+
J.all = (q) => {
|
|
11
|
+
return JSQuery.Element.from(document.querySelectorAll(q));
|
|
5
12
|
};
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
this.forEach((v) => v.trigger(e));
|
|
31
|
-
return this;
|
|
32
|
-
}
|
|
33
|
-
css(styles) {
|
|
34
|
-
this.forEach((v) => v.css(styles));
|
|
35
|
-
return this;
|
|
36
|
-
}
|
|
37
|
-
props(props) {
|
|
38
|
-
this.forEach((v) => v.props(props));
|
|
39
|
-
return this;
|
|
40
|
-
}
|
|
41
|
-
class(names) {
|
|
42
|
-
this.forEach((v) => v.class(names));
|
|
43
|
-
return this;
|
|
44
|
-
}
|
|
45
|
-
removeClass(names) {
|
|
46
|
-
this.forEach((v) => v.removeClass(names));
|
|
47
|
-
return this;
|
|
48
|
-
}
|
|
49
|
-
toggleClass(names) {
|
|
50
|
-
this.forEach((v) => v.toggleClass(names));
|
|
51
|
-
return this;
|
|
52
|
-
}
|
|
53
|
-
remove() {
|
|
54
|
-
this.forEach((v) => v.remove());
|
|
55
|
-
return this;
|
|
56
|
-
}
|
|
57
|
-
new() {
|
|
58
|
-
const temp = new ElementArray();
|
|
59
|
-
this.forEach((v) => temp.push(v.new()));
|
|
60
|
-
return temp;
|
|
61
|
-
}
|
|
62
|
-
//events
|
|
63
|
-
click(func, s) {
|
|
64
|
-
this.forEach((v) => v.click(func, s));
|
|
65
|
-
return this;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
function toArray(elt) {
|
|
69
|
-
return elt instanceof NodeList || elt instanceof HTMLCollection;
|
|
70
|
-
}
|
|
71
|
-
class Element {
|
|
72
|
-
static from(elt) {
|
|
73
|
-
if (elt == null) {
|
|
74
|
-
return null;
|
|
75
|
-
}
|
|
76
|
-
if (toArray(elt)) {
|
|
77
|
-
return ElementArray.from(elt).map((v) => new this(v));
|
|
78
|
-
}
|
|
79
|
-
return new this(elt);
|
|
80
|
-
}
|
|
81
|
-
new() {
|
|
82
|
-
return Element.from(this.elt);
|
|
83
|
-
}
|
|
84
|
-
constructor(elt) {
|
|
85
|
-
_Element_instances.add(this);
|
|
86
|
-
this.elt = elt;
|
|
87
|
-
}
|
|
88
|
-
on(e, func, s) {
|
|
89
|
-
this.elt.addEventListener(e, func, s);
|
|
90
|
-
return this;
|
|
91
|
-
}
|
|
92
|
-
removeEvent(e, func, s) {
|
|
93
|
-
this.elt.removeEventListener(e, func, s);
|
|
94
|
-
return this;
|
|
95
|
-
}
|
|
96
|
-
trigger(e) {
|
|
97
|
-
this.elt[e]();
|
|
98
|
-
return this;
|
|
99
|
-
}
|
|
100
|
-
css(styles) {
|
|
101
|
-
for (const [name, val] of Object.entries(styles)) {
|
|
102
|
-
this.elt.style[name] = val;
|
|
103
|
-
}
|
|
104
|
-
return this;
|
|
105
|
-
}
|
|
106
|
-
getCss(style) {
|
|
107
|
-
return this.elt.style[style];
|
|
108
|
-
}
|
|
109
|
-
props(props) {
|
|
110
|
-
for (const [name, val] of Object.entries(props)) {
|
|
111
|
-
if (val === null) {
|
|
112
|
-
this.elt.removeAttribute(name);
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
this.elt.setAttribute(name, val);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
return this;
|
|
119
|
-
}
|
|
120
|
-
getProp(name) {
|
|
121
|
-
return this.elt.getAttribute(name);
|
|
122
|
-
}
|
|
123
|
-
id(val) {
|
|
124
|
-
if (val == undefined)
|
|
125
|
-
return this.getProp("id");
|
|
126
|
-
this.props({ id: val });
|
|
127
|
-
return this;
|
|
128
|
-
}
|
|
129
|
-
class(names) {
|
|
130
|
-
if (Array.isArray(names)) {
|
|
131
|
-
names.forEach((name) => this.elt.classList.add(name));
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
this.elt.classList.add(names);
|
|
135
|
-
}
|
|
136
|
-
return this;
|
|
137
|
-
}
|
|
138
|
-
removeClass(names) {
|
|
139
|
-
if (Array.isArray(names)) {
|
|
140
|
-
names.forEach((name) => this.elt.classList.remove(name));
|
|
141
|
-
}
|
|
142
|
-
else {
|
|
143
|
-
this.elt.classList.remove(names);
|
|
144
|
-
}
|
|
145
|
-
return this;
|
|
146
|
-
}
|
|
147
|
-
toggleClass(names) {
|
|
148
|
-
if (Array.isArray(names)) {
|
|
149
|
-
names.forEach((name) => this.elt.classList.toggle(name));
|
|
150
|
-
}
|
|
151
|
-
else {
|
|
152
|
-
this.elt.classList.toggle(names);
|
|
153
|
-
}
|
|
154
|
-
return this;
|
|
155
|
-
}
|
|
156
|
-
hasClass(name) {
|
|
157
|
-
return this.elt.classList.contains(name);
|
|
158
|
-
}
|
|
159
|
-
$(q) {
|
|
160
|
-
return J.from(this.elt.querySelector(q));
|
|
161
|
-
}
|
|
162
|
-
all(q) {
|
|
163
|
-
return J.from(this.elt.querySelectorAll(q));
|
|
164
|
-
}
|
|
165
|
-
is(q) {
|
|
166
|
-
return this.elt.matches(q);
|
|
167
|
-
}
|
|
168
|
-
child(children) {
|
|
169
|
-
if (Array.isArray(children)) {
|
|
170
|
-
children.forEach((child) => this.elt.appendChild(toElt(child)));
|
|
171
|
-
}
|
|
172
|
-
else {
|
|
173
|
-
this.elt.appendChild(toElt(children));
|
|
174
|
-
}
|
|
175
|
-
return this;
|
|
176
|
-
}
|
|
177
|
-
remove() {
|
|
178
|
-
this.elt.remove();
|
|
179
|
-
return this;
|
|
180
|
-
}
|
|
181
|
-
get children() {
|
|
182
|
-
return Element.from(this.elt.children);
|
|
183
|
-
}
|
|
184
|
-
html(val) {
|
|
185
|
-
if (val == undefined)
|
|
186
|
-
return this.elt.innerHTML;
|
|
187
|
-
this.elt.innerHTML = val;
|
|
188
|
-
return this;
|
|
189
|
-
}
|
|
190
|
-
text(val) {
|
|
191
|
-
if (val == undefined)
|
|
192
|
-
return this.elt.textContent;
|
|
193
|
-
this.elt.textContent = val;
|
|
194
|
-
return this;
|
|
195
|
-
}
|
|
196
|
-
rect() {
|
|
197
|
-
return this.elt.getBoundingClientRect().toJSON();
|
|
198
|
-
}
|
|
199
|
-
value(val) {
|
|
200
|
-
if (val == undefined)
|
|
201
|
-
return this.elt.value;
|
|
202
|
-
this.elt.value = val;
|
|
203
|
-
return this;
|
|
204
|
-
}
|
|
205
|
-
checked(val) {
|
|
206
|
-
if (val == undefined)
|
|
207
|
-
return this.elt.checked;
|
|
208
|
-
this.elt.checked = val;
|
|
209
|
-
return this;
|
|
210
|
-
}
|
|
211
|
-
//events
|
|
212
|
-
click(func, s) {
|
|
213
|
-
__classPrivateFieldGet(this, _Element_instances, "m", _Element_TriggerEvent).call(this, "click", func, s);
|
|
214
|
-
return this;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
_Element_instances = new WeakSet(), _Element_TriggerEvent = function _Element_TriggerEvent(e, func, s) {
|
|
218
|
-
if (!func) {
|
|
219
|
-
this.trigger(e);
|
|
220
|
-
return;
|
|
221
|
-
}
|
|
222
|
-
this.on(e, func, s);
|
|
223
|
-
};
|
|
224
|
-
function toElt(elt) {
|
|
225
|
-
if (elt instanceof Element)
|
|
226
|
-
return elt.elt;
|
|
227
|
-
return elt;
|
|
228
|
-
}
|
|
229
|
-
class Extension {
|
|
230
|
-
constructor() {
|
|
231
|
-
if (this.constructor === Extension) {
|
|
232
|
-
throw new Error("you can't make an instance of class: JSQuery.Extension");
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
get() {
|
|
236
|
-
return {
|
|
237
|
-
$: this.$(),
|
|
238
|
-
Element: this.Element(),
|
|
239
|
-
static_Element: this.static_Element(),
|
|
240
|
-
static_ElementArray: this.static_ElementArray(),
|
|
241
|
-
ElementArray: this.ElementArray(),
|
|
242
|
-
JSQuery: this.JSQuery(),
|
|
243
|
-
};
|
|
244
|
-
}
|
|
245
|
-
$() {
|
|
246
|
-
return {};
|
|
247
|
-
}
|
|
248
|
-
Element() {
|
|
249
|
-
return {};
|
|
250
|
-
}
|
|
251
|
-
ElementArray() {
|
|
252
|
-
return {};
|
|
253
|
-
}
|
|
254
|
-
static_Element() {
|
|
255
|
-
return {};
|
|
256
|
-
}
|
|
257
|
-
static_ElementArray() {
|
|
258
|
-
return {};
|
|
259
|
-
}
|
|
260
|
-
JSQuery() {
|
|
261
|
-
return {};
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
function J(q) {
|
|
265
|
-
return Element.from(document.querySelector(q));
|
|
13
|
+
let head;
|
|
14
|
+
J.head = () => {
|
|
15
|
+
if (!head)
|
|
16
|
+
head = JSQuery.Element.from(document.head);
|
|
17
|
+
return head;
|
|
18
|
+
};
|
|
19
|
+
let body;
|
|
20
|
+
J.body = () => {
|
|
21
|
+
if (!body)
|
|
22
|
+
body = JSQuery.Element.from(document.body);
|
|
23
|
+
return body;
|
|
24
|
+
};
|
|
25
|
+
let doc;
|
|
26
|
+
J.doc = () => {
|
|
27
|
+
if (!doc)
|
|
28
|
+
doc = JSQuery.Element.from(document);
|
|
29
|
+
return doc;
|
|
30
|
+
};
|
|
31
|
+
J.create = (t) => {
|
|
32
|
+
return JSQuery.Element.from(document.createElement(t));
|
|
33
|
+
};
|
|
34
|
+
J.loadExtension = (extend) => {
|
|
35
|
+
if (Object.getPrototypeOf(extend) !== JSQuery.Extension) {
|
|
36
|
+
throw new Error("the class is not a child of JSQuery.Extension or the inputed class is an instance");
|
|
266
37
|
}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
J
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
let body;
|
|
280
|
-
J.body = () => {
|
|
281
|
-
if (!body)
|
|
282
|
-
body = Element.from(document.body);
|
|
283
|
-
return body;
|
|
284
|
-
};
|
|
285
|
-
let doc;
|
|
286
|
-
J.doc = () => {
|
|
287
|
-
if (!doc)
|
|
288
|
-
doc = Element.from(document);
|
|
289
|
-
return doc;
|
|
290
|
-
};
|
|
291
|
-
J.create = (t) => {
|
|
292
|
-
return Element.from(document.createElement(t));
|
|
293
|
-
};
|
|
294
|
-
const JSQuery = {
|
|
295
|
-
Element,
|
|
296
|
-
ElementArray,
|
|
297
|
-
Extension,
|
|
298
|
-
Plugin: Extension,
|
|
299
|
-
Caching: class Caching extends Extension {
|
|
300
|
-
$() {
|
|
301
|
-
return {
|
|
302
|
-
cache(func) {
|
|
303
|
-
const f = (...args) => {
|
|
304
|
-
const val = JSON.stringify(args);
|
|
305
|
-
if (f.cache.hasOwnProperty(val)) {
|
|
306
|
-
return f.cache[val];
|
|
307
|
-
}
|
|
308
|
-
const temp = func(...args);
|
|
309
|
-
f.cache[val] = temp;
|
|
310
|
-
return temp;
|
|
311
|
-
};
|
|
312
|
-
f.cache = {};
|
|
313
|
-
return f;
|
|
314
|
-
},
|
|
315
|
-
};
|
|
316
|
-
}
|
|
317
|
-
},
|
|
318
|
-
};
|
|
319
|
-
J.loadExtension = (extend) => {
|
|
320
|
-
if (Object.getPrototypeOf(extend) !== Extension) {
|
|
321
|
-
throw new Error("the class is not a child of JSQuery.Extension or the inputed class is an instance");
|
|
322
|
-
}
|
|
323
|
-
body = undefined;
|
|
324
|
-
head = undefined;
|
|
325
|
-
const items = new extend().get();
|
|
326
|
-
Object.assign(J, items.$);
|
|
327
|
-
Object.assign(JSQuery, items.JSQuery);
|
|
328
|
-
Object.assign(Element.prototype, items.Element);
|
|
329
|
-
Object.assign(ElementArray.prototype, items.ElementArray);
|
|
330
|
-
Object.assign(Element, items.static_Element);
|
|
331
|
-
Object.assign(ElementArray, items.static_ElementArray);
|
|
332
|
-
};
|
|
333
|
-
J.loadPlugin = J.loadExtension;
|
|
334
|
-
return { $: J, JSQuery };
|
|
335
|
-
})();
|
|
38
|
+
body = undefined;
|
|
39
|
+
head = undefined;
|
|
40
|
+
const items = new extend().get();
|
|
41
|
+
Object.assign(J, items.$);
|
|
42
|
+
Object.assign(JSQuery, items.JSQuery);
|
|
43
|
+
Object.assign(JSQuery.Element.prototype, items.Element);
|
|
44
|
+
Object.assign(JSQuery.ElementArray.prototype, items.ElementArray);
|
|
45
|
+
Object.assign(JSQuery.Element, items.static_Element);
|
|
46
|
+
Object.assign(JSQuery.ElementArray, items.static_ElementArray);
|
|
47
|
+
};
|
|
48
|
+
J.loadPlugin = J.loadExtension;
|
|
49
|
+
export const $ = J;
|
package/jsquery.ts
CHANGED
|
@@ -1,290 +1,5 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
return elt instanceof NodeList || elt instanceof HTMLCollection;
|
|
4
|
-
}
|
|
5
|
-
function toElt(elt: Element): HTMLElement {
|
|
6
|
-
if (elt instanceof Element) return elt.elt;
|
|
7
|
-
return elt;
|
|
8
|
-
}
|
|
9
|
-
export class Extension {
|
|
10
|
-
constructor() {
|
|
11
|
-
if (this.constructor === Extension) {
|
|
12
|
-
throw new Error(
|
|
13
|
-
"you can't make an instance of class: JSQuery.Extension"
|
|
14
|
-
);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
get() {
|
|
18
|
-
return {
|
|
19
|
-
$: this.$(),
|
|
20
|
-
Element: this.Element(),
|
|
21
|
-
static_Element: this.static_Element(),
|
|
22
|
-
static_ElementArray: this.static_ElementArray(),
|
|
23
|
-
ElementArray: this.ElementArray(),
|
|
24
|
-
JSQuery: this.JSQuery(),
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
$() {
|
|
28
|
-
return {};
|
|
29
|
-
}
|
|
30
|
-
Element() {
|
|
31
|
-
return {};
|
|
32
|
-
}
|
|
33
|
-
ElementArray() {
|
|
34
|
-
return {};
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
static_Element() {
|
|
38
|
-
return {};
|
|
39
|
-
}
|
|
40
|
-
static_ElementArray() {
|
|
41
|
-
return {};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
JSQuery() {
|
|
45
|
-
return {};
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
export class Element {
|
|
49
|
-
elt: HTMLElement;
|
|
50
|
-
#TriggerEvent(e: any, func: (this:HTMLElement, ev: any) => any, s?: boolean | AddEventListenerOptions) {
|
|
51
|
-
if (!func) {
|
|
52
|
-
this.trigger(e);
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
this.on(e, func, s);
|
|
56
|
-
}
|
|
57
|
-
static from(elt: HTMLElement): Element|null;
|
|
58
|
-
static from(elt: NodeList|HTMLCollection): ElementArray;
|
|
59
|
-
static from(elt: HTMLElement | NodeList | HTMLCollection): Element | ElementArray | null {
|
|
60
|
-
if (elt == null) {
|
|
61
|
-
return null;
|
|
62
|
-
}
|
|
63
|
-
if (toArray(elt)) {
|
|
64
|
-
return ElementArray.from(elt).map((v) => new this(v as HTMLElement)) as ElementArray;
|
|
65
|
-
}
|
|
66
|
-
return new this(elt);
|
|
67
|
-
}
|
|
68
|
-
new() {
|
|
69
|
-
return Element.from(this.elt);
|
|
70
|
-
}
|
|
71
|
-
constructor(elt:HTMLElement) {
|
|
72
|
-
this.elt = elt;
|
|
73
|
-
}
|
|
74
|
-
on(e: any, func: (this:HTMLElement, ev: any) => any, s?: boolean | AddEventListenerOptions) {
|
|
75
|
-
this.elt.addEventListener(e, func, s);
|
|
76
|
-
return this;
|
|
77
|
-
}
|
|
78
|
-
removeEvent(e: any, func: (this:HTMLElement, ev: any) => any, s?: boolean | AddEventListenerOptions) {
|
|
79
|
-
this.elt.removeEventListener(e, func, s);
|
|
80
|
-
return this;
|
|
81
|
-
}
|
|
82
|
-
trigger(e: any) {
|
|
83
|
-
this.elt[e]();
|
|
84
|
-
return this;
|
|
85
|
-
}
|
|
86
|
-
css(styles: Record<string, any>) {
|
|
87
|
-
for (const [name, val] of Object.entries(styles)) {
|
|
88
|
-
this.elt.style[name] = val;
|
|
89
|
-
}
|
|
90
|
-
return this;
|
|
91
|
-
}
|
|
92
|
-
getCss(style: string) {
|
|
93
|
-
return this.elt.style[style];
|
|
94
|
-
}
|
|
95
|
-
props(props: Record<string, any>) {
|
|
96
|
-
for (const [name, val] of Object.entries(props)) {
|
|
97
|
-
if(val === null) {
|
|
98
|
-
this.elt.removeAttribute(name);
|
|
99
|
-
} else {
|
|
100
|
-
this.elt.setAttribute(name, val);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
return this;
|
|
104
|
-
}
|
|
105
|
-
getProp(name: string) {
|
|
106
|
-
return this.elt.getAttribute(name);
|
|
107
|
-
}
|
|
108
|
-
id(): string;
|
|
109
|
-
id(val: string): this;
|
|
110
|
-
id(val?: string): string | this {
|
|
111
|
-
if (val == undefined) return this.getProp("id");
|
|
112
|
-
this.props({ id: val });
|
|
113
|
-
return this;
|
|
114
|
-
}
|
|
115
|
-
class(names: string | string[]) {
|
|
116
|
-
if (Array.isArray(names)) {
|
|
117
|
-
names.forEach((name) => this.elt.classList.add(name));
|
|
118
|
-
} else {
|
|
119
|
-
this.elt.classList.add(names);
|
|
120
|
-
}
|
|
121
|
-
return this;
|
|
122
|
-
}
|
|
123
|
-
removeClass(names: string | string[]) {
|
|
124
|
-
if (Array.isArray(names)) {
|
|
125
|
-
names.forEach((name) => this.elt.classList.remove(name));
|
|
126
|
-
} else {
|
|
127
|
-
this.elt.classList.remove(names);
|
|
128
|
-
}
|
|
129
|
-
return this;
|
|
130
|
-
}
|
|
131
|
-
toggleClass(names: string | string[]) {
|
|
132
|
-
if (Array.isArray(names)) {
|
|
133
|
-
names.forEach((name) => this.elt.classList.toggle(name));
|
|
134
|
-
} else {
|
|
135
|
-
this.elt.classList.toggle(names);
|
|
136
|
-
}
|
|
137
|
-
return this;
|
|
138
|
-
}
|
|
139
|
-
hasClass(name: string) {
|
|
140
|
-
return this.elt.classList.contains(name);
|
|
141
|
-
}
|
|
142
|
-
$(q: any): Element|null {
|
|
143
|
-
return J.from(this.elt.querySelector(q)) as any;
|
|
144
|
-
}
|
|
145
|
-
all(q: any): ElementArray {
|
|
146
|
-
return J.from(this.elt.querySelectorAll(q)) as any;
|
|
147
|
-
}
|
|
148
|
-
is(q:string) {
|
|
149
|
-
return this.elt.matches(q);
|
|
150
|
-
}
|
|
151
|
-
child(children: Element|Element[]) {
|
|
152
|
-
if (Array.isArray(children)) {
|
|
153
|
-
children.forEach((child:Element) => this.elt.appendChild(toElt(child)));
|
|
154
|
-
} else {
|
|
155
|
-
this.elt.appendChild(toElt(children));
|
|
156
|
-
}
|
|
157
|
-
return this;
|
|
158
|
-
}
|
|
159
|
-
remove() {
|
|
160
|
-
this.elt.remove();
|
|
161
|
-
return this;
|
|
162
|
-
}
|
|
163
|
-
get children() {
|
|
164
|
-
return Element.from(this.elt.children);
|
|
165
|
-
}
|
|
166
|
-
html(): string;
|
|
167
|
-
html(val: string): this;
|
|
168
|
-
html(val?:string): string|this {
|
|
169
|
-
if (val == undefined) return this.elt.innerHTML;
|
|
170
|
-
this.elt.innerHTML = val;
|
|
171
|
-
return this;
|
|
172
|
-
}
|
|
173
|
-
text(): string;
|
|
174
|
-
text(val: string): this;
|
|
175
|
-
text(val?: string): string | this {
|
|
176
|
-
if (val == undefined) return this.elt.textContent;
|
|
177
|
-
this.elt.textContent = val;
|
|
178
|
-
return this;
|
|
179
|
-
}
|
|
180
|
-
rect() {
|
|
181
|
-
return this.elt.getBoundingClientRect().toJSON();
|
|
182
|
-
}
|
|
183
|
-
value(): string;
|
|
184
|
-
value(val: string): this;
|
|
185
|
-
value(val?: string): string | this {
|
|
186
|
-
if (val == undefined) return (this.elt as any).value;
|
|
187
|
-
(this.elt as any).value = val;
|
|
188
|
-
return this;
|
|
189
|
-
}
|
|
190
|
-
checked(): boolean;
|
|
191
|
-
checked(val: boolean): this;
|
|
192
|
-
checked(val?: boolean): boolean| this {
|
|
193
|
-
if (val == undefined) return (this.elt as any).checked;
|
|
194
|
-
(this.elt as any).checked = val;
|
|
195
|
-
return this;
|
|
196
|
-
}
|
|
197
|
-
//events
|
|
198
|
-
click(func?: (this:HTMLElement, ev: any) => any, s?: boolean | AddEventListenerOptions) {
|
|
199
|
-
this.#TriggerEvent("click", func, s);
|
|
200
|
-
return this;
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
export class Caching extends Extension {
|
|
204
|
-
$() {
|
|
205
|
-
return {
|
|
206
|
-
cache<T extends (...args:any[])=>any>(func: T): T {
|
|
207
|
-
const f = (...args: Parameters<T>): ReturnType<T> => {
|
|
208
|
-
const val = JSON.stringify(args);
|
|
209
|
-
if (f.cache.hasOwnProperty(val)) {
|
|
210
|
-
return f.cache[val];
|
|
211
|
-
}
|
|
212
|
-
const temp = func(...args);
|
|
213
|
-
f.cache[val] = temp;
|
|
214
|
-
return temp;
|
|
215
|
-
};
|
|
216
|
-
f.cache = {};
|
|
217
|
-
return f as any;
|
|
218
|
-
},
|
|
219
|
-
};
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
export class ElementArray extends Array<Element> {
|
|
223
|
-
on<K extends keyof DocumentEventMap>(e: K, func: (this: HTMLElement, ev: DocumentEventMap[K])=>any, s?: boolean | AddEventListenerOptions) {
|
|
224
|
-
this.forEach((v) => v.on(e, func, s));
|
|
225
|
-
return this;
|
|
226
|
-
}
|
|
227
|
-
rect() {
|
|
228
|
-
return this.map((v) => v.rect());
|
|
229
|
-
}
|
|
230
|
-
hasClass(c:string) {
|
|
231
|
-
return this.map((v) => v.hasClass(c));
|
|
232
|
-
}
|
|
233
|
-
is(q:string) {
|
|
234
|
-
return this.map((v) => v.is(q));
|
|
235
|
-
}
|
|
236
|
-
checked(): boolean[];
|
|
237
|
-
checked(val: boolean): this;
|
|
238
|
-
checked(val?: boolean): this | boolean[] {
|
|
239
|
-
if (val !== undefined) {
|
|
240
|
-
this.forEach((v) => v.checked(val));
|
|
241
|
-
return this;
|
|
242
|
-
}
|
|
243
|
-
return this.map((v) => v.checked()) as any;
|
|
244
|
-
}
|
|
245
|
-
trigger(e: any) {
|
|
246
|
-
this.forEach((v) => v.trigger(e));
|
|
247
|
-
return this;
|
|
248
|
-
}
|
|
249
|
-
css(styles: Record<string, any>) {
|
|
250
|
-
this.forEach((v) => v.css(styles));
|
|
251
|
-
return this;
|
|
252
|
-
}
|
|
253
|
-
props(props: Record<string, any>) {
|
|
254
|
-
this.forEach((v) => v.props(props));
|
|
255
|
-
return this;
|
|
256
|
-
}
|
|
257
|
-
class(names: string | string[]) {
|
|
258
|
-
this.forEach((v) => v.class(names));
|
|
259
|
-
return this;
|
|
260
|
-
}
|
|
261
|
-
removeClass(names: string | string[]) {
|
|
262
|
-
this.forEach((v) => v.removeClass(names));
|
|
263
|
-
return this;
|
|
264
|
-
}
|
|
265
|
-
toggleClass(names: string | string[]) {
|
|
266
|
-
this.forEach((v) => v.toggleClass(names));
|
|
267
|
-
return this;
|
|
268
|
-
}
|
|
269
|
-
remove() {
|
|
270
|
-
this.forEach((v) => v.remove());
|
|
271
|
-
return this;
|
|
272
|
-
}
|
|
273
|
-
new() {
|
|
274
|
-
const temp = new ElementArray();
|
|
275
|
-
this.forEach((v) => temp.push(v.new() as any));
|
|
276
|
-
return temp;
|
|
277
|
-
}
|
|
278
|
-
//events
|
|
279
|
-
click(func: (this:HTMLElement, ev: any) => any, s?: boolean | AddEventListenerOptions) {
|
|
280
|
-
this.forEach((v) => v.click(func, s));
|
|
281
|
-
return this;
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
export const Plugin = Extension;
|
|
285
|
-
export type Plugin = Extension;
|
|
286
|
-
}
|
|
287
|
-
|
|
1
|
+
export * as JSQuery from "./jsquerymod.js";
|
|
2
|
+
import * as JSQuery from "./jsquerymod.js";
|
|
288
3
|
|
|
289
4
|
function J(q: any): JSQuery.Element | null {
|
|
290
5
|
return JSQuery.Element.from(document.querySelector(q)) as any;
|