Source
xxxxxxxxxx
/*
** 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/>.
**/
/*
* Since function addPopupValues can be defined by several dashboard widgets, the variable addPopupValues should be
* defined in global scope and always re-written with function right before usage. Do this in all widgets where it is
* needed.
*/
let old_addPopupValues = null;
if (typeof addPopupValues === 'undefined') {
window.addPopupValues = null;
}
(function($) {
$.widget('zbx.sortable_tree', $.extend({}, $.ui.sortable.prototype, {
options: {
// jQuery UI sortable options:
cursor: 'grabbing',
placeholder: 'placeholder',
forcePlaceholderSize: true,
toleranceElement: '> div',
forceHelperSize: true,
tolerance: 'intersect',
handle: '.drag-icon',
items: '.tree-item',
helper: 'clone',
revert: 10,
opacity: .75,
scrollSpeed: 20,
// Custom options:
parent_change_delay: 0,
parent_expand_delay: 600,
indent_size: 15,
max_depth: 10
},
_create: function() {
$.ui.sortable.prototype._create.apply(this, arguments);
},
_mouseDrag: function(event) {
const opt = this.options;
// Compute the helpers position.
this.position = this._generatePosition(event);
this.positionAbs = this._convertPositionTo('absolute');
if (!this.lastPositionAbs) {
this.lastPositionAbs = this.positionAbs;