HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/farmfun/reserveren.farmfun.be/wwwroot/js/site/app/ReadMore.js
import {remove} from "lodash/array";

export default class ReadMore {
    constructor(shortContentElement, fullContentElement, toggleButtonElement) {
        this.shortContentElement = shortContentElement;
        this.fullContentElement = fullContentElement;
        this.toggleButtonElement = toggleButtonElement;

        // Initialize the state
        this.isExpanded = false;

        // Bind the click event to the toggle method
        this.toggleButtonElement.addEventListener('click', () => this.toggle());
    }

    toggle() {
        this.isExpanded = !this.isExpanded;

        // Update the view based on the current state
        this.updateView();
    }

    updateView() {
        if (this.isExpanded) {
            this.shortContentElement.classList.remove('is-active')
            this.fullContentElement.classList.add('is-active');
            this.toggleButtonElement.textContent = 'Lees minder';
        } else {
            this.shortContentElement.classList.add('is-active')
            this.fullContentElement.classList.remove('is-active');
            this.toggleButtonElement.textContent = 'Lees meer';
        }
    }
}