nopaque/web/app/static/js/nopaque.InteractionElement.js

35 lines
1.0 KiB
JavaScript
Raw Normal View History

2020-06-19 10:30:05 +00:00
class InteractionElement {
constructor(htmlId="",
checkStatus=true,
2020-06-19 10:30:05 +00:00
disabledBefore=true,
disabledAfter=false,
hideBefore=true,
hideAfter=false) {
this.htmlId = htmlId;
this.checkStatus = checkStatus;
2020-06-19 10:30:05 +00:00
this.callbacks = {};
this.disabledBefore = disabledBefore;
this.disabledAfter = disabledAfter;
this.hideBefore = hideBefore;
this.hideAfter = hideAfter;
}
getElement() {
this.interactionStatusElement = document.getElementById(this.htmlId);
return this.interactionStatusElement;
2020-06-19 10:30:05 +00:00
}
setCallback(trigger, callback, bindThis, args=[]) {
this.callbacks[trigger] = {
"function": callback,
"bindThis": bindThis,
"args": args
};
}
bindThisToCallback(trigger) {
let callback = this.callbacks[trigger];
let boundedCallback = callback["function"].bind(callback.bindThis);
return boundedCallback;
}
}