2011-05-31 22:10:30 +02:00
|
|
|
/**
|
2021-06-10 14:54:16 +02:00
|
|
|
* EGroupware egw_dragdrop_dhtmlxmenu - egw action framework
|
2011-05-31 22:10:30 +02:00
|
|
|
*
|
2021-06-10 14:54:16 +02:00
|
|
|
* @link https://www.egroupware.org
|
2011-05-31 22:10:30 +02:00
|
|
|
* @author Andreas Stöckel <as@stylite.de>
|
|
|
|
* @copyright 2011 by Andreas Stöckel
|
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
|
|
|
* @package egw_action
|
|
|
|
*/
|
|
|
|
|
2014-03-04 10:10:58 +01:00
|
|
|
/*egw:uses
|
|
|
|
egw_action;
|
|
|
|
*/
|
2021-06-14 13:45:57 +02:00
|
|
|
import {egwActionObjectInterface} from "./egw_action.js";
|
2021-06-12 11:44:17 +02:00
|
|
|
import {egwBitIsSet} from "./egw_action_common.js";
|
2021-06-14 13:45:57 +02:00
|
|
|
import {EGW_AI_DRAG_OUT, EGW_AI_DRAG_OVER, EGW_AO_STATE_FOCUSED, EGW_AO_STATE_SELECTED} from "./egw_action_constants.js";
|
2021-06-10 14:54:16 +02:00
|
|
|
|
2011-05-31 22:10:30 +02:00
|
|
|
/**
|
|
|
|
* This file contains an egw_actionObjectInterface which allows a dhtmlx tree
|
|
|
|
* row to be a drag target and contains a function which transforms a complete
|
|
|
|
* dhtmlx tree into egw_actionObjects
|
|
|
|
*/
|
|
|
|
|
2021-06-10 14:54:16 +02:00
|
|
|
export function dhtmlxTree_getNode(_tree, _itemId) {
|
2011-05-31 22:10:30 +02:00
|
|
|
var node = _tree._globalIdStorageFind(_itemId);
|
|
|
|
if (node != null)
|
|
|
|
{
|
|
|
|
// Get the outer html table node of the tree node - return the first
|
|
|
|
// "tr" child of the element
|
2022-09-02 22:37:35 +02:00
|
|
|
return jQuery("tr:first", node.htmlNode).get(0);
|
2011-05-31 22:10:30 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// An action object interface for an dhtmlxTree entry - it only contains the
|
|
|
|
// code needed for drag/drop handling
|
2021-06-10 14:54:16 +02:00
|
|
|
export function dhtmlxtreeItemAOI(_tree, _itemId)
|
2011-05-31 22:10:30 +02:00
|
|
|
{
|
|
|
|
var aoi = new egwActionObjectInterface();
|
|
|
|
|
|
|
|
// Retrieve the actual node from the tree
|
|
|
|
aoi.node = dhtmlxTree_getNode(_tree, _itemId);
|
2013-04-09 17:43:42 +02:00
|
|
|
aoi.id = _itemId;
|
2011-05-31 22:10:30 +02:00
|
|
|
aoi.doGetDOMNode = function() {
|
|
|
|
return aoi.node;
|
|
|
|
}
|
|
|
|
|
|
|
|
aoi.doTriggerEvent = function(_event) {
|
|
|
|
if (_event == EGW_AI_DRAG_OVER)
|
|
|
|
{
|
2016-06-02 16:51:15 +02:00
|
|
|
jQuery(this.node).addClass("draggedOver");
|
2011-05-31 22:10:30 +02:00
|
|
|
}
|
|
|
|
if (_event == EGW_AI_DRAG_OUT)
|
|
|
|
{
|
2016-06-02 16:51:15 +02:00
|
|
|
jQuery(this.node).removeClass("draggedOver");
|
2011-05-31 22:10:30 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-29 01:11:58 +02:00
|
|
|
aoi.doSetState = function(_state) {
|
|
|
|
if(!_tree || !_tree.focusItem) return;
|
|
|
|
|
|
|
|
// Update the "focused" flag
|
|
|
|
if(egwBitIsSet(_state, EGW_AO_STATE_FOCUSED))
|
|
|
|
{
|
|
|
|
_tree.focusItem(this.id);
|
|
|
|
}
|
|
|
|
if(egwBitIsSet(_state, EGW_AO_STATE_SELECTED))
|
|
|
|
{
|
|
|
|
_tree.selectItem(this.id, false); // false = do not trigger onSelect
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-31 22:10:30 +02:00
|
|
|
return aoi;
|
|
|
|
}
|
|
|
|
|