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

32 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) {
2020-06-25 15:44:55 +00:00
this.htmlId = htmlId;
this.element = (htmlId) => {this.element = document.getElementById(htmlId);}
this.checkStatus = checkStatus;
this.callbacks = {};
this.disabledBefore = disabledBefore;
this.disabledAfter = disabledAfter;
this.hideBefore = hideBefore;
this.hideAfter = hideAfter;
this.element(this.htmlId);
2020-06-19 10:30:05 +00:00
}
setCallback(trigger, callback, bindThis, args=[]) {
this.callbacks[trigger] = {
2020-06-25 15:44:55 +00:00
"function": callback,
"bindThis": bindThis,
"args": args
2020-06-19 10:30:05 +00:00
};
}
bindThisToCallback(trigger) {
let callback = this.callbacks[trigger];
let boundedCallback = callback["function"].bind(callback.bindThis);
return boundedCallback;
}
}