/* Copyright CloudLinux Zug GmbH 2010-2017 All Rights Reserved
 *
 * Licensed under CLOUD LINUX LICENSE AGREEMENT
 * http://cloudlinux.com/docs/LICENSE.TXT
 */
import { Component, ElementRef, Input } from '@angular/core';

@Component({
    selector: '[uiMultirowSpinner]',
    template: require('./ui-spinner.html'),
    styles: [require('./ui-spinner.less')],
})
export class UiTableMultirowSpinner {
    private height;
    private width;
    private state;
    @Input('spinner-size')
    private rowCount: number = 1;

    constructor (
        private el: ElementRef
    ) {}

    @Input('uiMultirowSpinner')
    public set uiSpinner(state: boolean) {
        this.state = state;
        if (state) {
            this.updateSize();
            setTimeout(() => {
                this.updateSize();
            }, 1);
        }
    }

    public updateSize() {
        this.height = this.el.nativeElement.offsetHeight;
        this.width = this.el.nativeElement.offsetWidth;
    }
}
