Source
const show_secondary_label = document.getElementById(`show_${<?= WidgetForm::SHOW_SECONDARY_LABEL ?>}`).checked;
<?php declare(strict_types = 0);
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
use Widgets\Honeycomb\Includes\WidgetForm;
?>
window.widget_honeycomb_form = new class {
/**
* @type {HTMLFormElement}
*/
#form;
init({thresholds_colors}) {
this.#form = document.getElementById('widget-dialogue-form');
colorPalette.setThemeColors(thresholds_colors);
this.#form.addEventListener('change', e => {
this.#updateForm();
if (e.target.id === 'primary_label_size_type_<?= WidgetForm::LABEL_SIZE_CUSTOM ?>') {
document.getElementById('primary_label_size').focus();
}
if (e.target.id === 'secondary_label_size_type_<?= WidgetForm::LABEL_SIZE_CUSTOM ?>') {
document.getElementById('secondary_label_size').focus();
}
});
$thresholds_table.on('afterremove.dynamicRows', () => this.#updateForm());
this._thresholds_table = $thresholds_table[0];
this._thresholds_table.addEventListener('input', e => {
if (e.target.matches('input[name$="[threshold]"')) {
this.#updateForm();
}
});
for (const colorpicker of this.#form.querySelectorAll('.<?= ZBX_STYLE_COLOR_PICKER ?> input')) {
$(colorpicker).colorpicker({
appendTo: '.overlay-dialogue-body',
use_default: !colorpicker.name.includes('thresholds')
});
}
this.#updateForm();
}