Changeset View
Changeset View
Standalone View
Standalone View
webroot/rsrc/js/core/DraggableList.js
Show All 34 Lines | events : [ | ||||
'didEndDrag', | 'didEndDrag', | ||||
'didDrop', | 'didDrop', | ||||
'didSend', | 'didSend', | ||||
'didReceive'], | 'didReceive'], | ||||
properties : { | properties : { | ||||
findItemsHandler: null, | findItemsHandler: null, | ||||
compareHandler: null, | compareHandler: null, | ||||
isDropTargetHandler: 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 262 Lines • ▼ Show 20 Lines | _getTargetList : function(p) { | ||||
var is_target = false; | var is_target = false; | ||||
if (p.x >= rp.x && p.y >= rp.y) { | if (p.x >= rp.x && p.y >= rp.y) { | ||||
if (p.x <= (rp.x + rd.x) && p.y <= (rp.y + rd.y)) { | if (p.x <= (rp.x + rd.x) && p.y <= (rp.y + rd.y)) { | ||||
is_target = true; | is_target = true; | ||||
target_list = group[ii]; | target_list = group[ii]; | ||||
} | } | ||||
} | } | ||||
JX.DOM.alterClass(root, 'drag-target-list', is_target); | group[ii]._setIsDropTarget(is_target); | ||||
} | } | ||||
} else { | } else { | ||||
target_list = this; | target_list = this; | ||||
} | } | ||||
return target_list; | return target_list; | ||||
}, | }, | ||||
Show All 33 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; | ||||
}, | }, | ||||
_setIsDropTarget: function(is_target) { | |||||
var root = this.getRootNode(); | |||||
JX.DOM.alterClass(root, 'drag-target-list', is_target); | |||||
var handler = this.getIsDropTargetHandler(); | |||||
if (handler) { | |||||
handler(is_target); | |||||
} | |||||
return this; | |||||
}, | |||||
_getOrderedTarget: function(src_list, src_node) { | _getOrderedTarget: function(src_list, src_node) { | ||||
var targets = this._getTargets(); | var targets = this._getTargets(); | ||||
// NOTE: The targets are ordered from the bottom of the column to the | // 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 | // 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. | // don't find one, we'll sort to the head of the column. | ||||
for (var ii = 0; ii < targets.length; ii++) { | for (var ii = 0; ii < targets.length; ii++) { | ||||
▲ Show 20 Lines • Show All 249 Lines • ▼ Show 20 Lines | _drop: function(cursor) { | ||||
JX.DOM.replace(ghost, dragging); | JX.DOM.replace(ghost, dragging); | ||||
this.invoke('didSend', dragging, target_list); | this.invoke('didSend', dragging, target_list); | ||||
target_list.invoke('didReceive', dragging, this); | target_list.invoke('didReceive', dragging, this); | ||||
target_list.invoke('didDrop', dragging, target, this); | target_list.invoke('didDrop', dragging, target, this); | ||||
} | } | ||||
var group = this._group; | var group = this._group; | ||||
for (var ii = 0; ii < group.length; ii++) { | for (var ii = 0; ii < group.length; ii++) { | ||||
JX.DOM.alterClass(group[ii].getRootNode(), 'drag-target-list', false); | group[ii]._setIsDropTarget(false); | ||||
group[ii]._clearTarget(); | group[ii]._clearTarget(); | ||||
} | } | ||||
JX.DOM.alterClass(dragging, 'drag-dragging', false); | JX.DOM.alterClass(dragging, 'drag-dragging', false); | ||||
JX.Tooltip.unlock(); | JX.Tooltip.unlock(); | ||||
this.invoke('didEndDrag', dragging); | this.invoke('didEndDrag', dragging); | ||||
}, | }, | ||||
▲ Show 20 Lines • Show All 142 Lines • Show Last 20 Lines |