@aegis-framework/artemis 0.3.24 → 0.3.28
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/LICENSE +1 -1
- package/README.md +2 -2
- package/dist/artemis.js +2 -0
- package/dist/artemis.js.map +1 -0
- package/dist/artemis.min.js +2 -36
- package/dist/artemis.min.js.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/package.json +47 -15
- package/src/DOM.js +154 -14
- package/src/FileSystem.js +4 -0
- package/src/Platform.js +1 -0
- package/src/SpaceAdapter/IndexedDB.js +25 -5
- package/dist/artemis.min.map +0 -1
package/src/DOM.js
CHANGED
|
@@ -58,33 +58,45 @@ export class DOM {
|
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
60
|
* Hide elements by setting their `display` property to 'none'.
|
|
61
|
+
*
|
|
62
|
+
* @return {DOM} - Current instance
|
|
61
63
|
*/
|
|
62
64
|
hide () {
|
|
63
65
|
for (const element of this.collection) {
|
|
64
66
|
element.style.display = 'none';
|
|
65
67
|
}
|
|
68
|
+
|
|
69
|
+
return this;
|
|
66
70
|
}
|
|
67
71
|
|
|
68
72
|
/**
|
|
69
73
|
* Show elements by setting their `display` property to the given value.
|
|
70
74
|
*
|
|
71
75
|
* @param {string} [display='block'] - Display property to set
|
|
76
|
+
*
|
|
77
|
+
* @return {DOM} - Current instance
|
|
72
78
|
*/
|
|
73
79
|
show (display = 'block') {
|
|
74
80
|
for (const element of this.collection) {
|
|
75
81
|
element.style.display = display;
|
|
76
82
|
}
|
|
83
|
+
|
|
84
|
+
return this;
|
|
77
85
|
}
|
|
78
86
|
|
|
79
87
|
/**
|
|
80
88
|
* Add a class to the classList object
|
|
81
89
|
*
|
|
82
90
|
* @param {string} newClass - Class name to add
|
|
91
|
+
*
|
|
92
|
+
* @return {DOM} - Current instance
|
|
83
93
|
*/
|
|
84
94
|
addClass (newClass) {
|
|
85
95
|
for (const element of this.collection) {
|
|
86
96
|
element.classList.add (newClass);
|
|
87
97
|
}
|
|
98
|
+
|
|
99
|
+
return this;
|
|
88
100
|
}
|
|
89
101
|
|
|
90
102
|
/**
|
|
@@ -92,6 +104,8 @@ export class DOM {
|
|
|
92
104
|
*
|
|
93
105
|
* @param {string} [oldClass=null] - Class to remove. If it's empty or null,
|
|
94
106
|
* all classes will be removed
|
|
107
|
+
*
|
|
108
|
+
* @return {DOM} - Current instance
|
|
95
109
|
*/
|
|
96
110
|
removeClass (oldClass = null) {
|
|
97
111
|
if (oldClass !== null) {
|
|
@@ -105,12 +119,16 @@ export class DOM {
|
|
|
105
119
|
}
|
|
106
120
|
}
|
|
107
121
|
}
|
|
122
|
+
|
|
123
|
+
return this;
|
|
108
124
|
}
|
|
109
125
|
|
|
110
126
|
/**
|
|
111
127
|
* Toggle between two classes
|
|
112
128
|
*
|
|
113
129
|
* @param {string} classes - Space separated class names
|
|
130
|
+
*
|
|
131
|
+
* @return {DOM} - Current instance
|
|
114
132
|
*/
|
|
115
133
|
toggleClass (classes) {
|
|
116
134
|
classes = classes.split (' ');
|
|
@@ -119,12 +137,15 @@ export class DOM {
|
|
|
119
137
|
element.classList.toggle (classes[j]);
|
|
120
138
|
}
|
|
121
139
|
}
|
|
140
|
+
|
|
141
|
+
return this;
|
|
122
142
|
}
|
|
123
143
|
|
|
124
144
|
/**
|
|
125
145
|
* Check if the first element matching the selector has the given class
|
|
126
146
|
*
|
|
127
147
|
* @param {string} classToCheck - Class name to check for
|
|
148
|
+
*
|
|
128
149
|
* @return {boolean} - Whether the class is present or not
|
|
129
150
|
*/
|
|
130
151
|
hasClass (classToCheck) {
|
|
@@ -140,14 +161,18 @@ export class DOM {
|
|
|
140
161
|
* Get or set the value from the first element matching the selector
|
|
141
162
|
*
|
|
142
163
|
* @param {string} value - Value to set to the element.
|
|
143
|
-
*
|
|
144
|
-
*
|
|
164
|
+
*
|
|
165
|
+
* @return {string|DOM} - If a value is provided, this returns the current
|
|
166
|
+
* instance, otherwise it returns the value of the element instead of
|
|
167
|
+
* setting it
|
|
145
168
|
*/
|
|
146
169
|
value (value) {
|
|
147
170
|
if (typeof value !== 'undefined') {
|
|
148
171
|
for (const element of this.collection) {
|
|
149
172
|
element.value = value;
|
|
150
173
|
}
|
|
174
|
+
|
|
175
|
+
return this;
|
|
151
176
|
} else {
|
|
152
177
|
if (this.length > 0) {
|
|
153
178
|
return this.collection[0].value;
|
|
@@ -157,77 +182,105 @@ export class DOM {
|
|
|
157
182
|
|
|
158
183
|
/**
|
|
159
184
|
* Focus on the first element matching the selector
|
|
185
|
+
*
|
|
186
|
+
* @return {DOM} - Current instance
|
|
160
187
|
*/
|
|
161
188
|
focus () {
|
|
162
189
|
if (this.length > 0) {
|
|
163
190
|
this.collection[0].focus ();
|
|
164
191
|
}
|
|
192
|
+
|
|
193
|
+
return this;
|
|
165
194
|
}
|
|
166
195
|
|
|
167
196
|
/**
|
|
168
197
|
* Add a callback for the 'click' event on every element matching the selector
|
|
169
198
|
*
|
|
170
199
|
* @param {function} callback - Callback function to run when the event is triggered
|
|
200
|
+
*
|
|
201
|
+
* @return {DOM} - Current instance
|
|
171
202
|
*/
|
|
172
203
|
click (callback) {
|
|
173
204
|
for (const element of this.collection) {
|
|
174
205
|
element.addEventListener ('click', callback, false);
|
|
175
206
|
}
|
|
207
|
+
|
|
208
|
+
return this;
|
|
176
209
|
}
|
|
177
210
|
|
|
178
211
|
/**
|
|
179
212
|
* Add a callback for the 'keyup' event on every element matching the selector
|
|
180
213
|
*
|
|
181
214
|
* @param {function} callback - Callback function to run when the event is triggered
|
|
215
|
+
*
|
|
216
|
+
* @return {DOM} - Current instance
|
|
182
217
|
*/
|
|
183
218
|
keyup (callback) {
|
|
184
219
|
for (const element of this.collection) {
|
|
185
220
|
element.addEventListener ('keyup', callback, false);
|
|
186
221
|
}
|
|
222
|
+
|
|
223
|
+
return this;
|
|
187
224
|
}
|
|
188
225
|
|
|
189
226
|
/**
|
|
190
227
|
* Add a callback for the 'keydown' event on every element matching the selector
|
|
191
228
|
*
|
|
192
229
|
* @param {function} callback - Callback function to run when the event is triggered
|
|
230
|
+
*
|
|
231
|
+
* @return {DOM} - Current instance
|
|
193
232
|
*/
|
|
194
233
|
keydown (callback) {
|
|
195
234
|
for (const element of this.collection) {
|
|
196
235
|
element.addEventListener ('keydown', callback, false);
|
|
197
236
|
}
|
|
237
|
+
|
|
238
|
+
return this;
|
|
198
239
|
}
|
|
199
240
|
|
|
200
241
|
/**
|
|
201
242
|
* Add a callback for the 'submit' event on every element matching the selector
|
|
202
243
|
*
|
|
203
244
|
* @param {function} callback - Callback function to run when the event is triggered
|
|
245
|
+
*
|
|
246
|
+
* @return {DOM} - Current instance
|
|
204
247
|
*/
|
|
205
248
|
submit (callback) {
|
|
206
249
|
for (const element of this.collection) {
|
|
207
250
|
element.addEventListener ('submit', callback, false);
|
|
208
251
|
}
|
|
252
|
+
|
|
253
|
+
return this;
|
|
209
254
|
}
|
|
210
255
|
|
|
211
256
|
/**
|
|
212
257
|
* Add a callback for the 'change' event on every element matching the selector
|
|
213
258
|
*
|
|
214
259
|
* @param {function} callback - Callback function to run when the event is triggered
|
|
260
|
+
*
|
|
261
|
+
* @return {DOM} - Current instance
|
|
215
262
|
*/
|
|
216
263
|
change (callback) {
|
|
217
264
|
for (const element of this.collection) {
|
|
218
265
|
element.addEventListener ('change', callback, false);
|
|
219
266
|
}
|
|
267
|
+
|
|
268
|
+
return this;
|
|
220
269
|
}
|
|
221
270
|
|
|
222
271
|
/**
|
|
223
272
|
* Add a callback for the 'scroll' event on every element matching the selector
|
|
224
273
|
*
|
|
225
274
|
* @param {function} callback - Callback function to run when the event is triggered
|
|
275
|
+
*
|
|
276
|
+
* @return {DOM} - Current instance
|
|
226
277
|
*/
|
|
227
278
|
scroll (callback) {
|
|
228
279
|
for (const element of this.collection) {
|
|
229
280
|
element.addEventListener ('scroll', callback, false);
|
|
230
281
|
}
|
|
282
|
+
|
|
283
|
+
return this;
|
|
231
284
|
}
|
|
232
285
|
|
|
233
286
|
/**
|
|
@@ -236,6 +289,8 @@ export class DOM {
|
|
|
236
289
|
* @param {string} event - Event to add the listener to
|
|
237
290
|
* @param {string} target - Target element on which to detect the event
|
|
238
291
|
* @param {function} callback - Callback function to run when the event is triggered
|
|
292
|
+
*
|
|
293
|
+
* @return {DOM} - Current instance
|
|
239
294
|
*/
|
|
240
295
|
on (event, target, callback) {
|
|
241
296
|
event = event.split(' ');
|
|
@@ -262,12 +317,15 @@ export class DOM {
|
|
|
262
317
|
}
|
|
263
318
|
}
|
|
264
319
|
}
|
|
320
|
+
|
|
321
|
+
return this;
|
|
265
322
|
}
|
|
266
323
|
|
|
267
324
|
/**
|
|
268
325
|
* Filter from the current collection to only those matching the new selector
|
|
269
326
|
*
|
|
270
327
|
* @param {string} element - Selector to filter the collection with
|
|
328
|
+
*
|
|
271
329
|
* @return {DOM} - New DOM instance with the filtered collection
|
|
272
330
|
*/
|
|
273
331
|
filter (selector) {
|
|
@@ -292,13 +350,17 @@ export class DOM {
|
|
|
292
350
|
*
|
|
293
351
|
* @param {string} name - Name of the data property
|
|
294
352
|
* @param {string} [value] - Value of the property
|
|
295
|
-
*
|
|
353
|
+
*
|
|
354
|
+
* @return {string|DOM} - If no value is provided, this function returns
|
|
355
|
+
* the first matching element value, otherwise it returns the current instance
|
|
296
356
|
*/
|
|
297
357
|
data (name, value) {
|
|
298
358
|
if (typeof value !== 'undefined') {
|
|
299
359
|
for (const element of this.collection) {
|
|
300
360
|
element.dataset[name] = value;
|
|
301
361
|
}
|
|
362
|
+
|
|
363
|
+
return this;
|
|
302
364
|
} else {
|
|
303
365
|
if (this.length > 0) {
|
|
304
366
|
return this.collection[0].dataset[name];
|
|
@@ -312,26 +374,32 @@ export class DOM {
|
|
|
312
374
|
*
|
|
313
375
|
* @param {string} name - Name of the data property to remove
|
|
314
376
|
*
|
|
315
|
-
* @return {
|
|
377
|
+
* @return {DOM} - Current instance
|
|
316
378
|
*/
|
|
317
379
|
removeData (name) {
|
|
318
380
|
for (const element of this.collection) {
|
|
319
381
|
delete element.dataset[name];
|
|
320
382
|
}
|
|
383
|
+
|
|
384
|
+
return this;
|
|
321
385
|
}
|
|
322
386
|
|
|
323
387
|
/**
|
|
324
388
|
* Get or set the text of the first element matching the selector
|
|
325
389
|
*
|
|
326
390
|
* @param {string} [value] - Value to set the text to
|
|
327
|
-
*
|
|
328
|
-
*
|
|
391
|
+
*
|
|
392
|
+
* @return {string|DOM} - If no value is provided, this function returns the
|
|
393
|
+
* inner text of the first matching element. Otherwise it returns the current
|
|
394
|
+
* instance.
|
|
329
395
|
*/
|
|
330
396
|
text (value) {
|
|
331
397
|
if (typeof value !== 'undefined') {
|
|
332
398
|
for (const element of this.collection) {
|
|
333
399
|
element.textContent = value;
|
|
334
400
|
}
|
|
401
|
+
|
|
402
|
+
return this;
|
|
335
403
|
} else {
|
|
336
404
|
if (this.length > 0) {
|
|
337
405
|
return this.collection[0].textContent;
|
|
@@ -343,14 +411,17 @@ export class DOM {
|
|
|
343
411
|
* Get or set the inner HTML of the first element matching the selector
|
|
344
412
|
*
|
|
345
413
|
* @param {string} [value] - Value to set the HTML to
|
|
346
|
-
*
|
|
347
|
-
*
|
|
414
|
+
*
|
|
415
|
+
* @return {string|DOM} - If no value is provided, this function returns the
|
|
416
|
+
* first matching element HTML. Otherwise it returns the current instance
|
|
348
417
|
*/
|
|
349
418
|
html (value) {
|
|
350
419
|
if (typeof value !== 'undefined') {
|
|
351
420
|
for (const element of this.collection) {
|
|
352
421
|
element.innerHTML = value;
|
|
353
422
|
}
|
|
423
|
+
|
|
424
|
+
return this;
|
|
354
425
|
} else {
|
|
355
426
|
if (this.length > 0) {
|
|
356
427
|
return this.collection[0].innerHTML;
|
|
@@ -362,6 +433,8 @@ export class DOM {
|
|
|
362
433
|
* Append an element to the first element matching the selector
|
|
363
434
|
*
|
|
364
435
|
* @param {string} element - String representation of the element to add
|
|
436
|
+
*
|
|
437
|
+
* @return {DOM} - Current instance
|
|
365
438
|
*/
|
|
366
439
|
append (element) {
|
|
367
440
|
if (this.length > 0) {
|
|
@@ -377,12 +450,16 @@ export class DOM {
|
|
|
377
450
|
this.collection[0].appendChild (element);
|
|
378
451
|
}
|
|
379
452
|
}
|
|
453
|
+
|
|
454
|
+
return this;
|
|
380
455
|
}
|
|
381
456
|
|
|
382
457
|
/**
|
|
383
458
|
* Prepend an element to the first element matching the selector
|
|
384
459
|
*
|
|
385
460
|
* @param {string} element - String representation of the element to add
|
|
461
|
+
*
|
|
462
|
+
* @return {DOM} - Current instance
|
|
386
463
|
*/
|
|
387
464
|
prepend (element) {
|
|
388
465
|
if (this.length > 0) {
|
|
@@ -406,23 +483,30 @@ export class DOM {
|
|
|
406
483
|
}
|
|
407
484
|
}
|
|
408
485
|
}
|
|
486
|
+
|
|
487
|
+
return this;
|
|
409
488
|
}
|
|
410
489
|
|
|
411
490
|
/**
|
|
412
491
|
* Iterate over the collection of elements matching the selector
|
|
413
492
|
*
|
|
414
493
|
* @param {function} callback - Callback to run for every element
|
|
494
|
+
*
|
|
495
|
+
* @return {DOM} - Current instance
|
|
415
496
|
*/
|
|
416
497
|
each (callback) {
|
|
417
498
|
for (const element of this.collection) {
|
|
418
499
|
callback (element);
|
|
419
500
|
}
|
|
501
|
+
|
|
502
|
+
return this;
|
|
420
503
|
}
|
|
421
504
|
|
|
422
505
|
/**
|
|
423
506
|
* Get an element from the collection given it's index
|
|
424
507
|
*
|
|
425
508
|
* @param {int} index - Index of the element to retrieve
|
|
509
|
+
*
|
|
426
510
|
* @return {HTMLElement} - HTML Element in the position indicated by the index
|
|
427
511
|
*/
|
|
428
512
|
get (index) {
|
|
@@ -487,7 +571,8 @@ export class DOM {
|
|
|
487
571
|
* Find an element that matches the given selector in the first element of the collection
|
|
488
572
|
*
|
|
489
573
|
* @param {string} selector - Selector to find the element with
|
|
490
|
-
*
|
|
574
|
+
*
|
|
575
|
+
* @return {DOM} - DOM instance with the element if found
|
|
491
576
|
*/
|
|
492
577
|
find (selector) {
|
|
493
578
|
if (this.length > 0) {
|
|
@@ -500,7 +585,7 @@ export class DOM {
|
|
|
500
585
|
/**
|
|
501
586
|
* Get the top and left offsets of the first element matching the selector
|
|
502
587
|
*
|
|
503
|
-
* @return {
|
|
588
|
+
* @return {object|void} - Object with `top` and `left` offsets
|
|
504
589
|
*/
|
|
505
590
|
offset () {
|
|
506
591
|
if (this.length > 0) {
|
|
@@ -517,6 +602,7 @@ export class DOM {
|
|
|
517
602
|
* from the initial object and then follows to its parents.
|
|
518
603
|
*
|
|
519
604
|
* @param {string} selector - Selector to match the closest element with
|
|
605
|
+
*
|
|
520
606
|
* @return {DOM} - DOM instance with the closest HTML element matching the selector
|
|
521
607
|
*/
|
|
522
608
|
closest (selector) {
|
|
@@ -546,6 +632,17 @@ export class DOM {
|
|
|
546
632
|
return element;
|
|
547
633
|
}
|
|
548
634
|
|
|
635
|
+
/**
|
|
636
|
+
* Find the closest parent element matching the given selector. This bubbles up
|
|
637
|
+
* from the initial object and then follows to its parents.
|
|
638
|
+
*
|
|
639
|
+
* @param {string} selector - Selector to match the closest element with
|
|
640
|
+
* @param {string} limit - Selector for limit element. If the limit is reached
|
|
641
|
+
* and no element matching the provided selector was found, it will cause an
|
|
642
|
+
* early return.
|
|
643
|
+
*
|
|
644
|
+
* @return {DOM} - DOM instance with the closest HTML element matching the selector
|
|
645
|
+
*/
|
|
549
646
|
closestParent (selector, limit) {
|
|
550
647
|
let element = this;
|
|
551
648
|
while (element.exists ()) {
|
|
@@ -574,7 +671,8 @@ export class DOM {
|
|
|
574
671
|
*
|
|
575
672
|
* @param {string} attribute - Attribute's name
|
|
576
673
|
* @param {string|Number} [value] - Value to set the attribute to
|
|
577
|
-
*
|
|
674
|
+
*
|
|
675
|
+
* @return {string|number|DOM} - If no value is provided, this function returns the current
|
|
578
676
|
* value of the provided attribute
|
|
579
677
|
*/
|
|
580
678
|
attribute (attribute, value) {
|
|
@@ -582,6 +680,8 @@ export class DOM {
|
|
|
582
680
|
for (const element of this.collection) {
|
|
583
681
|
element.setAttribute (attribute, value);
|
|
584
682
|
}
|
|
683
|
+
|
|
684
|
+
return this;
|
|
585
685
|
} else {
|
|
586
686
|
if (this.length > 0) {
|
|
587
687
|
return this.collection[0].getAttribute (attribute);
|
|
@@ -593,6 +693,7 @@ export class DOM {
|
|
|
593
693
|
* Check whether an element has an attribute or not
|
|
594
694
|
*
|
|
595
695
|
* @param {string} attribute - The name of the attribute to check existance for
|
|
696
|
+
*
|
|
596
697
|
* @returns {boolean} - Whether or not the attribute is present
|
|
597
698
|
*/
|
|
598
699
|
hasAttribute (attribute) {
|
|
@@ -608,22 +709,30 @@ export class DOM {
|
|
|
608
709
|
* Insert content to the `after` property of an element
|
|
609
710
|
*
|
|
610
711
|
* @param {string} content - String representation of the content to add
|
|
712
|
+
*
|
|
713
|
+
* @return {DOM} - Current instance
|
|
611
714
|
*/
|
|
612
715
|
after (content) {
|
|
613
716
|
for (const element of this.collection) {
|
|
614
717
|
element.insertAdjacentHTML ('afterend', content);
|
|
615
718
|
}
|
|
719
|
+
|
|
720
|
+
return this;
|
|
616
721
|
}
|
|
617
722
|
|
|
618
723
|
/**
|
|
619
724
|
* Insert content to the `before` property of an element
|
|
620
725
|
*
|
|
621
726
|
* @param {string} content - String representation of the content to add
|
|
727
|
+
*
|
|
728
|
+
* @return {DOM} - Current instance
|
|
622
729
|
*/
|
|
623
730
|
before (content) {
|
|
624
731
|
for (const element of this.collection) {
|
|
625
732
|
element.insertAdjacentHTML ('beforebegin', content);
|
|
626
733
|
}
|
|
734
|
+
|
|
735
|
+
return this;
|
|
627
736
|
}
|
|
628
737
|
|
|
629
738
|
/**
|
|
@@ -633,14 +742,15 @@ export class DOM {
|
|
|
633
742
|
* either an individual property or a JSON object with key-value pairs
|
|
634
743
|
* @param {string} [value] - Value to set the property to when only changing
|
|
635
744
|
* one property
|
|
636
|
-
*
|
|
745
|
+
*
|
|
746
|
+
* @return {string|DOM} - If a property is given but not a value for it, this
|
|
637
747
|
* function will return its current value
|
|
638
748
|
*/
|
|
639
749
|
style (properties, value) {
|
|
640
750
|
for (let i = 0; i < this.collection.length; i++) {
|
|
641
|
-
if (typeof properties === 'string' && value !== 'undefined') {
|
|
751
|
+
if (typeof properties === 'string' && typeof value !== 'undefined') {
|
|
642
752
|
this.collection[i].style[properties] = value;
|
|
643
|
-
} else if (typeof properties === 'string' && value === 'undefined') {
|
|
753
|
+
} else if (typeof properties === 'string' && typeof value === 'undefined') {
|
|
644
754
|
return this.collection[i].style[properties];
|
|
645
755
|
} else if (typeof properties === 'object') {
|
|
646
756
|
for (const property in properties) {
|
|
@@ -648,6 +758,7 @@ export class DOM {
|
|
|
648
758
|
}
|
|
649
759
|
}
|
|
650
760
|
}
|
|
761
|
+
return this;
|
|
651
762
|
}
|
|
652
763
|
|
|
653
764
|
/**
|
|
@@ -658,6 +769,8 @@ export class DOM {
|
|
|
658
769
|
* to animate
|
|
659
770
|
* @param {int} time - Time in milliseconds during which the properties will
|
|
660
771
|
* be animated
|
|
772
|
+
*
|
|
773
|
+
* @return {DOM} - Current instance
|
|
661
774
|
*/
|
|
662
775
|
animate (style, time) {
|
|
663
776
|
for (let i = 0; i < this.collection.length; i++) {
|
|
@@ -697,6 +810,8 @@ export class DOM {
|
|
|
697
810
|
}
|
|
698
811
|
}
|
|
699
812
|
}
|
|
813
|
+
|
|
814
|
+
return this;
|
|
700
815
|
}
|
|
701
816
|
|
|
702
817
|
/**
|
|
@@ -704,6 +819,8 @@ export class DOM {
|
|
|
704
819
|
*
|
|
705
820
|
* @param {type} [time=400] - Time duration for the animation
|
|
706
821
|
* @param {type} callback - Callback function to run once the animation is over
|
|
822
|
+
*
|
|
823
|
+
* @return {DOM} - Current instance
|
|
707
824
|
*/
|
|
708
825
|
fadeIn (time = 400, callback) {
|
|
709
826
|
if (this.length > 0) {
|
|
@@ -727,6 +844,8 @@ export class DOM {
|
|
|
727
844
|
|
|
728
845
|
tick();
|
|
729
846
|
}
|
|
847
|
+
|
|
848
|
+
return this;
|
|
730
849
|
}
|
|
731
850
|
|
|
732
851
|
/**
|
|
@@ -734,6 +853,8 @@ export class DOM {
|
|
|
734
853
|
*
|
|
735
854
|
* @param {type} [time=400] - Time duration for the animation
|
|
736
855
|
* @param {type} callback - Callback function to run once the animation is over
|
|
856
|
+
*
|
|
857
|
+
* @return {DOM} - Current instance
|
|
737
858
|
*/
|
|
738
859
|
fadeOut (time = 400, callback) {
|
|
739
860
|
if (this.length > 0) {
|
|
@@ -753,11 +874,14 @@ export class DOM {
|
|
|
753
874
|
};
|
|
754
875
|
tick ();
|
|
755
876
|
}
|
|
877
|
+
|
|
878
|
+
return this;
|
|
756
879
|
}
|
|
757
880
|
|
|
758
881
|
/** Check if the first element in the collection matches a given selector
|
|
759
882
|
*
|
|
760
883
|
* @param {string} selector - Selector to match
|
|
884
|
+
*
|
|
761
885
|
* @return {boolean} - Whether the element matches the selector or not
|
|
762
886
|
*/
|
|
763
887
|
matches (selector) {
|
|
@@ -775,15 +899,21 @@ export class DOM {
|
|
|
775
899
|
|
|
776
900
|
/**
|
|
777
901
|
* Remove all elements in the collection
|
|
902
|
+
*
|
|
903
|
+
* @return {DOM} - Current instance
|
|
778
904
|
*/
|
|
779
905
|
remove () {
|
|
780
906
|
for (const element of this.collection) {
|
|
781
907
|
element.parentNode.removeChild (element);
|
|
782
908
|
}
|
|
909
|
+
|
|
910
|
+
return this;
|
|
783
911
|
}
|
|
784
912
|
|
|
785
913
|
/**
|
|
786
914
|
* Replace the first element in the collection with a new one
|
|
915
|
+
*
|
|
916
|
+
* @return {DOM} - Current instance
|
|
787
917
|
*/
|
|
788
918
|
replaceWith (newElement) {
|
|
789
919
|
let replaceElement = newElement;
|
|
@@ -797,15 +927,21 @@ export class DOM {
|
|
|
797
927
|
for (const element of this.collection) {
|
|
798
928
|
element.parentElement.replaceChild (replaceElement, element);
|
|
799
929
|
}
|
|
930
|
+
|
|
931
|
+
return this;
|
|
800
932
|
}
|
|
801
933
|
|
|
802
934
|
/**
|
|
803
935
|
* Reset every element in the collection
|
|
936
|
+
*
|
|
937
|
+
* @return {DOM} - Current instance
|
|
804
938
|
*/
|
|
805
939
|
reset () {
|
|
806
940
|
for (const element of this.collection) {
|
|
807
941
|
element.reset ();
|
|
808
942
|
}
|
|
943
|
+
|
|
944
|
+
return this;
|
|
809
945
|
}
|
|
810
946
|
|
|
811
947
|
/**
|
|
@@ -813,6 +949,7 @@ export class DOM {
|
|
|
813
949
|
*
|
|
814
950
|
* @param {string} property - Property name to set or get
|
|
815
951
|
* @param {string|Number} [value] - Value to set the property to
|
|
952
|
+
*
|
|
816
953
|
* @return {string|Number} - If no value is provided, this function will return the
|
|
817
954
|
* current value of the indicated property
|
|
818
955
|
*/
|
|
@@ -821,6 +958,8 @@ export class DOM {
|
|
|
821
958
|
for (const element of this.collection) {
|
|
822
959
|
element[property] = value;
|
|
823
960
|
}
|
|
961
|
+
|
|
962
|
+
return this;
|
|
824
963
|
} else {
|
|
825
964
|
if (this.length > 0) {
|
|
826
965
|
return this.collection[0][property];
|
|
@@ -833,6 +972,7 @@ export class DOM {
|
|
|
833
972
|
* Simple wrapper function to use the DOM library
|
|
834
973
|
*
|
|
835
974
|
* @param {string|Object|array} selector - Selector or DOM element to use
|
|
975
|
+
*
|
|
836
976
|
* @return {DOM} - DOM instance or class if no selector is used
|
|
837
977
|
*/
|
|
838
978
|
export function $_ (selector) {
|
package/src/FileSystem.js
CHANGED
|
@@ -40,6 +40,7 @@ export class FileSystem {
|
|
|
40
40
|
* @param {File|Blob} file - File to read
|
|
41
41
|
* @param {string} [type = 'text'] - Type of data to be read, values can be
|
|
42
42
|
* 'text', 'base64' and 'buffer'.
|
|
43
|
+
*
|
|
43
44
|
* @return {Promise<Event, ArrayBuffer|string>} - Promise that resolves to
|
|
44
45
|
* the Load event and content of the file. The format depends on the type
|
|
45
46
|
* parameter used.
|
|
@@ -75,6 +76,7 @@ export class FileSystem {
|
|
|
75
76
|
* @param {string} file - Name of the file (Including extension)
|
|
76
77
|
* @param {ArrayBuffer|ArrayBufferView|Blob|string} content - Content to save in the file
|
|
77
78
|
* @param {string} [type = 'text/plain'] - Mime Type for the file
|
|
79
|
+
*
|
|
78
80
|
* @return {Promise<File>}
|
|
79
81
|
*/
|
|
80
82
|
static create (name, content, type = 'text/plain') {
|
|
@@ -85,6 +87,7 @@ export class FileSystem {
|
|
|
85
87
|
* @static extension - Returns the extension of a file given its file name.
|
|
86
88
|
*
|
|
87
89
|
* @param {string} name - Name or full path of the file
|
|
90
|
+
*
|
|
88
91
|
* @return {string} - File extension without the leading dot (.)
|
|
89
92
|
*/
|
|
90
93
|
static extension (name) {
|
|
@@ -95,6 +98,7 @@ export class FileSystem {
|
|
|
95
98
|
* @static isImage - Check if a file is an image by its extension.
|
|
96
99
|
*
|
|
97
100
|
* @param {string} name - Name or full path of the file
|
|
101
|
+
*
|
|
98
102
|
* @return {boolean}
|
|
99
103
|
*/
|
|
100
104
|
static isImage (name) {
|