Changeset View
Changeset View
Standalone View
Standalone View
webroot/rsrc/js/core/DraggableList.js
Show All 33 Lines | events : [ | ||||
'didCancelDrag', | 'didCancelDrag', | ||||
'didEndDrag', | 'didEndDrag', | ||||
'didDrop', | 'didDrop', | ||||
'didSend', | 'didSend', | ||||
'didReceive'], | 'didReceive'], | ||||
properties : { | properties : { | ||||
findItemsHandler: null, | findItemsHandler: null, | ||||
compareHandler: null, | |||||
canDragX: false, | canDragX: false, | ||||
outerContainer: null, | outerContainer: null, | ||||
hasInfiniteHeight: false | hasInfiniteHeight: false | ||||
}, | }, | ||||
members : { | members : { | ||||
_root : null, | _root : null, | ||||
_dragging : null, | _dragging : null, | ||||
▲ Show 20 Lines • Show All 312 Lines • ▼ Show 20 Lines | _clearTarget : function() { | ||||
// Clear the target position cache, since adding or removing ghosts | // Clear the target position cache, since adding or removing ghosts | ||||
// changes element positions. | // changes element positions. | ||||
this._dirtyTargetCache(); | this._dirtyTargetCache(); | ||||
return this; | return this; | ||||
}, | }, | ||||
_getOrderedTarget: function(src_list, src_node) { | |||||
var targets = this._getTargets(); | |||||
// NOTE: The targets are ordered from the bottom of the column to the | |||||
// top, so we're looking for the first node that we sort below. If we | |||||
// don't find one, we'll sort to the head of the column. | |||||
for (var ii = 0; ii < targets.length; ii++) { | |||||
var target = targets[ii]; | |||||
if (this._compareTargets(src_list, src_node, target.item) > 0) { | |||||
return target.item; | |||||
} | |||||
} | |||||
return null; | |||||
}, | |||||
_compareTargets: function(src_list, src_node, dst_node) { | |||||
var dst_list = this; | |||||
return this.getCompareHandler()(src_list, src_node, dst_list, dst_node); | |||||
}, | |||||
_getCurrentTarget : function(p) { | _getCurrentTarget : function(p) { | ||||
var ghost = this.getGhostNode(); | |||||
var targets = this._getTargets(); | var targets = this._getTargets(); | ||||
var dragging = this._dragging; | var dragging = this._dragging; | ||||
// Find the node we're dragging the object underneath. This is the first | // Find the node we're dragging the object underneath. This is the first | ||||
// node in the list that's above the cursor. If that node is the node | // node in the list that's above the cursor. If that node is the node | ||||
// we're dragging or its predecessor, don't select a target, because the | // we're dragging or its predecessor, don't select a target, because the | ||||
// operation would be a no-op. | // operation would be a no-op. | ||||
▲ Show 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | _onmove : function(e) { | ||||
var p = JX.$V(this._cursorPosition.x, this._cursorPosition.y); | var p = JX.$V(this._cursorPosition.x, this._cursorPosition.y); | ||||
var group = this._group; | var group = this._group; | ||||
var target_list = this._getTargetList(p); | var target_list = this._getTargetList(p); | ||||
// Compute the size and position of the drop target indicator, because we | // Compute the size and position of the drop target indicator, because we | ||||
// need to update our static position computations to account for it. | // need to update our static position computations to account for it. | ||||
var compare_handler = this.getCompareHandler(); | |||||
var cur_target = false; | var cur_target = false; | ||||
if (target_list) { | if (target_list) { | ||||
if (compare_handler && (target_list !== this)) { | |||||
cur_target = target_list._getOrderedTarget(this, this._dragging); | |||||
} else { | |||||
cur_target = target_list._getCurrentTarget(p); | cur_target = target_list._getCurrentTarget(p); | ||||
} | } | ||||
} | |||||
// If we've selected a new target, update the UI to show where we're | // If we've selected a new target, update the UI to show where we're | ||||
// going to drop the row. | // going to drop the row. | ||||
for (var ii = 0; ii < group.length; ii++) { | for (var ii = 0; ii < group.length; ii++) { | ||||
if (group[ii] == target_list) { | if (group[ii] == target_list) { | ||||
group[ii]._setTarget(cur_target); | group[ii]._setTarget(cur_target); | ||||
} else { | } else { | ||||
▲ Show 20 Lines • Show All 283 Lines • Show Last 20 Lines |