Notes/src/public/javascripts/widgets/basic_widget.js

42 lines
729 B
JavaScript
Raw Normal View History

2020-01-15 21:36:01 +01:00
import Component from "./component.js";
2020-01-20 22:35:52 +01:00
import keyboardActionsService from "../services/keyboard_actions.js";
2020-01-15 21:36:01 +01:00
class BasicWidget extends Component {
render() {
2020-01-20 22:35:52 +01:00
const $widget = this.doRender();
$widget.addClass('component')
.prop('component', this);
this.toggle(this.isEnabled());
2020-01-20 22:35:52 +01:00
return $widget;
}
isEnabled() {
return true;
}
/**
* for overriding
*/
doRender() {}
2020-01-14 20:27:40 +01:00
toggle(show) {
this.$widget.toggle(show);
}
isVisible() {
return this.$widget.is(":visible");
}
2020-01-19 21:12:53 +01:00
remove() {
if (this.$widget) {
this.$widget.remove();
}
}
cleanup() {}
}
export default BasicWidget;