salix/front/core/components/debug-info/index.js

32 lines
827 B
JavaScript
Raw Normal View History

2019-10-23 15:38:35 +00:00
import ngModule from '../../module';
import Component from '../../lib/component';
2019-10-23 15:38:35 +00:00
import './style.scss';
/**
* Floating box displaying debugging information.
* Enabled only in development environment.
*/
export default class Controller extends Component {
2019-10-23 15:38:35 +00:00
constructor($element, $) {
super($element, $);
2019-10-23 15:38:35 +00:00
this.env = process.env.NODE_ENV || 'development';
if (this.env == 'development')
this.interval = setInterval(() => $.$digest(), 2000);
else
$element[0].style.display = 'none';
$element[0].addEventListener('mouseover',
() => this.classList.toggle('right'));
2019-10-23 15:38:35 +00:00
}
$onDestroy() {
clearInterval(this.interval);
}
}
ngModule.vnComponent('vnDebugInfo', {
2019-10-23 15:38:35 +00:00
template: require('./index.html'),
controller: Controller
});