DropZone.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /**
  2. * @class SimpleTasks.ux.DropZone
  3. * @extends Ext.tree.ViewDropZone
  4. * @private
  5. */
  6. Ext.define('SimpleTasks.ux.DropZone', {
  7. extend: 'Ext.tree.ViewDropZone',
  8. handleNodeDrop : function(data, overRecord, position) {
  9. var droppedRecord = data.records[0];
  10. if(droppedRecord instanceof SimpleTasks.model.Task) {
  11. this.cancelExpand();
  12. this.fireViewEvent('taskdrop', droppedRecord, overRecord);
  13. } else if(droppedRecord instanceof SimpleTasks.model.List) {
  14. this.callParent(arguments);
  15. this.fireViewEvent('listdrop', droppedRecord, overRecord, position);
  16. }
  17. },
  18. onNodeOver: function(node, dragZone, e, data) {
  19. var me = this,
  20. view = me.view,
  21. overRecord = view.getRecord(node),
  22. position = me.getPosition(e, node),
  23. targetNode = view.getRecord(node);
  24. // if we're dragging to reorder rows within the List Tree, then call superclass onNodeOver.
  25. // This allows the superclass to show the visual position indicator.
  26. // Otherwise if we're dragging a Task from the Task Grid, do not show the indicator, since we want
  27. // to give the appearance of the dragged record being dropped ON a node, not in between nodes.
  28. if(data.records[0] instanceof SimpleTasks.model.List) {
  29. return me.callParent(arguments);
  30. }
  31. // auto node expand check
  32. this.cancelExpand();
  33. if (position == 'append' && !this.expandProcId && !Ext.Array.contains(data.records, targetNode) && !targetNode.isLeaf() && !targetNode.isExpanded()) {
  34. this.queueExpand(targetNode);
  35. }
  36. me.overRecord = overRecord;
  37. me.valid = true;
  38. return me.dropAllowed;
  39. }
  40. });