2021-07-12 12:36:30 +03:00
|
|
|
class Input {
|
|
|
|
static on(event, elementId, functionCallback, ...args) {
|
|
|
|
//if element provided is string, get the actual element
|
|
|
|
const element = Util.getElement(elementId);
|
|
|
|
|
|
|
|
element.addEventListener(event,
|
|
|
|
function (e) {
|
2021-07-15 23:21:19 +03:00
|
|
|
functionCallback(...args, e);
|
2021-07-12 12:36:30 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
static onChildren(event, parentElement, functionCallback, ...args) {
|
|
|
|
parentElement = Util.getElement(parentElement);
|
|
|
|
const children = parentElement.children;
|
|
|
|
|
|
|
|
//loop through children and add onClick listener
|
|
|
|
for (var i = 0; i < children.length; i++) {
|
2021-07-15 19:33:19 +03:00
|
|
|
on(event, children[i], functionCallback, ...args);
|
2021-07-12 12:36:30 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|