"use strict"; // Grouping manager for mutually-exclusive controls Toolkit.ButtonGroup = class ButtonGroup { // Object constructor constructor() { this.components = []; } ///////////////////////////// Public Methods ////////////////////////////// // Add a component to the group add(component) { if (this.components.indexOf(component) != -1) return component; this.components.push(component); if ("setGroup" in component) component.setGroup(this); return component; } // Select only one button in the group setChecked(component) { for (let comp of this.components) { if ("setChecked" in comp) comp.setChecked(comp == component, this); } } // Remove a component from the group remove(component) { let index = this.components.indexOf(component); if (index == -1) return false; this.components.splice(index, 1); if ("setGroup" in component) component.setGroup(null); return true; } };