import { Component, Input, OnChanges } from '@angular/core';

import { HelperService }               from '@k-services/svc.helper'

@Component({
    moduleId: module.id+ '',
    selector: 'fold-out-description',
    templateUrl: './template.fold-out-description.pug',
    styleUrls: ['./structure.fold-out-description.scss','./visual.fold-out-description.scss']
})

export class FoldOutDescriptionComponent {

    isOpen: boolean = false
    
    @Input('description') description: string;
    @Input('content') content: any;
    shortDescription: string;
    fullDescription: string;

    constructor (
        private _helper: HelperService
    ) {  }

    ngOnChanges() {
        if(this.content) {
            this.shortDescription = this.content.short;
            this.fullDescription = this.content.long;
        }
    }

    open():void {
        if(!this.isOpen) {
            this.isOpen = true
        } else {
            this.isOpen = false
        }
    }
}