614da503ddba106b2503cd2b666a046be7213c60.svn-base 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * Ext JS Library 2.0 Copyright(c) 2006-2007, Ext JS, LLC. licensing@extjs.com
  3. *
  4. * http://extjs.com/license
  5. */
  6. /**
  7. * @class Ext.tree.TreeDragZone
  8. * @extends Ext.dd.DragZone
  9. * @constructor
  10. * @param {String/HTMLElement/Element}
  11. * tree The {@link Ext.tree.TreePanel} for which to enable dragging
  12. * @param {Object}
  13. * config
  14. */
  15. if (Ext.dd.DragZone) {
  16. Ext.tree.TreeDragZone = function(tree, config) {
  17. Ext.tree.TreeDragZone.superclass.constructor.call(this, tree
  18. .getTreeEl(), config);
  19. /**
  20. * The TreePanel for this drag zone
  21. *
  22. * @type Ext.tree.TreePanel
  23. * @property
  24. */
  25. this.tree = tree;
  26. };
  27. Ext.extend(Ext.tree.TreeDragZone, Ext.dd.DragZone, {
  28. /**
  29. * @cfg {String} ddGroup A named drag drop group to which this
  30. * object belongs. If a group is specified, then this
  31. * object will only interact with other drag drop objects
  32. * in the same group (defaults to 'TreeDD').
  33. */
  34. ddGroup : "TreeDD",
  35. // private
  36. onBeforeDrag : function(data, e) {
  37. var n = data.node;
  38. return n && n.draggable && !n.disabled;
  39. },
  40. // private
  41. onInitDrag : function(e) {
  42. var data = this.dragData;
  43. this.tree.getSelectionModel().select(data.node);
  44. this.tree.eventModel.disable();
  45. this.proxy.update("");
  46. data.node.ui.appendDDGhost(this.proxy.ghost.dom);
  47. this.tree.fireEvent("startdrag", this.tree, data.node, e);
  48. },
  49. // private
  50. getRepairXY : function(e, data) {
  51. return data.node.ui.getDDRepairXY();
  52. },
  53. // private
  54. onEndDrag : function(data, e) {
  55. this.tree.eventModel.enable
  56. .defer(100, this.tree.eventModel);
  57. this.tree.fireEvent("enddrag", this.tree, data.node, e);
  58. },
  59. // private
  60. onValidDrop : function(dd, e, id) {
  61. this.tree.fireEvent("dragdrop", this.tree,
  62. this.dragData.node, dd, e);
  63. this.hideProxy();
  64. },
  65. // private
  66. beforeInvalidDrop : function(e, id) {
  67. // this scrolls the original position back into view
  68. var sm = this.tree.getSelectionModel();
  69. sm.clearSelections();
  70. sm.select(this.dragData.node);
  71. }
  72. });
  73. }