Source
xxxxxxxxxx
/*
** Zabbix
** Copyright (C) 2001-2022 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
/*
* 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) {
var o = this.options,
prev_offset_top;
// Compute the helpers position.
this.position = this._generatePosition(event);
this.positionAbs = this._convertPositionTo('absolute');
if (!this.lastPositionAbs) {
this.lastPositionAbs = this.positionAbs;
}
// Do scrolling.
if (this.options.scroll) {
if (this.scrollParent[0] != document && this.scrollParent[0].tagName != 'HTML') {
if ((this.overflowOffset.top + this.scrollParent[0].offsetHeight)
- event.pageY < o.scrollSensitivity) {
this.scrollParent[0].scrollTop = this.scrollParent[0].scrollTop + o.scrollSpeed;
}
else if (event.pageY - this.overflowOffset.top < o.scrollSensitivity) {
this.scrollParent[0].scrollTop = this.scrollParent[0].scrollTop - o.scrollSpeed;
}
if ((this.overflowOffset.left + this.scrollParent[0].offsetWidth)
- event.pageX < o.scrollSensitivity) {
this.scrollParent[0].scrollLeft = this.scrollParent[0].scrollLeft + o.scrollSpeed;
}
else if (event.pageX - this.overflowOffset.left < o.scrollSensitivity) {
this.scrollParent[0].scrollLeft = this.scrollParent[0].scrollLeft - o.scrollSpeed;
}
}