You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

135 lines
6.2 KiB

2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>The source code</title>
  6. <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  7. <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  8. <style type="text/css">
  9. .highlight { display: block; background-color: #ddd; }
  10. </style>
  11. <script type="text/javascript">
  12. function highlight() {
  13. document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
  14. }
  15. </script>
  16. </head>
  17. <body onload="prettyPrint(); highlight();">
  18. <pre class="prettyprint lang-js"><span id='Ext-dd-DropTarget-method-constructor'><span id='Ext-dd-DropTarget'>/**
  19. </span></span> * @class Ext.dd.DropTarget
  20. * @extends Ext.dd.DDTarget
  21. * A simple class that provides the basic implementation needed to make any element a drop target that can have
  22. * draggable items dropped onto it. The drop has no effect until an implementation of notifyDrop is provided.
  23. * @constructor
  24. * @param {Mixed} el The container element
  25. * @param {Object} config
  26. */
  27. Ext.dd.DropTarget = Ext.extend(Ext.dd.DDTarget, {
  28. constructor : function(el, config){
  29. this.el = Ext.get(el);
  30. Ext.apply(this, config);
  31. if(this.containerScroll){
  32. Ext.dd.ScrollManager.register(this.el);
  33. }
  34. Ext.dd.DropTarget.superclass.constructor.call(this, this.el.dom, this.ddGroup || this.group,
  35. {isTarget: true});
  36. },
  37. <span id='Ext-dd-DropTarget-cfg-ddGroup'> /**
  38. </span> * @cfg {String} ddGroup
  39. * A named drag drop group to which this object belongs. If a group is specified, then this object will only
  40. * interact with other drag drop objects in the same group (defaults to undefined).
  41. */
  42. <span id='Ext-dd-DropTarget-cfg-overClass'> /**
  43. </span> * @cfg {String} overClass
  44. * The CSS class applied to the drop target element while the drag source is over it (defaults to &quot;&quot;).
  45. */
  46. <span id='Ext-dd-DropTarget-cfg-dropAllowed'> /**
  47. </span> * @cfg {String} dropAllowed
  48. * The CSS class returned to the drag source when drop is allowed (defaults to &quot;x-dd-drop-ok&quot;).
  49. */
  50. dropAllowed : &quot;x-dd-drop-ok&quot;,
  51. <span id='Ext-dd-DropTarget-cfg-dropNotAllowed'> /**
  52. </span> * @cfg {String} dropNotAllowed
  53. * The CSS class returned to the drag source when drop is not allowed (defaults to &quot;x-dd-drop-nodrop&quot;).
  54. */
  55. dropNotAllowed : &quot;x-dd-drop-nodrop&quot;,
  56. <span id='Ext-dd-DropTarget-property-isTarget'> // private
  57. </span> isTarget : true,
  58. <span id='Ext-dd-DropTarget-property-isNotifyTarget'> // private
  59. </span> isNotifyTarget : true,
  60. <span id='Ext-dd-DropTarget-method-notifyEnter'> /**
  61. </span> * The function a {@link Ext.dd.DragSource} calls once to notify this drop target that the source is now over the
  62. * target. This default implementation adds the CSS class specified by overClass (if any) to the drop element
  63. * and returns the dropAllowed config value. This method should be overridden if drop validation is required.
  64. * @param {Ext.dd.DragSource} source The drag source that was dragged over this drop target
  65. * @param {Event} e The event
  66. * @param {Object} data An object containing arbitrary data supplied by the drag source
  67. * @return {String} status The CSS class that communicates the drop status back to the source so that the
  68. * underlying {@link Ext.dd.StatusProxy} can be updated
  69. */
  70. notifyEnter : function(dd, e, data){
  71. if(this.overClass){
  72. this.el.addClass(this.overClass);
  73. }
  74. return this.dropAllowed;
  75. },
  76. <span id='Ext-dd-DropTarget-method-notifyOver'> /**
  77. </span> * The function a {@link Ext.dd.DragSource} calls continuously while it is being dragged over the target.
  78. * This method will be called on every mouse movement while the drag source is over the drop target.
  79. * This default implementation simply returns the dropAllowed config value.
  80. * @param {Ext.dd.DragSource} source The drag source that was dragged over this drop target
  81. * @param {Event} e The event
  82. * @param {Object} data An object containing arbitrary data supplied by the drag source
  83. * @return {String} status The CSS class that communicates the drop status back to the source so that the
  84. * underlying {@link Ext.dd.StatusProxy} can be updated
  85. */
  86. notifyOver : function(dd, e, data){
  87. return this.dropAllowed;
  88. },
  89. <span id='Ext-dd-DropTarget-method-notifyOut'> /**
  90. </span> * The function a {@link Ext.dd.DragSource} calls once to notify this drop target that the source has been dragged
  91. * out of the target without dropping. This default implementation simply removes the CSS class specified by
  92. * overClass (if any) from the drop element.
  93. * @param {Ext.dd.DragSource} source The drag source that was dragged over this drop target
  94. * @param {Event} e The event
  95. * @param {Object} data An object containing arbitrary data supplied by the drag source
  96. */
  97. notifyOut : function(dd, e, data){
  98. if(this.overClass){
  99. this.el.removeClass(this.overClass);
  100. }
  101. },
  102. <span id='Ext-dd-DropTarget-method-notifyDrop'> /**
  103. </span> * The function a {@link Ext.dd.DragSource} calls once to notify this drop target that the dragged item has
  104. * been dropped on it. This method has no default implementation and returns false, so you must provide an
  105. * implementation that does something to process the drop event and returns true so that the drag source's
  106. * repair action does not run.
  107. * @param {Ext.dd.DragSource} source The drag source that was dragged over this drop target
  108. * @param {Event} e The event
  109. * @param {Object} data An object containing arbitrary data supplied by the drag source
  110. * @return {Boolean} True if the drop was valid, else false
  111. */
  112. notifyDrop : function(dd, e, data){
  113. return false;
  114. },
  115. <span id='Ext-dd-DropTarget-method-destroy'> destroy : function(){
  116. </span> Ext.dd.DropTarget.superclass.destroy.call(this);
  117. if(this.containerScroll){
  118. Ext.dd.ScrollManager.unregister(this.el);
  119. }
  120. }
  121. });</pre>
  122. </body>
  123. </html>