Changeset View
Changeset View
Standalone View
Standalone View
webroot/rsrc/js/core/DraggableList.js
| Show All 39 Lines | JX.install('DraggableList', { | ||||
| properties : { | properties : { | ||||
| findItemsHandler: null, | findItemsHandler: null, | ||||
| compareHandler: null, | compareHandler: null, | ||||
| isDropTargetHandler: null, | isDropTargetHandler: null, | ||||
| canDragX: false, | canDragX: false, | ||||
| outerContainer: null, | outerContainer: null, | ||||
| hasInfiniteHeight: false, | hasInfiniteHeight: false, | ||||
| compareOnMove: false, | compareOnMove: false, | ||||
| compareOnReorder: false | compareOnReorder: false, | ||||
| targetChangeHandler: null | |||||
| }, | }, | ||||
| members : { | members : { | ||||
| _root : null, | _root : null, | ||||
| _dragging : null, | _dragging : null, | ||||
| _locked : 0, | _locked : 0, | ||||
| _target : null, | _target : null, | ||||
| _lastTarget: null, | |||||
| _targets : null, | _targets : null, | ||||
| _ghostHandler : null, | _ghostHandler : null, | ||||
| _ghostNode : null, | _ghostNode : null, | ||||
| _group : null, | _group : null, | ||||
| _cursorPosition: null, | _cursorPosition: null, | ||||
| _cursorOrigin: null, | _cursorOrigin: null, | ||||
| _cursorScroll: null, | _cursorScroll: null, | ||||
| _frame: null, | _frame: null, | ||||
| ▲ Show 20 Lines • Show All 303 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; | ||||
| }, | }, | ||||
| _didChangeTarget: function(dst_list, dst_node) { | |||||
| if (dst_node === this._lastTarget) { | |||||
| return; | |||||
| } | |||||
| this._lastTarget = dst_node; | |||||
| var handler = this.getTargetChangeHandler(); | |||||
| if (handler) { | |||||
| handler(this, this._dragging, dst_list, dst_node); | |||||
| } | |||||
| }, | |||||
| _setIsDropTarget: function(is_target) { | _setIsDropTarget: function(is_target) { | ||||
| var root = this.getRootNode(); | var root = this.getRootNode(); | ||||
| JX.DOM.alterClass(root, 'drag-target-list', is_target); | JX.DOM.alterClass(root, 'drag-target-list', is_target); | ||||
| var handler = this.getIsDropTargetHandler(); | var handler = this.getIsDropTargetHandler(); | ||||
| if (handler) { | if (handler) { | ||||
| handler(is_target); | handler(is_target); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 152 Lines • ▼ Show 20 Lines | _onmove : function(e) { | ||||
| 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 { | ||||
| group[ii]._clearTarget(); | group[ii]._clearTarget(); | ||||
| } | } | ||||
| } | } | ||||
| this._didChangeTarget(target_list, cur_target); | |||||
| this._updateAutoscroll(this._cursorPosition); | this._updateAutoscroll(this._cursorPosition); | ||||
| var f = JX.$V(this._frame); | var f = JX.$V(this._frame); | ||||
| p.x -= f.x; | p.x -= f.x; | ||||
| p.y -= f.y; | p.y -= f.y; | ||||
| p.y += this._offset.y; | p.y += this._offset.y; | ||||
| this._clone.style.top = p.y + 'px'; | this._clone.style.top = p.y + 'px'; | ||||
| ▲ Show 20 Lines • Show All 117 Lines • ▼ Show 20 Lines | _drop: function(cursor) { | ||||
| } | } | ||||
| var group = this._group; | var group = this._group; | ||||
| for (var ii = 0; ii < group.length; ii++) { | for (var ii = 0; ii < group.length; ii++) { | ||||
| group[ii]._setIsDropTarget(false); | group[ii]._setIsDropTarget(false); | ||||
| group[ii]._clearTarget(); | group[ii]._clearTarget(); | ||||
| } | } | ||||
| this._didChangeTarget(null, null); | |||||
| 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); | ||||
| }, | }, | ||||
| _getScrollAnchor: function() { | _getScrollAnchor: function() { | ||||
| // If you drag an item from column "A" into column "B", then move the | // If you drag an item from column "A" into column "B", then move the | ||||
| ▲ Show 20 Lines • Show All 139 Lines • Show Last 20 Lines | |||||