rx/presenters

View on GitHub
views/mdc/assets/js/components/progress.js

Summary

Maintainability
A
0 mins
Test Coverage
import {hookupComponents, VBaseComponent} from './base-component';
import {MDCLinearProgress} from '@material/linear-progress';

export function initProgress(e) {
    console.debug('\tProgress');
    hookupComponents(e, '.v-progress', VProgress, MDCLinearProgress);
}

export class VProgress extends VBaseComponent {
    constructor(element, mdcComponent) {
        super(element, mdcComponent);
        element.dataset.hidden === 'true' ? this.hide() : this.show();
        this.root.addEventListener('V:postStarted', (e) => {
            this.show();
        });
        this.root.addEventListener('V:postFinished', (e) => {
            this.hide();
        });
        this.root.addEventListener('V:eventsHalted', (e) => {
            this.hide();
        });
    }

    show() {
        this.mdcComponent.open();
    }

    hide() {
        this.mdcComponent.close();
    }
}