"use strict"; // Display text component Toolkit.Label = class Label extends Toolkit.Component { // Object constructor constructor(application, options) { super(application, "div", options); options = options || {}; // Configure instance fields this.localized = "localized" in options ? !!options.localized : false; this.text = options.text || ""; // Configure element this.element.style.cursor = "default"; this.element.style.userSelect = "none"; // Configure properties this.setText(this.text); if (this.localized) this.application.addComponent(this); } ///////////////////////////// Public Methods ////////////////////////////// // Retrieve the label's display text getText() { return this.text; } // Specify the label's display text setText(text) { this.text = text || ""; this.localize(); } ///////////////////////////// Package Methods ///////////////////////////// // Update display text with localized strings localize() { let text = this.text; if (this.localized && this.application) text = this.application.translate(text, this); this.element.innerText = text; } };