Source
$overlay_body.scrollTop(Math.max($overlay_body.scrollTop(), this.#form.scrollHeight - $overlay_body.height()));
<?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\PieChart\Includes\{
CWidgetFieldDataSet,
WidgetForm
};
?>
window.widget_pie_chart_form = new class {
/**
* @type {HTMLFormElement}
*/
#form;
/**
* @type {HTMLElement}
*/
#dataset_wrapper;
/**
* @type {Map<HTMLLIElement, CSortable>}
*/
#single_items_sortable = new Map();
/**
* @type {String}
*/
#templateid;
init({form_tabs_id, color_palette, templateid}) {
colorPalette.setThemeColors(color_palette);
this.#form = document.getElementById('widget-dialogue-form');
this.#dataset_wrapper = document.getElementById('data_sets');
this.#templateid = templateid;
jQuery('.overlay-dialogue-body').off('scroll');
for (const colorpicker of this.#form.querySelectorAll('.<?= ZBX_STYLE_COLOR_PICKER ?> input')) {
$(colorpicker).colorpicker({
appendTo: '.overlay-dialogue-body',
use_default: colorpicker.name === 'value_color'
});
}
jQuery(`#${form_tabs_id}`)
.on('tabsactivate', () => jQuery.colorpicker('hide'))
.on('change', 'input, z-select, .multiselect', () => this.#updateForm());
this.#datasetTabInit();
this.#displayingOptionsTabInit();
this.#updateForm();
}
#datasetTabInit() {
this.#updateDatasetsLabel();
// Initialize vertical accordion.
jQuery(this.#dataset_wrapper)
.on('focus', '.<?= CMultiSelect::ZBX_STYLE_CLASS ?> input.input', function() {
jQuery('#data_sets').zbx_vertical_accordion('expandNth',
jQuery(this).closest('.<?= ZBX_STYLE_LIST_ACCORDION_ITEM ?>').index()
);
})
.on('click', function(e) {
if (!e.target.classList.contains('color-picker-preview')) {
jQuery.colorpicker('hide');
}
if (e.target.classList.contains('js-click-expand')
|| e.target.classList.contains('color-picker-preview')
|| e.target.classList.contains('<?= ZBX_STYLE_BTN_GREY ?>')) {
jQuery('#data_sets').zbx_vertical_accordion('expandNth',
jQuery(e.target).closest('.<?= ZBX_STYLE_LIST_ACCORDION_ITEM ?>').index()