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.

3194 lines
112 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">/*
  19. * These classes are derivatives of the similarly named classes in the YUI Library.
  20. * The original license:
  21. * Copyright (c) 2006, Yahoo! Inc. All rights reserved.
  22. * Code licensed under the BSD License:
  23. * http://developer.yahoo.net/yui/license.txt
  24. */
  25. (function() {
  26. var Event=Ext.EventManager;
  27. var Dom=Ext.lib.Dom;
  28. <span id='Ext-dd-DragDrop-method-constructor'><span id='Ext-dd-DragDrop'>/**
  29. </span></span> * @class Ext.dd.DragDrop
  30. * Defines the interface and base operation of items that that can be
  31. * dragged or can be drop targets. It was designed to be extended, overriding
  32. * the event handlers for startDrag, onDrag, onDragOver and onDragOut.
  33. * Up to three html elements can be associated with a DragDrop instance:
  34. * &lt;ul&gt;
  35. * &lt;li&gt;linked element: the element that is passed into the constructor.
  36. * This is the element which defines the boundaries for interaction with
  37. * other DragDrop objects.&lt;/li&gt;
  38. * &lt;li&gt;handle element(s): The drag operation only occurs if the element that
  39. * was clicked matches a handle element. By default this is the linked
  40. * element, but there are times that you will want only a portion of the
  41. * linked element to initiate the drag operation, and the setHandleElId()
  42. * method provides a way to define this.&lt;/li&gt;
  43. * &lt;li&gt;drag element: this represents the element that would be moved along
  44. * with the cursor during a drag operation. By default, this is the linked
  45. * element itself as in {@link Ext.dd.DD}. setDragElId() lets you define
  46. * a separate element that would be moved, as in {@link Ext.dd.DDProxy}.
  47. * &lt;/li&gt;
  48. * &lt;/ul&gt;
  49. * This class should not be instantiated until the onload event to ensure that
  50. * the associated elements are available.
  51. * The following would define a DragDrop obj that would interact with any
  52. * other DragDrop obj in the &quot;group1&quot; group:
  53. * &lt;pre&gt;
  54. * dd = new Ext.dd.DragDrop(&quot;div1&quot;, &quot;group1&quot;);
  55. * &lt;/pre&gt;
  56. * Since none of the event handlers have been implemented, nothing would
  57. * actually happen if you were to run the code above. Normally you would
  58. * override this class or one of the default implementations, but you can
  59. * also override the methods you want on an instance of the class...
  60. * &lt;pre&gt;
  61. * dd.onDragDrop = function(e, id) {
  62. * &amp;nbsp;&amp;nbsp;alert(&quot;dd was dropped on &quot; + id);
  63. * }
  64. * &lt;/pre&gt;
  65. * @constructor
  66. * @param {String} id of the element that is linked to this instance
  67. * @param {String} sGroup the group of related DragDrop objects
  68. * @param {object} config an object containing configurable attributes
  69. * Valid properties for DragDrop:
  70. * padding, isTarget, maintainOffset, primaryButtonOnly
  71. */
  72. Ext.dd.DragDrop = function(id, sGroup, config) {
  73. if(id) {
  74. this.init(id, sGroup, config);
  75. }
  76. };
  77. Ext.dd.DragDrop.prototype = {
  78. <span id='Ext-dd-DragDrop-property-ignoreSelf'> /**
  79. </span> * Set to false to enable a DragDrop object to fire drag events while dragging
  80. * over its own Element. Defaults to true - DragDrop objects do not by default
  81. * fire drag events to themselves.
  82. * @property ignoreSelf
  83. * @type Boolean
  84. */
  85. <span id='Ext-dd-DragDrop-property-id'> /**
  86. </span> * The id of the element associated with this object. This is what we
  87. * refer to as the &quot;linked element&quot; because the size and position of
  88. * this element is used to determine when the drag and drop objects have
  89. * interacted.
  90. * @property id
  91. * @type String
  92. */
  93. id: null,
  94. <span id='Ext-dd-DragDrop-property-config'> /**
  95. </span> * Configuration attributes passed into the constructor
  96. * @property config
  97. * @type object
  98. */
  99. config: null,
  100. <span id='Ext-dd-DragDrop-property-dragElId'> /**
  101. </span> * The id of the element that will be dragged. By default this is same
  102. * as the linked element, but could be changed to another element. Ex:
  103. * Ext.dd.DDProxy
  104. * @property dragElId
  105. * @type String
  106. * @private
  107. */
  108. dragElId: null,
  109. <span id='Ext-dd-DragDrop-property-handleElId'> /**
  110. </span> * The ID of the element that initiates the drag operation. By default
  111. * this is the linked element, but could be changed to be a child of this
  112. * element. This lets us do things like only starting the drag when the
  113. * header element within the linked html element is clicked.
  114. * @property handleElId
  115. * @type String
  116. * @private
  117. */
  118. handleElId: null,
  119. <span id='Ext-dd-DragDrop-property-invalidHandleTypes'> /**
  120. </span> * An object who's property names identify HTML tags to be considered invalid as drag handles.
  121. * A non-null property value identifies the tag as invalid. Defaults to the
  122. * following value which prevents drag operations from being initiated by &amp;lt;a&gt; elements:&lt;pre&gt;&lt;code&gt;
  123. {
  124. A: &quot;A&quot;
  125. }&lt;/code&gt;&lt;/pre&gt;
  126. * @property invalidHandleTypes
  127. * @type Object
  128. */
  129. invalidHandleTypes: null,
  130. <span id='Ext-dd-DragDrop-property-invalidHandleIds'> /**
  131. </span> * An object who's property names identify the IDs of elements to be considered invalid as drag handles.
  132. * A non-null property value identifies the ID as invalid. For example, to prevent
  133. * dragging from being initiated on element ID &quot;foo&quot;, use:&lt;pre&gt;&lt;code&gt;
  134. {
  135. foo: true
  136. }&lt;/code&gt;&lt;/pre&gt;
  137. * @property invalidHandleIds
  138. * @type Object
  139. */
  140. invalidHandleIds: null,
  141. <span id='Ext-dd-DragDrop-property-invalidHandleClasses'> /**
  142. </span> * An Array of CSS class names for elements to be considered in valid as drag handles.
  143. * @property invalidHandleClasses
  144. * @type Array
  145. */
  146. invalidHandleClasses: null,
  147. <span id='Ext-dd-DragDrop-property-startPageX'> /**
  148. </span> * The linked element's absolute X position at the time the drag was
  149. * started
  150. * @property startPageX
  151. * @type int
  152. * @private
  153. */
  154. startPageX: 0,
  155. <span id='Ext-dd-DragDrop-property-startPageY'> /**
  156. </span> * The linked element's absolute X position at the time the drag was
  157. * started
  158. * @property startPageY
  159. * @type int
  160. * @private
  161. */
  162. startPageY: 0,
  163. <span id='Ext-dd-DragDrop-property-groups'> /**
  164. </span> * The group defines a logical collection of DragDrop objects that are
  165. * related. Instances only get events when interacting with other
  166. * DragDrop object in the same group. This lets us define multiple
  167. * groups using a single DragDrop subclass if we want.
  168. * @property groups
  169. * @type object An object in the format {'group1':true, 'group2':true}
  170. */
  171. groups: null,
  172. <span id='Ext-dd-DragDrop-property-locked'> /**
  173. </span> * Individual drag/drop instances can be locked. This will prevent
  174. * onmousedown start drag.
  175. * @property locked
  176. * @type boolean
  177. * @private
  178. */
  179. locked: false,
  180. <span id='Ext-dd-DragDrop-method-lock'> /**
  181. </span> * Lock this instance
  182. * @method lock
  183. */
  184. lock: function() {
  185. this.locked = true;
  186. },
  187. <span id='Ext-dd-DragDrop-property-moveOnly'> /**
  188. </span> * When set to true, other DD objects in cooperating DDGroups do not receive
  189. * notification events when this DD object is dragged over them. Defaults to false.
  190. * @property moveOnly
  191. * @type boolean
  192. */
  193. moveOnly: false,
  194. <span id='Ext-dd-DragDrop-method-unlock'> /**
  195. </span> * Unlock this instace
  196. * @method unlock
  197. */
  198. unlock: function() {
  199. this.locked = false;
  200. },
  201. <span id='Ext-dd-DragDrop-property-isTarget'> /**
  202. </span> * By default, all instances can be a drop target. This can be disabled by
  203. * setting isTarget to false.
  204. * @property isTarget
  205. * @type boolean
  206. */
  207. isTarget: true,
  208. <span id='Ext-dd-DragDrop-property-padding'> /**
  209. </span> * The padding configured for this drag and drop object for calculating
  210. * the drop zone intersection with this object.
  211. * @property padding
  212. * @type int[] An array containing the 4 padding values: [top, right, bottom, left]
  213. */
  214. padding: null,
  215. <span id='Ext-dd-DragDrop-property-_domRef'> /**
  216. </span> * Cached reference to the linked element
  217. * @property _domRef
  218. * @private
  219. */
  220. _domRef: null,
  221. <span id='Ext-dd-DragDrop-property-__ygDragDrop'> /**
  222. </span> * Internal typeof flag
  223. * @property __ygDragDrop
  224. * @private
  225. */
  226. __ygDragDrop: true,
  227. <span id='Ext-dd-DragDrop-property-constrainX'> /**
  228. </span> * Set to true when horizontal contraints are applied
  229. * @property constrainX
  230. * @type boolean
  231. * @private
  232. */
  233. constrainX: false,
  234. <span id='Ext-dd-DragDrop-property-constrainY'> /**
  235. </span> * Set to true when vertical contraints are applied
  236. * @property constrainY
  237. * @type boolean
  238. * @private
  239. */
  240. constrainY: false,
  241. <span id='Ext-dd-DragDrop-property-minX'> /**
  242. </span> * The left constraint
  243. * @property minX
  244. * @type int
  245. * @private
  246. */
  247. minX: 0,
  248. <span id='Ext-dd-DragDrop-property-maxX'> /**
  249. </span> * The right constraint
  250. * @property maxX
  251. * @type int
  252. * @private
  253. */
  254. maxX: 0,
  255. <span id='Ext-dd-DragDrop-property-minY'> /**
  256. </span> * The up constraint
  257. * @property minY
  258. * @type int
  259. * @private
  260. */
  261. minY: 0,
  262. <span id='Ext-dd-DragDrop-property-maxY'> /**
  263. </span> * The down constraint
  264. * @property maxY
  265. * @type int
  266. * @private
  267. */
  268. maxY: 0,
  269. <span id='Ext-dd-DragDrop-property-maintainOffset'> /**
  270. </span> * Maintain offsets when we resetconstraints. Set to true when you want
  271. * the position of the element relative to its parent to stay the same
  272. * when the page changes
  273. *
  274. * @property maintainOffset
  275. * @type boolean
  276. */
  277. maintainOffset: false,
  278. <span id='Ext-dd-DragDrop-property-xTicks'> /**
  279. </span> * Array of pixel locations the element will snap to if we specified a
  280. * horizontal graduation/interval. This array is generated automatically
  281. * when you define a tick interval.
  282. * @property xTicks
  283. * @type int[]
  284. */
  285. xTicks: null,
  286. <span id='Ext-dd-DragDrop-property-yTicks'> /**
  287. </span> * Array of pixel locations the element will snap to if we specified a
  288. * vertical graduation/interval. This array is generated automatically
  289. * when you define a tick interval.
  290. * @property yTicks
  291. * @type int[]
  292. */
  293. yTicks: null,
  294. <span id='Ext-dd-DragDrop-property-primaryButtonOnly'> /**
  295. </span> * By default the drag and drop instance will only respond to the primary
  296. * button click (left button for a right-handed mouse). Set to true to
  297. * allow drag and drop to start with any mouse click that is propogated
  298. * by the browser
  299. * @property primaryButtonOnly
  300. * @type boolean
  301. */
  302. primaryButtonOnly: true,
  303. <span id='Ext-dd-DragDrop-property-available'> /**
  304. </span> * The available property is false until the linked dom element is accessible.
  305. * @property available
  306. * @type boolean
  307. */
  308. available: false,
  309. <span id='Ext-dd-DragDrop-property-hasOuterHandles'> /**
  310. </span> * By default, drags can only be initiated if the mousedown occurs in the
  311. * region the linked element is. This is done in part to work around a
  312. * bug in some browsers that mis-report the mousedown if the previous
  313. * mouseup happened outside of the window. This property is set to true
  314. * if outer handles are defined.
  315. *
  316. * @property hasOuterHandles
  317. * @type boolean
  318. * @default false
  319. */
  320. hasOuterHandles: false,
  321. <span id='Ext-dd-DragDrop-method-b4StartDrag'> /**
  322. </span> * Code that executes immediately before the startDrag event
  323. * @method b4StartDrag
  324. * @private
  325. */
  326. b4StartDrag: function(x, y) { },
  327. <span id='Ext-dd-DragDrop-method-startDrag'> /**
  328. </span> * Abstract method called after a drag/drop object is clicked
  329. * and the drag or mousedown time thresholds have beeen met.
  330. * @method startDrag
  331. * @param {int} X click location
  332. * @param {int} Y click location
  333. */
  334. startDrag: function(x, y) { /* override this */ },
  335. <span id='Ext-dd-DragDrop-method-b4Drag'> /**
  336. </span> * Code that executes immediately before the onDrag event
  337. * @method b4Drag
  338. * @private
  339. */
  340. b4Drag: function(e) { },
  341. <span id='Ext-dd-DragDrop-method-onDrag'> /**
  342. </span> * Abstract method called during the onMouseMove event while dragging an
  343. * object.
  344. * @method onDrag
  345. * @param {Event} e the mousemove event
  346. */
  347. onDrag: function(e) { /* override this */ },
  348. <span id='Ext-dd-DragDrop-method-onDragEnter'> /**
  349. </span> * Abstract method called when this element fist begins hovering over
  350. * another DragDrop obj
  351. * @method onDragEnter
  352. * @param {Event} e the mousemove event
  353. * @param {String|DragDrop[]} id In POINT mode, the element
  354. * id this is hovering over. In INTERSECT mode, an array of one or more
  355. * dragdrop items being hovered over.
  356. */
  357. onDragEnter: function(e, id) { /* override this */ },
  358. <span id='Ext-dd-DragDrop-method-b4DragOver'> /**
  359. </span> * Code that executes immediately before the onDragOver event
  360. * @method b4DragOver
  361. * @private
  362. */
  363. b4DragOver: function(e) { },
  364. <span id='Ext-dd-DragDrop-method-onDragOver'> /**
  365. </span> * Abstract method called when this element is hovering over another
  366. * DragDrop obj
  367. * @method onDragOver
  368. * @param {Event} e the mousemove event
  369. * @param {String|DragDrop[]} id In POINT mode, the element
  370. * id this is hovering over. In INTERSECT mode, an array of dd items
  371. * being hovered over.
  372. */
  373. onDragOver: function(e, id) { /* override this */ },
  374. <span id='Ext-dd-DragDrop-method-b4DragOut'> /**
  375. </span> * Code that executes immediately before the onDragOut event
  376. * @method b4DragOut
  377. * @private
  378. */
  379. b4DragOut: function(e) { },
  380. <span id='Ext-dd-DragDrop-method-onDragOut'> /**
  381. </span> * Abstract method called when we are no longer hovering over an element
  382. * @method onDragOut
  383. * @param {Event} e the mousemove event
  384. * @param {String|DragDrop[]} id In POINT mode, the element
  385. * id this was hovering over. In INTERSECT mode, an array of dd items
  386. * that the mouse is no longer over.
  387. */
  388. onDragOut: function(e, id) { /* override this */ },
  389. <span id='Ext-dd-DragDrop-method-b4DragDrop'> /**
  390. </span> * Code that executes immediately before the onDragDrop event
  391. * @method b4DragDrop
  392. * @private
  393. */
  394. b4DragDrop: function(e) { },
  395. <span id='Ext-dd-DragDrop-method-onDragDrop'> /**
  396. </span> * Abstract method called when this item is dropped on another DragDrop
  397. * obj
  398. * @method onDragDrop
  399. * @param {Event} e the mouseup event
  400. * @param {String|DragDrop[]} id In POINT mode, the element
  401. * id this was dropped on. In INTERSECT mode, an array of dd items this
  402. * was dropped on.
  403. */
  404. onDragDrop: function(e, id) { /* override this */ },
  405. <span id='Ext-dd-DragDrop-method-onInvalidDrop'> /**
  406. </span> * Abstract method called when this item is dropped on an area with no
  407. * drop target
  408. * @method onInvalidDrop
  409. * @param {Event} e the mouseup event
  410. */
  411. onInvalidDrop: function(e) { /* override this */ },
  412. <span id='Ext-dd-DragDrop-method-b4EndDrag'> /**
  413. </span> * Code that executes immediately before the endDrag event
  414. * @method b4EndDrag
  415. * @private
  416. */
  417. b4EndDrag: function(e) { },
  418. <span id='Ext-dd-DragDrop-method-endDrag'> /**
  419. </span> * Fired when we are done dragging the object
  420. * @method endDrag
  421. * @param {Event} e the mouseup event
  422. */
  423. endDrag: function(e) { /* override this */ },
  424. <span id='Ext-dd-DragDrop-method-b4MouseDown'> /**
  425. </span> * Code executed immediately before the onMouseDown event
  426. * @method b4MouseDown
  427. * @param {Event} e the mousedown event
  428. * @private
  429. */
  430. b4MouseDown: function(e) { },
  431. <span id='Ext-dd-DragDrop-method-onMouseDown'> /**
  432. </span> * Event handler that fires when a drag/drop obj gets a mousedown
  433. * @method onMouseDown
  434. * @param {Event} e the mousedown event
  435. */
  436. onMouseDown: function(e) { /* override this */ },
  437. <span id='Ext-dd-DragDrop-method-onMouseUp'> /**
  438. </span> * Event handler that fires when a drag/drop obj gets a mouseup
  439. * @method onMouseUp
  440. * @param {Event} e the mouseup event
  441. */
  442. onMouseUp: function(e) { /* override this */ },
  443. <span id='Ext-dd-DragDrop-method-onAvailable'> /**
  444. </span> * Override the onAvailable method to do what is needed after the initial
  445. * position was determined.
  446. * @method onAvailable
  447. */
  448. onAvailable: function () {
  449. },
  450. <span id='Ext-dd-DragDrop-property-defaultPadding'> /**
  451. </span> * Provides default constraint padding to &quot;constrainTo&quot; elements (defaults to {left: 0, right:0, top:0, bottom:0}).
  452. * @type Object
  453. */
  454. defaultPadding : {left:0, right:0, top:0, bottom:0},
  455. <span id='Ext-dd-DragDrop-method-constrainTo'> /**
  456. </span> * Initializes the drag drop object's constraints to restrict movement to a certain element.
  457. *
  458. * Usage:
  459. &lt;pre&gt;&lt;code&gt;
  460. var dd = new Ext.dd.DDProxy(&quot;dragDiv1&quot;, &quot;proxytest&quot;,
  461. { dragElId: &quot;existingProxyDiv&quot; });
  462. dd.startDrag = function(){
  463. this.constrainTo(&quot;parent-id&quot;);
  464. };
  465. &lt;/code&gt;&lt;/pre&gt;
  466. * Or you can initalize it using the {@link Ext.Element} object:
  467. &lt;pre&gt;&lt;code&gt;
  468. Ext.get(&quot;dragDiv1&quot;).initDDProxy(&quot;proxytest&quot;, {dragElId: &quot;existingProxyDiv&quot;}, {
  469. startDrag : function(){
  470. this.constrainTo(&quot;parent-id&quot;);
  471. }
  472. });
  473. &lt;/code&gt;&lt;/pre&gt;
  474. * @param {Mixed} constrainTo The element to constrain to.
  475. * @param {Object/Number} pad (optional) Pad provides a way to specify &quot;padding&quot; of the constraints,
  476. * and can be either a number for symmetrical padding (4 would be equal to {left:4, right:4, top:4, bottom:4}) or
  477. * an object containing the sides to pad. For example: {right:10, bottom:10}
  478. * @param {Boolean} inContent (optional) Constrain the draggable in the content box of the element (inside padding and borders)
  479. */
  480. constrainTo : function(constrainTo, pad, inContent){
  481. if(Ext.isNumber(pad)){
  482. pad = {left: pad, right:pad, top:pad, bottom:pad};
  483. }
  484. pad = pad || this.defaultPadding;
  485. var b = Ext.get(this.getEl()).getBox(),
  486. ce = Ext.get(constrainTo),
  487. s = ce.getScroll(),
  488. c,
  489. cd = ce.dom;
  490. if(cd == document.body){
  491. c = { x: s.left, y: s.top, width: Ext.lib.Dom.getViewWidth(), height: Ext.lib.Dom.getViewHeight()};
  492. }else{
  493. var xy = ce.getXY();
  494. c = {x : xy[0], y: xy[1], width: cd.clientWidth, height: cd.clientHeight};
  495. }
  496. var topSpace = b.y - c.y,
  497. leftSpace = b.x - c.x;
  498. this.resetConstraints();
  499. this.setXConstraint(leftSpace - (pad.left||0), // left
  500. c.width - leftSpace - b.width - (pad.right||0), //right
  501. this.xTickSize
  502. );
  503. this.setYConstraint(topSpace - (pad.top||0), //top
  504. c.height - topSpace - b.height - (pad.bottom||0), //bottom
  505. this.yTickSize
  506. );
  507. },
  508. <span id='Ext-dd-DragDrop-method-getEl'> /**
  509. </span> * Returns a reference to the linked element
  510. * @method getEl
  511. * @return {HTMLElement} the html element
  512. */
  513. getEl: function() {
  514. if (!this._domRef) {
  515. this._domRef = Ext.getDom(this.id);
  516. }
  517. return this._domRef;
  518. },
  519. <span id='Ext-dd-DragDrop-method-getDragEl'> /**
  520. </span> * Returns a reference to the actual element to drag. By default this is
  521. * the same as the html element, but it can be assigned to another
  522. * element. An example of this can be found in Ext.dd.DDProxy
  523. * @method getDragEl
  524. * @return {HTMLElement} the html element
  525. */
  526. getDragEl: function() {
  527. return Ext.getDom(this.dragElId);
  528. },
  529. <span id='Ext-dd-DragDrop-method-init'> /**
  530. </span> * Sets up the DragDrop object. Must be called in the constructor of any
  531. * Ext.dd.DragDrop subclass
  532. * @method init
  533. * @param id the id of the linked element
  534. * @param {String} sGroup the group of related items
  535. * @param {object} config configuration attributes
  536. */
  537. init: function(id, sGroup, config) {
  538. this.initTarget(id, sGroup, config);
  539. Event.on(this.id, &quot;mousedown&quot;, this.handleMouseDown, this);
  540. // Event.on(this.id, &quot;selectstart&quot;, Event.preventDefault);
  541. },
  542. <span id='Ext-dd-DragDrop-method-initTarget'> /**
  543. </span> * Initializes Targeting functionality only... the object does not
  544. * get a mousedown handler.
  545. * @method initTarget
  546. * @param id the id of the linked element
  547. * @param {String} sGroup the group of related items
  548. * @param {object} config configuration attributes
  549. */
  550. initTarget: function(id, sGroup, config) {
  551. // configuration attributes
  552. this.config = config || {};
  553. // create a local reference to the drag and drop manager
  554. this.DDM = Ext.dd.DDM;
  555. // initialize the groups array
  556. this.groups = {};
  557. // assume that we have an element reference instead of an id if the
  558. // parameter is not a string
  559. if (typeof id !== &quot;string&quot;) {
  560. id = Ext.id(id);
  561. }
  562. // set the id
  563. this.id = id;
  564. // add to an interaction group
  565. this.addToGroup((sGroup) ? sGroup : &quot;default&quot;);
  566. // We don't want to register this as the handle with the manager
  567. // so we just set the id rather than calling the setter.
  568. this.handleElId = id;
  569. // the linked element is the element that gets dragged by default
  570. this.setDragElId(id);
  571. // by default, clicked anchors will not start drag operations.
  572. this.invalidHandleTypes = { A: &quot;A&quot; };
  573. this.invalidHandleIds = {};
  574. this.invalidHandleClasses = [];
  575. this.applyConfig();
  576. this.handleOnAvailable();
  577. },
  578. <span id='Ext-dd-DragDrop-method-applyConfig'> /**
  579. </span> * Applies the configuration parameters that were passed into the constructor.
  580. * This is supposed to happen at each level through the inheritance chain. So
  581. * a DDProxy implentation will execute apply config on DDProxy, DD, and
  582. * DragDrop in order to get all of the parameters that are available in
  583. * each object.
  584. * @method applyConfig
  585. */
  586. applyConfig: function() {
  587. // configurable properties:
  588. // padding, isTarget, maintainOffset, primaryButtonOnly
  589. this.padding = this.config.padding || [0, 0, 0, 0];
  590. this.isTarget = (this.config.isTarget !== false);
  591. this.maintainOffset = (this.config.maintainOffset);
  592. this.primaryButtonOnly = (this.config.primaryButtonOnly !== false);
  593. },
  594. <span id='Ext-dd-DragDrop-method-handleOnAvailable'> /**
  595. </span> * Executed when the linked element is available
  596. * @method handleOnAvailable
  597. * @private
  598. */
  599. handleOnAvailable: function() {
  600. this.available = true;
  601. this.resetConstraints();
  602. this.onAvailable();
  603. },
  604. <span id='Ext-dd-DragDrop-method-setPadding'> /**
  605. </span> * Configures the padding for the target zone in px. Effectively expands
  606. * (or reduces) the virtual object size for targeting calculations.
  607. * Supports css-style shorthand; if only one parameter is passed, all sides
  608. * will have that padding, and if only two are passed, the top and bottom
  609. * will have the first param, the left and right the second.
  610. * @method setPadding
  611. * @param {int} iTop Top pad
  612. * @param {int} iRight Right pad
  613. * @param {int} iBot Bot pad
  614. * @param {int} iLeft Left pad
  615. */
  616. setPadding: function(iTop, iRight, iBot, iLeft) {
  617. // this.padding = [iLeft, iRight, iTop, iBot];
  618. if (!iRight &amp;&amp; 0 !== iRight) {
  619. this.padding = [iTop, iTop, iTop, iTop];
  620. } else if (!iBot &amp;&amp; 0 !== iBot) {
  621. this.padding = [iTop, iRight, iTop, iRight];
  622. } else {
  623. this.padding = [iTop, iRight, iBot, iLeft];
  624. }
  625. },
  626. <span id='Ext-dd-DragDrop-method-setInitPosition'> /**
  627. </span> * Stores the initial placement of the linked element.
  628. * @method setInitPosition
  629. * @param {int} diffX the X offset, default 0
  630. * @param {int} diffY the Y offset, default 0
  631. */
  632. setInitPosition: function(diffX, diffY) {
  633. var el = this.getEl();
  634. if (!this.DDM.verifyEl(el)) {
  635. return;
  636. }
  637. var dx = diffX || 0;
  638. var dy = diffY || 0;
  639. var p = Dom.getXY( el );
  640. this.initPageX = p[0] - dx;
  641. this.initPageY = p[1] - dy;
  642. this.lastPageX = p[0];
  643. this.lastPageY = p[1];
  644. this.setStartPosition(p);
  645. },
  646. <span id='Ext-dd-DragDrop-method-setStartPosition'> /**
  647. </span> * Sets the start position of the element. This is set when the obj
  648. * is initialized, the reset when a drag is started.
  649. * @method setStartPosition
  650. * @param pos current position (from previous lookup)
  651. * @private
  652. */
  653. setStartPosition: function(pos) {
  654. var p = pos || Dom.getXY( this.getEl() );
  655. this.deltaSetXY = null;
  656. this.startPageX = p[0];
  657. this.startPageY = p[1];
  658. },
  659. <span id='Ext-dd-DragDrop-method-addToGroup'> /**
  660. </span> * Add this instance to a group of related drag/drop objects. All
  661. * instances belong to at least one group, and can belong to as many
  662. * groups as needed.
  663. * @method addToGroup
  664. * @param sGroup {string} the name of the group
  665. */
  666. addToGroup: function(sGroup) {
  667. this.groups[sGroup] = true;
  668. this.DDM.regDragDrop(this, sGroup);
  669. },
  670. <span id='Ext-dd-DragDrop-method-removeFromGroup'> /**
  671. </span> * Remove's this instance from the supplied interaction group
  672. * @method removeFromGroup
  673. * @param {string} sGroup The group to drop
  674. */
  675. removeFromGroup: function(sGroup) {
  676. if (this.groups[sGroup]) {
  677. delete this.groups[sGroup];
  678. }
  679. this.DDM.removeDDFromGroup(this, sGroup);
  680. },
  681. <span id='Ext-dd-DragDrop-method-setDragElId'> /**
  682. </span> * Allows you to specify that an element other than the linked element
  683. * will be moved with the cursor during a drag
  684. * @method setDragElId
  685. * @param id {string} the id of the element that will be used to initiate the drag
  686. */
  687. setDragElId: function(id) {
  688. this.dragElId = id;
  689. },
  690. <span id='Ext-dd-DragDrop-method-setHandleElId'> /**
  691. </span> * Allows you to specify a child of the linked element that should be
  692. * used to initiate the drag operation. An example of this would be if
  693. * you have a content div with text and links. Clicking anywhere in the
  694. * content area would normally start the drag operation. Use this method
  695. * to specify that an element inside of the content div is the element
  696. * that starts the drag operation.
  697. * @method setHandleElId
  698. * @param id {string} the id of the element that will be used to
  699. * initiate the drag.
  700. */
  701. setHandleElId: function(id) {
  702. if (typeof id !== &quot;string&quot;) {
  703. id = Ext.id(id);
  704. }
  705. this.handleElId = id;
  706. this.DDM.regHandle(this.id, id);
  707. },
  708. <span id='Ext-dd-DragDrop-method-setOuterHandleElId'> /**
  709. </span> * Allows you to set an element outside of the linked element as a drag
  710. * handle
  711. * @method setOuterHandleElId
  712. * @param id the id of the element that will be used to initiate the drag
  713. */
  714. setOuterHandleElId: function(id) {
  715. if (typeof id !== &quot;string&quot;) {
  716. id = Ext.id(id);
  717. }
  718. Event.on(id, &quot;mousedown&quot;,
  719. this.handleMouseDown, this);
  720. this.setHandleElId(id);
  721. this.hasOuterHandles = true;
  722. },
  723. <span id='Ext-dd-DragDrop-method-unreg'> /**
  724. </span> * Remove all drag and drop hooks for this element
  725. * @method unreg
  726. */
  727. unreg: function() {
  728. Event.un(this.id, &quot;mousedown&quot;,
  729. this.handleMouseDown);
  730. this._domRef = null;
  731. this.DDM._remove(this);
  732. },
  733. destroy : function(){
  734. this.unreg();
  735. },
  736. <span id='Ext-dd-DragDrop-method-isLocked'> /**
  737. </span> * Returns true if this instance is locked, or the drag drop mgr is locked
  738. * (meaning that all drag/drop is disabled on the page.)
  739. * @method isLocked
  740. * @return {boolean} true if this obj or all drag/drop is locked, else
  741. * false
  742. */
  743. isLocked: function() {
  744. return (this.DDM.isLocked() || this.locked);
  745. },
  746. <span id='Ext-dd-DragDrop-method-handleMouseDown'> /**
  747. </span> * Fired when this object is clicked
  748. * @method handleMouseDown
  749. * @param {Event} e
  750. * @param {Ext.dd.DragDrop} oDD the clicked dd object (this dd obj)
  751. * @private
  752. */
  753. handleMouseDown: function(e, oDD){
  754. if (this.primaryButtonOnly &amp;&amp; e.button != 0) {
  755. return;
  756. }
  757. if (this.isLocked()) {
  758. return;
  759. }
  760. this.DDM.refreshCache(this.groups);
  761. var pt = new Ext.lib.Point(Ext.lib.Event.getPageX(e), Ext.lib.Event.getPageY(e));
  762. if (!this.hasOuterHandles &amp;&amp; !this.DDM.isOverTarget(pt, this) ) {
  763. } else {
  764. if (this.clickValidator(e)) {
  765. // set the initial element position
  766. this.setStartPosition();
  767. this.b4MouseDown(e);
  768. this.onMouseDown(e);
  769. this.DDM.handleMouseDown(e, this);
  770. if (this.preventDefault || this.stopPropagation) {
  771. if (this.preventDefault) {
  772. e.preventDefault();
  773. }
  774. if (this.stopPropagation) {
  775. e.stopPropagation();
  776. }
  777. } else {
  778. this.DDM.stopEvent(e);
  779. }
  780. } else {
  781. }
  782. }
  783. },
  784. clickValidator: function(e) {
  785. var target = e.getTarget();
  786. return ( this.isValidHandleChild(target) &amp;&amp;
  787. (this.id == this.handleElId ||
  788. this.DDM.handleWasClicked(target, this.id)) );
  789. },
  790. <span id='Ext-dd-DragDrop-method-addInvalidHandleType'> /**
  791. </span> * Allows you to specify a tag name that should not start a drag operation
  792. * when clicked. This is designed to facilitate embedding links within a
  793. * drag handle that do something other than start the drag.
  794. * @method addInvalidHandleType
  795. * @param {string} tagName the type of element to exclude
  796. */
  797. addInvalidHandleType: function(tagName) {
  798. var type = tagName.toUpperCase();
  799. this.invalidHandleTypes[type] = type;
  800. },
  801. <span id='Ext-dd-DragDrop-method-addInvalidHandleId'> /**
  802. </span> * Lets you to specify an element id for a child of a drag handle
  803. * that should not initiate a drag
  804. * @method addInvalidHandleId
  805. * @param {string} id the element id of the element you wish to ignore
  806. */
  807. addInvalidHandleId: function(id) {
  808. if (typeof id !== &quot;string&quot;) {
  809. id = Ext.id(id);
  810. }
  811. this.invalidHandleIds[id] = id;
  812. },
  813. <span id='Ext-dd-DragDrop-method-addInvalidHandleClass'> /**
  814. </span> * Lets you specify a css class of elements that will not initiate a drag
  815. * @method addInvalidHandleClass
  816. * @param {string} cssClass the class of the elements you wish to ignore
  817. */
  818. addInvalidHandleClass: function(cssClass) {
  819. this.invalidHandleClasses.push(cssClass);
  820. },
  821. <span id='Ext-dd-DragDrop-method-removeInvalidHandleType'> /**
  822. </span> * Unsets an excluded tag name set by addInvalidHandleType
  823. * @method removeInvalidHandleType
  824. * @param {string} tagName the type of element to unexclude
  825. */
  826. removeInvalidHandleType: function(tagName) {
  827. var type = tagName.toUpperCase();
  828. // this.invalidHandleTypes[type] = null;
  829. delete this.invalidHandleTypes[type];
  830. },
  831. <span id='Ext-dd-DragDrop-method-removeInvalidHandleId'> /**
  832. </span> * Unsets an invalid handle id
  833. * @method removeInvalidHandleId
  834. * @param {string} id the id of the element to re-enable
  835. */
  836. removeInvalidHandleId: function(id) {
  837. if (typeof id !== &quot;string&quot;) {
  838. id = Ext.id(id);
  839. }
  840. delete this.invalidHandleIds[id];
  841. },
  842. <span id='Ext-dd-DragDrop-method-removeInvalidHandleClass'> /**
  843. </span> * Unsets an invalid css class
  844. * @method removeInvalidHandleClass
  845. * @param {string} cssClass the class of the element(s) you wish to
  846. * re-enable
  847. */
  848. removeInvalidHandleClass: function(cssClass) {
  849. for (var i=0, len=this.invalidHandleClasses.length; i&lt;len; ++i) {
  850. if (this.invalidHandleClasses[i] == cssClass) {
  851. delete this.invalidHandleClasses[i];
  852. }
  853. }
  854. },
  855. <span id='Ext-dd-DragDrop-method-isValidHandleChild'> /**
  856. </span> * Checks the tag exclusion list to see if this click should be ignored
  857. * @method isValidHandleChild
  858. * @param {HTMLElement} node the HTMLElement to evaluate
  859. * @return {boolean} true if this is a valid tag type, false if not
  860. */
  861. isValidHandleChild: function(node) {
  862. var valid = true;
  863. // var n = (node.nodeName == &quot;#text&quot;) ? node.parentNode : node;
  864. var nodeName;
  865. try {
  866. nodeName = node.nodeName.toUpperCase();
  867. } catch(e) {
  868. nodeName = node.nodeName;
  869. }
  870. valid = valid &amp;&amp; !this.invalidHandleTypes[nodeName];
  871. valid = valid &amp;&amp; !this.invalidHandleIds[node.id];
  872. for (var i=0, len=this.invalidHandleClasses.length; valid &amp;&amp; i&lt;len; ++i) {
  873. valid = !Ext.fly(node).hasClass(this.invalidHandleClasses[i]);
  874. }
  875. return valid;
  876. },
  877. <span id='Ext-dd-DragDrop-method-setXTicks'> /**
  878. </span> * Create the array of horizontal tick marks if an interval was specified
  879. * in setXConstraint().
  880. * @method setXTicks
  881. * @private
  882. */
  883. setXTicks: function(iStartX, iTickSize) {
  884. this.xTicks = [];
  885. this.xTickSize = iTickSize;
  886. var tickMap = {};
  887. for (var i = this.initPageX; i &gt;= this.minX; i = i - iTickSize) {
  888. if (!tickMap[i]) {
  889. this.xTicks[this.xTicks.length] = i;
  890. tickMap[i] = true;
  891. }
  892. }
  893. for (i = this.initPageX; i &lt;= this.maxX; i = i + iTickSize) {
  894. if (!tickMap[i]) {
  895. this.xTicks[this.xTicks.length] = i;
  896. tickMap[i] = true;
  897. }
  898. }
  899. this.xTicks.sort(this.DDM.numericSort) ;
  900. },
  901. <span id='Ext-dd-DragDrop-method-setYTicks'> /**
  902. </span> * Create the array of vertical tick marks if an interval was specified in
  903. * setYConstraint().
  904. * @method setYTicks
  905. * @private
  906. */
  907. setYTicks: function(iStartY, iTickSize) {
  908. this.yTicks = [];
  909. this.yTickSize = iTickSize;
  910. var tickMap = {};
  911. for (var i = this.initPageY; i &gt;= this.minY; i = i - iTickSize) {
  912. if (!tickMap[i]) {
  913. this.yTicks[this.yTicks.length] = i;
  914. tickMap[i] = true;
  915. }
  916. }
  917. for (i = this.initPageY; i &lt;= this.maxY; i = i + iTickSize) {
  918. if (!tickMap[i]) {
  919. this.yTicks[this.yTicks.length] = i;
  920. tickMap[i] = true;
  921. }
  922. }
  923. this.yTicks.sort(this.DDM.numericSort) ;
  924. },
  925. <span id='Ext-dd-DragDrop-method-setXConstraint'> /**
  926. </span> * By default, the element can be dragged any place on the screen. Use
  927. * this method to limit the horizontal travel of the element. Pass in
  928. * 0,0 for the parameters if you want to lock the drag to the y axis.
  929. * @method setXConstraint
  930. * @param {int} iLeft the number of pixels the element can move to the left
  931. * @param {int} iRight the number of pixels the element can move to the
  932. * right
  933. * @param {int} iTickSize optional parameter for specifying that the
  934. * element
  935. * should move iTickSize pixels at a time.
  936. */
  937. setXConstraint: function(iLeft, iRight, iTickSize) {
  938. this.leftConstraint = iLeft;
  939. this.rightConstraint = iRight;
  940. this.minX = this.initPageX - iLeft;
  941. this.maxX = this.initPageX + iRight;
  942. if (iTickSize) { this.setXTicks(this.initPageX, iTickSize); }
  943. this.constrainX = true;
  944. },
  945. <span id='Ext-dd-DragDrop-method-clearConstraints'> /**
  946. </span> * Clears any constraints applied to this instance. Also clears ticks
  947. * since they can't exist independent of a constraint at this time.
  948. * @method clearConstraints
  949. */
  950. clearConstraints: function() {
  951. this.constrainX = false;
  952. this.constrainY = false;
  953. this.clearTicks();
  954. },
  955. <span id='Ext-dd-DragDrop-method-clearTicks'> /**
  956. </span> * Clears any tick interval defined for this instance
  957. * @method clearTicks
  958. */
  959. clearTicks: function() {
  960. this.xTicks = null;
  961. this.yTicks = null;
  962. this.xTickSize = 0;
  963. this.yTickSize = 0;
  964. },
  965. <span id='Ext-dd-DragDrop-method-setYConstraint'> /**
  966. </span> * By default, the element can be dragged any place on the screen. Set
  967. * this to limit the vertical travel of the element. Pass in 0,0 for the
  968. * parameters if you want to lock the drag to the x axis.
  969. * @method setYConstraint
  970. * @param {int} iUp the number of pixels the element can move up
  971. * @param {int} iDown the number of pixels the element can move down
  972. * @param {int} iTickSize optional parameter for specifying that the
  973. * element should move iTickSize pixels at a time.
  974. */
  975. setYConstraint: function(iUp, iDown, iTickSize) {
  976. this.topConstraint = iUp;
  977. this.bottomConstraint = iDown;
  978. this.minY = this.initPageY - iUp;
  979. this.maxY = this.initPageY + iDown;
  980. if (iTickSize) { this.setYTicks(this.initPageY, iTickSize); }
  981. this.constrainY = true;
  982. },
  983. <span id='Ext-dd-DragDrop-method-resetConstraints'> /**
  984. </span> * resetConstraints must be called if you manually reposition a dd element.
  985. * @method resetConstraints
  986. * @param {boolean} maintainOffset
  987. */
  988. resetConstraints: function() {
  989. // Maintain offsets if necessary
  990. if (this.initPageX || this.initPageX === 0) {
  991. // figure out how much this thing has moved
  992. var dx = (this.maintainOffset) ? this.lastPageX - this.initPageX : 0;
  993. var dy = (this.maintainOffset) ? this.lastPageY - this.initPageY : 0;
  994. this.setInitPosition(dx, dy);
  995. // This is the first time we have detected the element's position
  996. } else {
  997. this.setInitPosition();
  998. }
  999. if (this.constrainX) {
  1000. this.setXConstraint( this.leftConstraint,
  1001. this.rightConstraint,
  1002. this.xTickSize );
  1003. }
  1004. if (this.constrainY) {
  1005. this.setYConstraint( this.topConstraint,
  1006. this.bottomConstraint,
  1007. this.yTickSize );
  1008. }
  1009. },
  1010. <span id='Ext-dd-DragDrop-method-getTick'> /**
  1011. </span> * Normally the drag element is moved pixel by pixel, but we can specify
  1012. * that it move a number of pixels at a time. This method resolves the
  1013. * location when we have it set up like this.
  1014. * @method getTick
  1015. * @param {int} val where we want to place the object
  1016. * @param {int[]} tickArray sorted array of valid points
  1017. * @return {int} the closest tick
  1018. * @private
  1019. */
  1020. getTick: function(val, tickArray) {
  1021. if (!tickArray) {
  1022. // If tick interval is not defined, it is effectively 1 pixel,
  1023. // so we return the value passed to us.
  1024. return val;
  1025. } else if (tickArray[0] &gt;= val) {
  1026. // The value is lower than the first tick, so we return the first
  1027. // tick.
  1028. return tickArray[0];
  1029. } else {
  1030. for (var i=0, len=tickArray.length; i&lt;len; ++i) {
  1031. var next = i + 1;
  1032. if (tickArray[next] &amp;&amp; tickArray[next] &gt;= val) {
  1033. var diff1 = val - tickArray[i];
  1034. var diff2 = tickArray[next] - val;
  1035. return (diff2 &gt; diff1) ? tickArray[i] : tickArray[next];
  1036. }
  1037. }
  1038. // The value is larger than the last tick, so we return the last
  1039. // tick.
  1040. return tickArray[tickArray.length - 1];
  1041. }
  1042. },
  1043. <span id='Ext-dd-DragDrop-method-toString'> /**
  1044. </span> * toString method
  1045. * @method toString
  1046. * @return {string} string representation of the dd obj
  1047. */
  1048. toString: function() {
  1049. return (&quot;DragDrop &quot; + this.id);
  1050. }
  1051. };
  1052. })();
  1053. /*
  1054. * The drag and drop utility provides a framework for building drag and drop
  1055. * applications. In addition to enabling drag and drop for specific elements,
  1056. * the drag and drop elements are tracked by the manager class, and the
  1057. * interactions between the various elements are tracked during the drag and
  1058. * the implementing code is notified about these important moments.
  1059. */
  1060. // Only load the library once. Rewriting the manager class would orphan
  1061. // existing drag and drop instances.
  1062. if (!Ext.dd.DragDropMgr) {
  1063. <span id='Ext-dd-DragDropMgr'>/**
  1064. </span> * @class Ext.dd.DragDropMgr
  1065. * DragDropMgr is a singleton that tracks the element interaction for
  1066. * all DragDrop items in the window. Generally, you will not call
  1067. * this class directly, but it does have helper methods that could
  1068. * be useful in your DragDrop implementations.
  1069. * @singleton
  1070. */
  1071. Ext.dd.DragDropMgr = function() {
  1072. var Event = Ext.EventManager;
  1073. return {
  1074. <span id='Ext-dd-DragDropMgr-property-ids'> /**
  1075. </span> * Two dimensional Array of registered DragDrop objects. The first
  1076. * dimension is the DragDrop item group, the second the DragDrop
  1077. * object.
  1078. * @property ids
  1079. * @type String[]
  1080. * @private
  1081. */
  1082. ids: {},
  1083. <span id='Ext-dd-DragDropMgr-property-handleIds'> /**
  1084. </span> * Array of element ids defined as drag handles. Used to determine
  1085. * if the element that generated the mousedown event is actually the
  1086. * handle and not the html element itself.
  1087. * @property handleIds
  1088. * @type String[]
  1089. * @private
  1090. */
  1091. handleIds: {},
  1092. <span id='Ext-dd-DragDropMgr-property-dragCurrent'> /**
  1093. </span> * the DragDrop object that is currently being dragged
  1094. * @property dragCurrent
  1095. * @type DragDrop
  1096. * @private
  1097. **/
  1098. dragCurrent: null,
  1099. <span id='Ext-dd-DragDropMgr-property-dragOvers'> /**
  1100. </span> * the DragDrop object(s) that are being hovered over
  1101. * @property dragOvers
  1102. * @type Array
  1103. * @private
  1104. */
  1105. dragOvers: {},
  1106. <span id='Ext-dd-DragDropMgr-property-deltaX'> /**
  1107. </span> * the X distance between the cursor and the object being dragged
  1108. * @property deltaX
  1109. * @type int
  1110. * @private
  1111. */
  1112. deltaX: 0,
  1113. <span id='Ext-dd-DragDropMgr-property-deltaY'> /**
  1114. </span> * the Y distance between the cursor and the object being dragged
  1115. * @property deltaY
  1116. * @type int
  1117. * @private
  1118. */
  1119. deltaY: 0,
  1120. <span id='Ext-dd-DragDropMgr-property-preventDefault'> /**
  1121. </span> * Flag to determine if we should prevent the default behavior of the
  1122. * events we define. By default this is true, but this can be set to
  1123. * false if you need the default behavior (not recommended)
  1124. * @property preventDefault
  1125. * @type boolean
  1126. */
  1127. preventDefault: true,
  1128. <span id='Ext-dd-DragDropMgr-property-stopPropagation'> /**
  1129. </span> * Flag to determine if we should stop the propagation of the events
  1130. * we generate. This is true by default but you may want to set it to
  1131. * false if the html element contains other features that require the
  1132. * mouse click.
  1133. * @property stopPropagation
  1134. * @type boolean
  1135. */
  1136. stopPropagation: true,
  1137. <span id='Ext-dd-DragDropMgr-property-initialized'> /**
  1138. </span> * Internal flag that is set to true when drag and drop has been
  1139. * intialized
  1140. * @property initialized
  1141. * @private
  1142. */
  1143. initialized: false,
  1144. <span id='Ext-dd-DragDropMgr-property-locked'> /**
  1145. </span> * All drag and drop can be disabled.
  1146. * @property locked
  1147. * @private
  1148. */
  1149. locked: false,
  1150. <span id='Ext-dd-DragDropMgr-method-init'> /**
  1151. </span> * Called the first time an element is registered.
  1152. * @method init
  1153. * @private
  1154. */
  1155. init: function() {
  1156. this.initialized = true;
  1157. },
  1158. <span id='Ext-dd-DragDropMgr-property-POINT'> /**
  1159. </span> * In point mode, drag and drop interaction is defined by the
  1160. * location of the cursor during the drag/drop
  1161. * @property POINT
  1162. * @type int
  1163. */
  1164. POINT: 0,
  1165. <span id='Ext-dd-DragDropMgr-property-INTERSECT'> /**
  1166. </span> * In intersect mode, drag and drop interaction is defined by the
  1167. * overlap of two or more drag and drop objects.
  1168. * @property INTERSECT
  1169. * @type int
  1170. */
  1171. INTERSECT: 1,
  1172. <span id='Ext-dd-DragDropMgr-property-mode'> /**
  1173. </span> * The current drag and drop mode. Default: POINT
  1174. * @property mode
  1175. * @type int
  1176. */
  1177. mode: 0,
  1178. <span id='Ext-dd-DragDropMgr-property-notifyOccluded'> /**
  1179. </span> * @property {Boolean} [notifyOccluded=false]
  1180. * This config is only provided to provide old, usually unwanted drag/drop behaviour.
  1181. *
  1182. * From ExtJS 4.1.0 onwards, when drop targets are contained in floating, absolutely positioned elements
  1183. * such as in {@link Ext.window.Window Windows}, which may overlap each other, `over` and `drop` events
  1184. * are only delivered to the topmost drop target at the mouse position.
  1185. *
  1186. * If all targets below that in zIndex order should also receive notifications, set
  1187. * `notifyOccluded` to `true`.
  1188. */
  1189. notifyOccluded: false,
  1190. <span id='Ext-dd-DragDropMgr-method-_execOnAll'> /**
  1191. </span> * Runs method on all drag and drop objects
  1192. * @method _execOnAll
  1193. * @private
  1194. */
  1195. _execOnAll: function(sMethod, args) {
  1196. for (var i in this.ids) {
  1197. for (var j in this.ids[i]) {
  1198. var oDD = this.ids[i][j];
  1199. if (! this.isTypeOfDD(oDD)) {
  1200. continue;
  1201. }
  1202. oDD[sMethod].apply(oDD, args);
  1203. }
  1204. }
  1205. },
  1206. <span id='Ext-dd-DragDropMgr-method-_onLoad'> /**
  1207. </span> * Drag and drop initialization. Sets up the global event handlers
  1208. * @method _onLoad
  1209. * @private
  1210. */
  1211. _onLoad: function() {
  1212. this.init();
  1213. Event.on(document, &quot;mouseup&quot;, this.handleMouseUp, this, true);
  1214. Event.on(document, &quot;mousemove&quot;, this.handleMouseMove, this, true);
  1215. Event.on(window, &quot;unload&quot;, this._onUnload, this, true);
  1216. Event.on(window, &quot;resize&quot;, this._onResize, this, true);
  1217. // Event.on(window, &quot;mouseout&quot;, this._test);
  1218. },
  1219. <span id='Ext-dd-DragDropMgr-method-_onResize'> /**
  1220. </span> * Reset constraints on all drag and drop objs
  1221. * @method _onResize
  1222. * @private
  1223. */
  1224. _onResize: function(e) {
  1225. this._execOnAll(&quot;resetConstraints&quot;, []);
  1226. },
  1227. <span id='Ext-dd-DragDropMgr-method-lock'> /**
  1228. </span> * Lock all drag and drop functionality
  1229. * @method lock
  1230. */
  1231. lock: function() { this.locked = true; },
  1232. <span id='Ext-dd-DragDropMgr-method-unlock'> /**
  1233. </span> * Unlock all drag and drop functionality
  1234. * @method unlock
  1235. */
  1236. unlock: function() { this.locked = false; },
  1237. <span id='Ext-dd-DragDropMgr-method-isLocked'> /**
  1238. </span> * Is drag and drop locked?
  1239. * @method isLocked
  1240. * @return {boolean} True if drag and drop is locked, false otherwise.
  1241. */
  1242. isLocked: function() { return this.locked; },
  1243. <span id='Ext-dd-DragDropMgr-property-locationCache'> /**
  1244. </span> * Location cache that is set for all drag drop objects when a drag is
  1245. * initiated, cleared when the drag is finished.
  1246. * @property locationCache
  1247. * @private
  1248. */
  1249. locationCache: {},
  1250. <span id='Ext-dd-DragDropMgr-property-useCache'> /**
  1251. </span> * Set useCache to false if you want to force object the lookup of each
  1252. * drag and drop linked element constantly during a drag.
  1253. * @property useCache
  1254. * @type boolean
  1255. */
  1256. useCache: true,
  1257. <span id='Ext-dd-DragDropMgr-property-clickPixelThresh'> /**
  1258. </span> * The number of pixels that the mouse needs to move after the
  1259. * mousedown before the drag is initiated. Default=3;
  1260. * @property clickPixelThresh
  1261. * @type int
  1262. */
  1263. clickPixelThresh: 3,
  1264. <span id='Ext-dd-DragDropMgr-property-clickTimeThresh'> /**
  1265. </span> * The number of milliseconds after the mousedown event to initiate the
  1266. * drag if we don't get a mouseup event. Default=350
  1267. * @property clickTimeThresh
  1268. * @type int
  1269. */
  1270. clickTimeThresh: 350,
  1271. <span id='Ext-dd-DragDropMgr-property-dragThreshMet'> /**
  1272. </span> * Flag that indicates that either the drag pixel threshold or the
  1273. * mousdown time threshold has been met
  1274. * @property dragThreshMet
  1275. * @type boolean
  1276. * @private
  1277. */
  1278. dragThreshMet: false,
  1279. <span id='Ext-dd-DragDropMgr-property-clickTimeout'> /**
  1280. </span> * Timeout used for the click time threshold
  1281. * @property clickTimeout
  1282. * @type Object
  1283. * @private
  1284. */
  1285. clickTimeout: null,
  1286. <span id='Ext-dd-DragDropMgr-property-startX'> /**
  1287. </span> * The X position of the mousedown event stored for later use when a
  1288. * drag threshold is met.
  1289. * @property startX
  1290. * @type int
  1291. * @private
  1292. */
  1293. startX: 0,
  1294. <span id='Ext-dd-DragDropMgr-property-startY'> /**
  1295. </span> * The Y position of the mousedown event stored for later use when a
  1296. * drag threshold is met.
  1297. * @property startY
  1298. * @type int
  1299. * @private
  1300. */
  1301. startY: 0,
  1302. <span id='Ext-dd-DragDropMgr-method-regDragDrop'> /**
  1303. </span> * Each DragDrop instance must be registered with the DragDropMgr.
  1304. * This is executed in DragDrop.init()
  1305. * @method regDragDrop
  1306. * @param {DragDrop} oDD the DragDrop object to register
  1307. * @param {String} sGroup the name of the group this element belongs to
  1308. */
  1309. regDragDrop: function(oDD, sGroup) {
  1310. if (!this.initialized) { this.init(); }
  1311. if (!this.ids[sGroup]) {
  1312. this.ids[sGroup] = {};
  1313. }
  1314. this.ids[sGroup][oDD.id] = oDD;
  1315. },
  1316. <span id='Ext-dd-DragDropMgr-method-removeDDFromGroup'> /**
  1317. </span> * Removes the supplied dd instance from the supplied group. Executed
  1318. * by DragDrop.removeFromGroup, so don't call this function directly.
  1319. * @method removeDDFromGroup
  1320. * @private
  1321. */
  1322. removeDDFromGroup: function(oDD, sGroup) {
  1323. if (!this.ids[sGroup]) {
  1324. this.ids[sGroup] = {};
  1325. }
  1326. var obj = this.ids[sGroup];
  1327. if (obj &amp;&amp; obj[oDD.id]) {
  1328. delete obj[oDD.id];
  1329. }
  1330. },
  1331. <span id='Ext-dd-DragDropMgr-method-_remove'> /**
  1332. </span> * Unregisters a drag and drop item. This is executed in
  1333. * DragDrop.unreg, use that method instead of calling this directly.
  1334. * @method _remove
  1335. * @private
  1336. */
  1337. _remove: function(oDD) {
  1338. for (var g in oDD.groups) {
  1339. if (g &amp;&amp; this.ids[g] &amp;&amp; this.ids[g][oDD.id]) {
  1340. delete this.ids[g][oDD.id];
  1341. }
  1342. }
  1343. delete this.handleIds[oDD.id];
  1344. },
  1345. <span id='Ext-dd-DragDropMgr-method-regHandle'> /**
  1346. </span> * Each DragDrop handle element must be registered. This is done
  1347. * automatically when executing DragDrop.setHandleElId()
  1348. * @method regHandle
  1349. * @param {String} sDDId the DragDrop id this element is a handle for
  1350. * @param {String} sHandleId the id of the element that is the drag
  1351. * handle
  1352. */
  1353. regHandle: function(sDDId, sHandleId) {
  1354. if (!this.handleIds[sDDId]) {
  1355. this.handleIds[sDDId] = {};
  1356. }
  1357. this.handleIds[sDDId][sHandleId] = sHandleId;
  1358. },
  1359. <span id='Ext-dd-DragDropMgr-method-isDragDrop'> /**
  1360. </span> * Utility function to determine if a given element has been
  1361. * registered as a drag drop item.
  1362. * @method isDragDrop
  1363. * @param {String} id the element id to check
  1364. * @return {boolean} true if this element is a DragDrop item,
  1365. * false otherwise
  1366. */
  1367. isDragDrop: function(id) {
  1368. return ( this.getDDById(id) ) ? true : false;
  1369. },
  1370. <span id='Ext-dd-DragDropMgr-method-getRelated'> /**
  1371. </span> * Returns the drag and drop instances that are in all groups the
  1372. * passed in instance belongs to.
  1373. * @method getRelated
  1374. * @param {DragDrop} p_oDD the obj to get related data for
  1375. * @param {boolean} bTargetsOnly if true, only return targetable objs
  1376. * @return {DragDrop[]} the related instances
  1377. */
  1378. getRelated: function(p_oDD, bTargetsOnly) {
  1379. var oDDs = [];
  1380. for (var i in p_oDD.groups) {
  1381. for (var j in this.ids[i]) {
  1382. var dd = this.ids[i][j];
  1383. if (! this.isTypeOfDD(dd)) {
  1384. continue;
  1385. }
  1386. if (!bTargetsOnly || dd.isTarget) {
  1387. oDDs[oDDs.length] = dd;
  1388. }
  1389. }
  1390. }
  1391. return oDDs;
  1392. },
  1393. <span id='Ext-dd-DragDropMgr-method-isLegalTarget'> /**
  1394. </span> * Returns true if the specified dd target is a legal target for
  1395. * the specifice drag obj
  1396. * @method isLegalTarget
  1397. * @param {DragDrop} oDD the drag obj
  1398. * @param {DragDrop} oTargetDD the target
  1399. * @return {boolean} true if the target is a legal target for the
  1400. * dd obj
  1401. */
  1402. isLegalTarget: function (oDD, oTargetDD) {
  1403. var targets = this.getRelated(oDD, true);
  1404. for (var i=0, len=targets.length;i&lt;len;++i) {
  1405. if (targets[i].id == oTargetDD.id) {
  1406. return true;
  1407. }
  1408. }
  1409. return false;
  1410. },
  1411. <span id='Ext-dd-DragDropMgr-method-isTypeOfDD'> /**
  1412. </span> * My goal is to be able to transparently determine if an object is
  1413. * typeof DragDrop, and the exact subclass of DragDrop. typeof
  1414. * returns &quot;object&quot;, oDD.constructor.toString() always returns
  1415. * &quot;DragDrop&quot; and not the name of the subclass. So for now it just
  1416. * evaluates a well-known variable in DragDrop.
  1417. * @method isTypeOfDD
  1418. * @param {Object} the object to evaluate
  1419. * @return {boolean} true if typeof oDD = DragDrop
  1420. */
  1421. isTypeOfDD: function (oDD) {
  1422. return (oDD &amp;&amp; oDD.__ygDragDrop);
  1423. },
  1424. <span id='Ext-dd-DragDropMgr-method-isHandle'> /**
  1425. </span> * Utility function to determine if a given element has been
  1426. * registered as a drag drop handle for the given Drag Drop object.
  1427. * @method isHandle
  1428. * @param {String} id the element id to check
  1429. * @return {boolean} true if this element is a DragDrop handle, false
  1430. * otherwise
  1431. */
  1432. isHandle: function(sDDId, sHandleId) {
  1433. return ( this.handleIds[sDDId] &amp;&amp;
  1434. this.handleIds[sDDId][sHandleId] );
  1435. },
  1436. <span id='Ext-dd-DragDropMgr-method-getDDById'> /**
  1437. </span> * Returns the DragDrop instance for a given id
  1438. * @method getDDById
  1439. * @param {String} id the id of the DragDrop object
  1440. * @return {DragDrop} the drag drop object, null if it is not found
  1441. */
  1442. getDDById: function(id) {
  1443. for (var i in this.ids) {
  1444. if (this.ids[i][id]) {
  1445. return this.ids[i][id];
  1446. }
  1447. }
  1448. return null;
  1449. },
  1450. <span id='Ext-dd-DragDropMgr-method-handleMouseDown'> /**
  1451. </span> * Fired after a registered DragDrop object gets the mousedown event.
  1452. * Sets up the events required to track the object being dragged
  1453. * @method handleMouseDown
  1454. * @param {Event} e the event
  1455. * @param oDD the DragDrop object being dragged
  1456. * @private
  1457. */
  1458. handleMouseDown: function(e, oDD) {
  1459. if(Ext.QuickTips){
  1460. Ext.QuickTips.ddDisable();
  1461. }
  1462. if(this.dragCurrent){
  1463. // the original browser mouseup wasn't handled (e.g. outside FF browser window)
  1464. // so clean up first to avoid breaking the next drag
  1465. this.handleMouseUp(e);
  1466. }
  1467. this.currentTarget = e.getTarget();
  1468. this.dragCurrent = oDD;
  1469. var el = oDD.getEl();
  1470. // track start position
  1471. this.startX = e.getPageX();
  1472. this.startY = e.getPageY();
  1473. this.deltaX = this.startX - el.offsetLeft;
  1474. this.deltaY = this.startY - el.offsetTop;
  1475. this.dragThreshMet = false;
  1476. this.clickTimeout = setTimeout(
  1477. function() {
  1478. var DDM = Ext.dd.DDM;
  1479. DDM.startDrag(DDM.startX, DDM.startY);
  1480. },
  1481. this.clickTimeThresh );
  1482. },
  1483. <span id='Ext-dd-DragDropMgr-method-startDrag'> /**
  1484. </span> * Fired when either the drag pixel threshol or the mousedown hold
  1485. * time threshold has been met.
  1486. * @method startDrag
  1487. * @param x {int} the X position of the original mousedown
  1488. * @param y {int} the Y position of the original mousedown
  1489. */
  1490. startDrag: function(x, y) {
  1491. clearTimeout(this.clickTimeout);
  1492. if (this.dragCurrent) {
  1493. this.dragCurrent.b4StartDrag(x, y);
  1494. this.dragCurrent.startDrag(x, y);
  1495. }
  1496. this.dragThreshMet = true;
  1497. },
  1498. <span id='Ext-dd-DragDropMgr-method-handleMouseUp'> /**
  1499. </span> * Internal function to handle the mouseup event. Will be invoked
  1500. * from the context of the document.
  1501. * @method handleMouseUp
  1502. * @param {Event} e the event
  1503. * @private
  1504. */
  1505. handleMouseUp: function(e) {
  1506. if(Ext.QuickTips){
  1507. Ext.QuickTips.ddEnable();
  1508. }
  1509. if (! this.dragCurrent) {
  1510. return;
  1511. }
  1512. clearTimeout(this.clickTimeout);
  1513. if (this.dragThreshMet) {
  1514. this.fireEvents(e, true);
  1515. } else {
  1516. }
  1517. this.stopDrag(e);
  1518. this.stopEvent(e);
  1519. },
  1520. <span id='Ext-dd-DragDropMgr-method-stopEvent'> /**
  1521. </span> * Utility to stop event propagation and event default, if these
  1522. * features are turned on.
  1523. * @method stopEvent
  1524. * @param {Event} e the event as returned by this.getEvent()
  1525. */
  1526. stopEvent: function(e){
  1527. if(this.stopPropagation) {
  1528. e.stopPropagation();
  1529. }
  1530. if (this.preventDefault) {
  1531. e.preventDefault();
  1532. }
  1533. },
  1534. <span id='Ext-dd-DragDropMgr-method-stopDrag'> /**
  1535. </span> * Internal function to clean up event handlers after the drag
  1536. * operation is complete
  1537. * @method stopDrag
  1538. * @param {Event} e the event
  1539. * @private
  1540. */
  1541. stopDrag: function(e) {
  1542. // Fire the drag end event for the item that was dragged
  1543. if (this.dragCurrent) {
  1544. if (this.dragThreshMet) {
  1545. this.dragCurrent.b4EndDrag(e);
  1546. this.dragCurrent.endDrag(e);
  1547. }
  1548. this.dragCurrent.onMouseUp(e);
  1549. }
  1550. this.dragCurrent = null;
  1551. this.dragOvers = {};
  1552. },
  1553. <span id='Ext-dd-DragDropMgr-method-handleMouseMove'> /**
  1554. </span> * Internal function to handle the mousemove event. Will be invoked
  1555. * from the context of the html element.
  1556. *
  1557. * @TODO figure out what we can do about mouse events lost when the
  1558. * user drags objects beyond the window boundary. Currently we can
  1559. * detect this in internet explorer by verifying that the mouse is
  1560. * down during the mousemove event. Firefox doesn't give us the
  1561. * button state on the mousemove event.
  1562. * @method handleMouseMove
  1563. * @param {Event} e the event
  1564. * @private
  1565. */
  1566. handleMouseMove: function(e) {
  1567. if (! this.dragCurrent) {
  1568. return true;
  1569. }
  1570. // var button = e.which || e.button;
  1571. // check for IE mouseup outside of page boundary
  1572. if (Ext.isIE &amp;&amp; (e.button !== 0 &amp;&amp; e.button !== 1 &amp;&amp; e.button !== 2)) {
  1573. this.stopEvent(e);
  1574. return this.handleMouseUp(e);
  1575. }
  1576. if (!this.dragThreshMet) {
  1577. var diffX = Math.abs(this.startX - e.getPageX());
  1578. var diffY = Math.abs(this.startY - e.getPageY());
  1579. if (diffX &gt; this.clickPixelThresh ||
  1580. diffY &gt; this.clickPixelThresh) {
  1581. this.startDrag(this.startX, this.startY);
  1582. }
  1583. }
  1584. if (this.dragThreshMet) {
  1585. this.dragCurrent.b4Drag(e);
  1586. this.dragCurrent.onDrag(e);
  1587. if(!this.dragCurrent.moveOnly){
  1588. this.fireEvents(e, false);
  1589. }
  1590. }
  1591. this.stopEvent(e);
  1592. return true;
  1593. },
  1594. <span id='Ext-dd-DragDropMgr-method-fireEvents'> /**
  1595. </span> * Iterates over all of the DragDrop elements to find ones we are
  1596. * hovering over or dropping on
  1597. * @method fireEvents
  1598. * @param {Event} e the event
  1599. * @param {boolean} isDrop is this a drop op or a mouseover op?
  1600. * @private
  1601. */
  1602. fireEvents: function(e, isDrop) {
  1603. var me = this,
  1604. dragCurrent = me.dragCurrent,
  1605. mousePoint = e.getPoint(),
  1606. overTarget,
  1607. overTargetEl,
  1608. allTargets = [],
  1609. oldOvers = [], // cache the previous dragOver array
  1610. outEvts = [],
  1611. overEvts = [],
  1612. dropEvts = [],
  1613. enterEvts = [],
  1614. needsSort,
  1615. i,
  1616. len,
  1617. sGroup;
  1618. // If the user did the mouse up outside of the window, we could
  1619. // get here even though we have ended the drag.
  1620. if (!dragCurrent || dragCurrent.isLocked()) {
  1621. return;
  1622. }
  1623. // Check to see if the object(s) we were hovering over is no longer
  1624. // being hovered over so we can fire the onDragOut event
  1625. for (i in me.dragOvers) {
  1626. overTarget = me.dragOvers[i];
  1627. if (! me.isTypeOfDD(overTarget)) {
  1628. continue;
  1629. }
  1630. if (! this.isOverTarget(mousePoint, overTarget, me.mode)) {
  1631. outEvts.push( overTarget );
  1632. }
  1633. oldOvers[i] = true;
  1634. delete me.dragOvers[i];
  1635. }
  1636. // Collect all targets which are members of the same ddGoups that the dragCurrent is a member of, and which may recieve mouseover and drop notifications.
  1637. // This is preparatory to seeing which one(s) we are currently over
  1638. // Begin by iterating through the ddGroups of which the dragCurrent is a member
  1639. for (sGroup in dragCurrent.groups) {
  1640. if (&quot;string&quot; != typeof sGroup) {
  1641. continue;
  1642. }
  1643. // Loop over the registered members of each group, testing each as a potential target
  1644. for (i in me.ids[sGroup]) {
  1645. overTarget = me.ids[sGroup][i];
  1646. // The target is valid if it is a DD type
  1647. // And it's got a DOM element
  1648. // And it's configured to be a drop target
  1649. // And it's not locked
  1650. // And it's either not the dragCurrent, or, if it is, tha dragCurrent is configured to not ignore itself.
  1651. if (me.isTypeOfDD(overTarget) &amp;&amp;
  1652. (overTargetEl = overTarget.getEl()) &amp;&amp;
  1653. (overTarget.isTarget) &amp;&amp;
  1654. (!overTarget.isLocked()) &amp;&amp;
  1655. ((overTarget != dragCurrent) || (dragCurrent.ignoreSelf === false))) {
  1656. // Only sort by zIndex if there were some which had a floating zIndex value
  1657. if ((overTarget.zIndex = me.getZIndex(overTargetEl)) !== -1) {
  1658. needsSort = true;
  1659. }
  1660. allTargets.push(overTarget);
  1661. }
  1662. }
  1663. }
  1664. // If there were floating targets, sort the highest zIndex to the top
  1665. if (needsSort) {
  1666. allTargets.sort(me.byZIndex);
  1667. }
  1668. // Loop through possible targets, notifying the one(s) we are over.
  1669. // Usually we only deliver events to the topmost.
  1670. for (i = 0, len = allTargets.length; i &lt; len; i++) {
  1671. overTarget = allTargets[i];
  1672. // If we are over the overTarget, queue it up to recieve an event of whatever type we are handling
  1673. if (me.isOverTarget(mousePoint, overTarget, me.mode)) {
  1674. // look for drop interactions
  1675. if (isDrop) {
  1676. dropEvts.push( overTarget );
  1677. // look for drag enter and drag over interactions
  1678. } else {
  1679. // initial drag over: dragEnter fires
  1680. if (!oldOvers[overTarget.id]) {
  1681. enterEvts.push( overTarget );
  1682. // subsequent drag overs: dragOver fires
  1683. } else {
  1684. overEvts.push( overTarget );
  1685. }
  1686. me.dragOvers[overTarget.id] = overTarget;
  1687. }
  1688. // Unless this DragDropManager has been explicitly configured to deliver events to multiple targets, then we are done.
  1689. if (!me.notifyOccluded) {
  1690. break;
  1691. }
  1692. }
  1693. }
  1694. if (me.mode) {
  1695. if (outEvts.length) {
  1696. dragCurrent.b4DragOut(e, outEvts);
  1697. dragCurrent.onDragOut(e, outEvts);
  1698. }
  1699. if (enterEvts.length) {
  1700. dragCurrent.onDragEnter(e, enterEvts);
  1701. }
  1702. if (overEvts.length) {
  1703. dragCurrent.b4DragOver(e, overEvts);
  1704. dragCurrent.onDragOver(e, overEvts);
  1705. }
  1706. if (dropEvts.length) {
  1707. dragCurrent.b4DragDrop(e, dropEvts);
  1708. dragCurrent.onDragDrop(e, dropEvts);
  1709. }
  1710. } else {
  1711. // fire dragout events
  1712. for (i=0, len=outEvts.length; i&lt;len; ++i) {
  1713. dragCurrent.b4DragOut(e, outEvts[i].id);
  1714. dragCurrent.onDragOut(e, outEvts[i].id);
  1715. }
  1716. // fire enter events
  1717. for (i=0,len=enterEvts.length; i&lt;len; ++i) {
  1718. // dc.b4DragEnter(e, oDD.id);
  1719. dragCurrent.onDragEnter(e, enterEvts[i].id);
  1720. }
  1721. // fire over events
  1722. for (i=0,len=overEvts.length; i&lt;len; ++i) {
  1723. dragCurrent.b4DragOver(e, overEvts[i].id);
  1724. dragCurrent.onDragOver(e, overEvts[i].id);
  1725. }
  1726. // fire drop events
  1727. for (i=0, len=dropEvts.length; i&lt;len; ++i) {
  1728. dragCurrent.b4DragDrop(e, dropEvts[i].id);
  1729. dragCurrent.onDragDrop(e, dropEvts[i].id);
  1730. }
  1731. }
  1732. // notify about a drop that did not find a target
  1733. if (isDrop &amp;&amp; !dropEvts.length) {
  1734. dragCurrent.onInvalidDrop(e);
  1735. }
  1736. },
  1737. <span id='Ext-dd-DragDropMgr-method-getZIndex'> /**
  1738. </span> * @private
  1739. * Collects the z-index of the passed element, looking up the parentNode axis to find an absolutely positioned ancestor
  1740. * which is able to yield a z-index. If found to be not absolutely positionedm returns -1.
  1741. *
  1742. * This is used when sorting potential drop targets into z-index order so that only the topmost receives `over` and `drop` events.
  1743. *
  1744. * @return {Number} The z-index of the element, or of its topmost absolutely positioned ancestor. Returns -1 if the element is not
  1745. * absolutely positioned.
  1746. */
  1747. getZIndex: function(element) {
  1748. var body = document.body,
  1749. z,
  1750. zIndex = -1;
  1751. element = Ext.getDom(element);
  1752. while (element !== body) {
  1753. if (!isNaN(z = Number(Ext.fly(element).getStyle('zIndex')))) {
  1754. zIndex = z;
  1755. }
  1756. element = element.parentNode;
  1757. }
  1758. return zIndex;
  1759. },
  1760. <span id='Ext-dd-DragDropMgr-method-byZIndex'> /**
  1761. </span> * @private
  1762. * Utility method to pass to {@link Ext.Array#sort} when sorting potential drop targets by z-index.
  1763. */
  1764. byZIndex: function(d1, d2) {
  1765. return d1.zIndex &lt; d2.zIndex;
  1766. },
  1767. <span id='Ext-dd-DragDropMgr-method-getBestMatch'> /**
  1768. </span> * Helper function for getting the best match from the list of drag
  1769. * and drop objects returned by the drag and drop events when we are
  1770. * in INTERSECT mode. It returns either the first object that the
  1771. * cursor is over, or the object that has the greatest overlap with
  1772. * the dragged element.
  1773. * @method getBestMatch
  1774. * @param {DragDrop[]} dds The array of drag and drop objects
  1775. * targeted
  1776. * @return {DragDrop} The best single match
  1777. */
  1778. getBestMatch: function(dds) {
  1779. var winner = null;
  1780. // Return null if the input is not what we expect
  1781. //if (!dds || !dds.length || dds.length == 0) {
  1782. // winner = null;
  1783. // If there is only one item, it wins
  1784. //} else if (dds.length == 1) {
  1785. var len = dds.length;
  1786. if (len == 1) {
  1787. winner = dds[0];
  1788. } else {
  1789. // Loop through the targeted items
  1790. for (var i=0; i&lt;len; ++i) {
  1791. var dd = dds[i];
  1792. // If the cursor is over the object, it wins. If the
  1793. // cursor is over multiple matches, the first one we come
  1794. // to wins.
  1795. if (dd.cursorIsOver) {
  1796. winner = dd;
  1797. break;
  1798. // Otherwise the object with the most overlap wins
  1799. } else {
  1800. if (!winner ||
  1801. winner.overlap.getArea() &lt; dd.overlap.getArea()) {
  1802. winner = dd;
  1803. }
  1804. }
  1805. }
  1806. }
  1807. return winner;
  1808. },
  1809. <span id='Ext-dd-DragDropMgr-method-refreshCache'> /**
  1810. </span> * Refreshes the cache of the top-left and bottom-right points of the
  1811. * drag and drop objects in the specified group(s). This is in the
  1812. * format that is stored in the drag and drop instance, so typical
  1813. * usage is:
  1814. * &lt;code&gt;
  1815. * Ext.dd.DragDropMgr.refreshCache(ddinstance.groups);
  1816. * &lt;/code&gt;
  1817. * Alternatively:
  1818. * &lt;code&gt;
  1819. * Ext.dd.DragDropMgr.refreshCache({group1:true, group2:true});
  1820. * &lt;/code&gt;
  1821. * @TODO this really should be an indexed array. Alternatively this
  1822. * method could accept both.
  1823. * @method refreshCache
  1824. * @param {Object} groups an associative array of groups to refresh
  1825. */
  1826. refreshCache: function(groups) {
  1827. for (var sGroup in groups) {
  1828. if (&quot;string&quot; != typeof sGroup) {
  1829. continue;
  1830. }
  1831. for (var i in this.ids[sGroup]) {
  1832. var oDD = this.ids[sGroup][i];
  1833. if (this.isTypeOfDD(oDD)) {
  1834. // if (this.isTypeOfDD(oDD) &amp;&amp; oDD.isTarget) {
  1835. var loc = this.getLocation(oDD);
  1836. if (loc) {
  1837. this.locationCache[oDD.id] = loc;
  1838. } else {
  1839. delete this.locationCache[oDD.id];
  1840. // this will unregister the drag and drop object if
  1841. // the element is not in a usable state
  1842. // oDD.unreg();
  1843. }
  1844. }
  1845. }
  1846. }
  1847. },
  1848. <span id='Ext-dd-DragDropMgr-method-verifyEl'> /**
  1849. </span> * This checks to make sure an element exists and is in the DOM. The
  1850. * main purpose is to handle cases where innerHTML is used to remove
  1851. * drag and drop objects from the DOM. IE provides an 'unspecified
  1852. * error' when trying to access the offsetParent of such an element
  1853. * @method verifyEl
  1854. * @param {HTMLElement} el the element to check
  1855. * @return {boolean} true if the element looks usable
  1856. */
  1857. verifyEl: function(el) {
  1858. if (el) {
  1859. var parent;
  1860. if(Ext.isIE){
  1861. try{
  1862. parent = el.offsetParent;
  1863. }catch(e){}
  1864. }else{
  1865. parent = el.offsetParent;
  1866. }
  1867. if (parent) {
  1868. return true;
  1869. }
  1870. }
  1871. return false;
  1872. },
  1873. <span id='Ext-dd-DragDropMgr-method-getLocation'> /**
  1874. </span> * Returns a Region object containing the drag and drop element's position
  1875. * and size, including the padding configured for it
  1876. * @method getLocation
  1877. * @param {DragDrop} oDD the drag and drop object to get the
  1878. * location for
  1879. * @return {Ext.lib.Region} a Region object representing the total area
  1880. * the element occupies, including any padding
  1881. * the instance is configured for.
  1882. */
  1883. getLocation: function(oDD) {
  1884. if (! this.isTypeOfDD(oDD)) {
  1885. return null;
  1886. }
  1887. var el = oDD.getEl(), pos, x1, x2, y1, y2, t, r, b, l, region;
  1888. try {
  1889. pos= Ext.lib.Dom.getXY(el);
  1890. } catch (e) { }
  1891. if (!pos) {
  1892. return null;
  1893. }
  1894. x1 = pos[0];
  1895. x2 = x1 + el.offsetWidth;
  1896. y1 = pos[1];
  1897. y2 = y1 + el.offsetHeight;
  1898. t = y1 - oDD.padding[0];
  1899. r = x2 + oDD.padding[1];
  1900. b = y2 + oDD.padding[2];
  1901. l = x1 - oDD.padding[3];
  1902. return new Ext.lib.Region( t, r, b, l );
  1903. },
  1904. <span id='Ext-dd-DragDropMgr-method-isOverTarget'> /**
  1905. </span> * Checks the cursor location to see if it over the target
  1906. * @method isOverTarget
  1907. * @param {Ext.lib.Point} pt The point to evaluate
  1908. * @param {DragDrop} oTarget the DragDrop object we are inspecting
  1909. * @return {boolean} true if the mouse is over the target
  1910. * @private
  1911. */
  1912. isOverTarget: function(pt, oTarget, intersect) {
  1913. // use cache if available
  1914. var loc = this.locationCache[oTarget.id];
  1915. if (!loc || !this.useCache) {
  1916. loc = this.getLocation(oTarget);
  1917. this.locationCache[oTarget.id] = loc;
  1918. }
  1919. if (!loc) {
  1920. return false;
  1921. }
  1922. oTarget.cursorIsOver = loc.contains( pt );
  1923. // DragDrop is using this as a sanity check for the initial mousedown
  1924. // in this case we are done. In POINT mode, if the drag obj has no
  1925. // contraints, we are also done. Otherwise we need to evaluate the
  1926. // location of the target as related to the actual location of the
  1927. // dragged element.
  1928. var dc = this.dragCurrent;
  1929. if (!dc || !dc.getTargetCoord ||
  1930. (!intersect &amp;&amp; !dc.constrainX &amp;&amp; !dc.constrainY)) {
  1931. return oTarget.cursorIsOver;
  1932. }
  1933. oTarget.overlap = null;
  1934. // Get the current location of the drag element, this is the
  1935. // location of the mouse event less the delta that represents
  1936. // where the original mousedown happened on the element. We
  1937. // need to consider constraints and ticks as well.
  1938. var pos = dc.getTargetCoord(pt.x, pt.y);
  1939. var el = dc.getDragEl();
  1940. var curRegion = new Ext.lib.Region( pos.y,
  1941. pos.x + el.offsetWidth,
  1942. pos.y + el.offsetHeight,
  1943. pos.x );
  1944. var overlap = curRegion.intersect(loc);
  1945. if (overlap) {
  1946. oTarget.overlap = overlap;
  1947. return (intersect) ? true : oTarget.cursorIsOver;
  1948. } else {
  1949. return false;
  1950. }
  1951. },
  1952. <span id='Ext-dd-DragDropMgr-method-_onUnload'> /**
  1953. </span> * unload event handler
  1954. * @method _onUnload
  1955. * @private
  1956. */
  1957. _onUnload: function(e, me) {
  1958. Event.removeListener(document, &quot;mouseup&quot;, this.handleMouseUp, this);
  1959. Event.removeListener(document, &quot;mousemove&quot;, this.handleMouseMove, this);
  1960. Event.removeListener(window, &quot;resize&quot;, this._onResize, this);
  1961. Ext.dd.DragDropMgr.unregAll();
  1962. },
  1963. <span id='Ext-dd-DragDropMgr-method-unregAll'> /**
  1964. </span> * Cleans up the drag and drop events and objects.
  1965. * @method unregAll
  1966. * @private
  1967. */
  1968. unregAll: function() {
  1969. if (this.dragCurrent) {
  1970. this.stopDrag();
  1971. this.dragCurrent = null;
  1972. }
  1973. this._execOnAll(&quot;unreg&quot;, []);
  1974. for (var i in this.elementCache) {
  1975. delete this.elementCache[i];
  1976. }
  1977. this.elementCache = {};
  1978. this.ids = {};
  1979. },
  1980. <span id='Ext-dd-DragDropMgr-property-elementCache'> /**
  1981. </span> * A cache of DOM elements
  1982. * @property elementCache
  1983. * @private
  1984. */
  1985. elementCache: {},
  1986. <span id='Ext-dd-DragDropMgr-method-getElWrapper'> /**
  1987. </span> * Get the wrapper for the DOM element specified
  1988. * @method getElWrapper
  1989. * @param {String} id the id of the element to get
  1990. * @return {Ext.dd.DDM.ElementWrapper} the wrapped element
  1991. * @private
  1992. * @deprecated This wrapper isn't that useful
  1993. */
  1994. getElWrapper: function(id) {
  1995. var oWrapper = this.elementCache[id];
  1996. if (!oWrapper || !oWrapper.el) {
  1997. oWrapper = this.elementCache[id] =
  1998. new this.ElementWrapper(Ext.getDom(id));
  1999. }
  2000. return oWrapper;
  2001. },
  2002. <span id='Ext-dd-DragDropMgr-method-getElement'> /**
  2003. </span> * Returns the actual DOM element
  2004. * @method getElement
  2005. * @param {String} id the id of the elment to get
  2006. * @return {Object} The element
  2007. * @deprecated use Ext.lib.Ext.getDom instead
  2008. */
  2009. getElement: function(id) {
  2010. return Ext.getDom(id);
  2011. },
  2012. <span id='Ext-dd-DragDropMgr-method-getCss'> /**
  2013. </span> * Returns the style property for the DOM element (i.e.,
  2014. * document.getElById(id).style)
  2015. * @method getCss
  2016. * @param {String} id the id of the elment to get
  2017. * @return {Object} The style property of the element
  2018. * @deprecated use Ext.lib.Dom instead
  2019. */
  2020. getCss: function(id) {
  2021. var el = Ext.getDom(id);
  2022. return (el) ? el.style : null;
  2023. },
  2024. <span id='Ext-dd-DragDropMgr-ElementWrapper'> /**
  2025. </span> * Inner class for cached elements
  2026. * @class Ext.dd.DragDropMgr.ElementWrapper
  2027. * @for DragDropMgr
  2028. * @private
  2029. * @deprecated
  2030. */
  2031. ElementWrapper: function(el) {
  2032. <span id='Ext-dd-DragDropMgr-ElementWrapper-property-el'> /**
  2033. </span> * The element
  2034. * @property el
  2035. */
  2036. this.el = el || null;
  2037. <span id='Ext-dd-DragDropMgr-ElementWrapper-property-id'> /**
  2038. </span> * The element id
  2039. * @property id
  2040. */
  2041. this.id = this.el &amp;&amp; el.id;
  2042. <span id='Ext-dd-DragDropMgr-ElementWrapper-property-css'> /**
  2043. </span> * A reference to the style property
  2044. * @property css
  2045. */
  2046. this.css = this.el &amp;&amp; el.style;
  2047. },
  2048. <span id='Ext-dd-DragDropMgr-ElementWrapper-method-getPosX'> /**
  2049. </span> * Returns the X position of an html element
  2050. * @method getPosX
  2051. * @param el the element for which to get the position
  2052. * @return {int} the X coordinate
  2053. * @for DragDropMgr
  2054. * @deprecated use Ext.lib.Dom.getX instead
  2055. */
  2056. getPosX: function(el) {
  2057. return Ext.lib.Dom.getX(el);
  2058. },
  2059. <span id='Ext-dd-DragDropMgr-ElementWrapper-method-getPosY'> /**
  2060. </span> * Returns the Y position of an html element
  2061. * @method getPosY
  2062. * @param el the element for which to get the position
  2063. * @return {int} the Y coordinate
  2064. * @deprecated use Ext.lib.Dom.getY instead
  2065. */
  2066. getPosY: function(el) {
  2067. return Ext.lib.Dom.getY(el);
  2068. },
  2069. <span id='Ext-dd-DragDropMgr-ElementWrapper-method-swapNode'> /**
  2070. </span> * Swap two nodes. In IE, we use the native method, for others we
  2071. * emulate the IE behavior
  2072. * @method swapNode
  2073. * @param n1 the first node to swap
  2074. * @param n2 the other node to swap
  2075. */
  2076. swapNode: function(n1, n2) {
  2077. if (n1.swapNode) {
  2078. n1.swapNode(n2);
  2079. } else {
  2080. var p = n2.parentNode;
  2081. var s = n2.nextSibling;
  2082. if (s == n1) {
  2083. p.insertBefore(n1, n2);
  2084. } else if (n2 == n1.nextSibling) {
  2085. p.insertBefore(n2, n1);
  2086. } else {
  2087. n1.parentNode.replaceChild(n2, n1);
  2088. p.insertBefore(n1, s);
  2089. }
  2090. }
  2091. },
  2092. <span id='Ext-dd-DragDropMgr-ElementWrapper-method-getScroll'> /**
  2093. </span> * Returns the current scroll position
  2094. * @method getScroll
  2095. * @private
  2096. */
  2097. getScroll: function () {
  2098. var t, l, dde=document.documentElement, db=document.body;
  2099. if (dde &amp;&amp; (dde.scrollTop || dde.scrollLeft)) {
  2100. t = dde.scrollTop;
  2101. l = dde.scrollLeft;
  2102. } else if (db) {
  2103. t = db.scrollTop;
  2104. l = db.scrollLeft;
  2105. } else {
  2106. }
  2107. return { top: t, left: l };
  2108. },
  2109. <span id='Ext-dd-DragDropMgr-ElementWrapper-method-getStyle'> /**
  2110. </span> * Returns the specified element style property
  2111. * @method getStyle
  2112. * @param {HTMLElement} el the element
  2113. * @param {string} styleProp the style property
  2114. * @return {string} The value of the style property
  2115. * @deprecated use Ext.lib.Dom.getStyle
  2116. */
  2117. getStyle: function(el, styleProp) {
  2118. return Ext.fly(el).getStyle(styleProp);
  2119. },
  2120. <span id='Ext-dd-DragDropMgr-ElementWrapper-method-getScrollTop'> /**
  2121. </span> * Gets the scrollTop
  2122. * @method getScrollTop
  2123. * @return {int} the document's scrollTop
  2124. */
  2125. getScrollTop: function () {
  2126. return this.getScroll().top;
  2127. },
  2128. <span id='Ext-dd-DragDropMgr-ElementWrapper-method-getScrollLeft'> /**
  2129. </span> * Gets the scrollLeft
  2130. * @method getScrollLeft
  2131. * @return {int} the document's scrollTop
  2132. */
  2133. getScrollLeft: function () {
  2134. return this.getScroll().left;
  2135. },
  2136. <span id='Ext-dd-DragDropMgr-ElementWrapper-method-moveToEl'> /**
  2137. </span> * Sets the x/y position of an element to the location of the
  2138. * target element.
  2139. * @method moveToEl
  2140. * @param {HTMLElement} moveEl The element to move
  2141. * @param {HTMLElement} targetEl The position reference element
  2142. */
  2143. moveToEl: function (moveEl, targetEl) {
  2144. var aCoord = Ext.lib.Dom.getXY(targetEl);
  2145. Ext.lib.Dom.setXY(moveEl, aCoord);
  2146. },
  2147. <span id='Ext-dd-DragDropMgr-ElementWrapper-method-numericSort'> /**
  2148. </span> * Numeric array sort function
  2149. * @method numericSort
  2150. */
  2151. numericSort: function(a, b) {
  2152. return (a - b);
  2153. },
  2154. <span id='Ext-dd-DragDropMgr-ElementWrapper-property-_timeoutCount'> /**
  2155. </span> * Internal counter
  2156. * @property _timeoutCount
  2157. * @private
  2158. */
  2159. _timeoutCount: 0,
  2160. <span id='Ext-dd-DragDropMgr-ElementWrapper-method-_addListeners'> /**
  2161. </span> * Trying to make the load order less important. Without this we get
  2162. * an error if this file is loaded before the Event Utility.
  2163. * @method _addListeners
  2164. * @private
  2165. */
  2166. _addListeners: function() {
  2167. var DDM = Ext.dd.DDM;
  2168. if ( Ext.lib.Event &amp;&amp; document ) {
  2169. DDM._onLoad();
  2170. } else {
  2171. if (DDM._timeoutCount &gt; 2000) {
  2172. } else {
  2173. setTimeout(DDM._addListeners, 10);
  2174. if (document &amp;&amp; document.body) {
  2175. DDM._timeoutCount += 1;
  2176. }
  2177. }
  2178. }
  2179. },
  2180. <span id='Ext-dd-DragDropMgr-ElementWrapper-method-handleWasClicked'> /**
  2181. </span> * Recursively searches the immediate parent and all child nodes for
  2182. * the handle element in order to determine wheter or not it was
  2183. * clicked.
  2184. * @method handleWasClicked
  2185. * @param node the html element to inspect
  2186. */
  2187. handleWasClicked: function(node, id) {
  2188. if (this.isHandle(id, node.id)) {
  2189. return true;
  2190. } else {
  2191. // check to see if this is a text node child of the one we want
  2192. var p = node.parentNode;
  2193. while (p) {
  2194. if (this.isHandle(id, p.id)) {
  2195. return true;
  2196. } else {
  2197. p = p.parentNode;
  2198. }
  2199. }
  2200. }
  2201. return false;
  2202. }
  2203. };
  2204. }();
  2205. // shorter alias, save a few bytes
  2206. Ext.dd.DDM = Ext.dd.DragDropMgr;
  2207. Ext.dd.DDM._addListeners();
  2208. }
  2209. <span id='Ext-dd-DD-method-constructor'><span id='Ext-dd-DD'>/**
  2210. </span></span> * @class Ext.dd.DD
  2211. * A DragDrop implementation where the linked element follows the
  2212. * mouse cursor during a drag.
  2213. * @extends Ext.dd.DragDrop
  2214. * @constructor
  2215. * @param {String} id the id of the linked element
  2216. * @param {String} sGroup the group of related DragDrop items
  2217. * @param {object} config an object containing configurable attributes
  2218. * Valid properties for DD:
  2219. * scroll
  2220. */
  2221. Ext.dd.DD = function(id, sGroup, config) {
  2222. if (id) {
  2223. this.init(id, sGroup, config);
  2224. }
  2225. };
  2226. Ext.extend(Ext.dd.DD, Ext.dd.DragDrop, {
  2227. <span id='Ext-dd-DD-property-scroll'> /**
  2228. </span> * When set to true, the utility automatically tries to scroll the browser
  2229. * window when a drag and drop element is dragged near the viewport boundary.
  2230. * Defaults to true.
  2231. * @property scroll
  2232. * @type boolean
  2233. */
  2234. scroll: true,
  2235. <span id='Ext-dd-DD-method-autoOffset'> /**
  2236. </span> * Sets the pointer offset to the distance between the linked element's top
  2237. * left corner and the location the element was clicked
  2238. * @method autoOffset
  2239. * @param {int} iPageX the X coordinate of the click
  2240. * @param {int} iPageY the Y coordinate of the click
  2241. */
  2242. autoOffset: function(iPageX, iPageY) {
  2243. var x = iPageX - this.startPageX;
  2244. var y = iPageY - this.startPageY;
  2245. this.setDelta(x, y);
  2246. },
  2247. <span id='Ext-dd-DD-method-setDelta'> /**
  2248. </span> * Sets the pointer offset. You can call this directly to force the
  2249. * offset to be in a particular location (e.g., pass in 0,0 to set it
  2250. * to the center of the object)
  2251. * @method setDelta
  2252. * @param {int} iDeltaX the distance from the left
  2253. * @param {int} iDeltaY the distance from the top
  2254. */
  2255. setDelta: function(iDeltaX, iDeltaY) {
  2256. this.deltaX = iDeltaX;
  2257. this.deltaY = iDeltaY;
  2258. },
  2259. <span id='Ext-dd-DD-method-setDragElPos'> /**
  2260. </span> * Sets the drag element to the location of the mousedown or click event,
  2261. * maintaining the cursor location relative to the location on the element
  2262. * that was clicked. Override this if you want to place the element in a
  2263. * location other than where the cursor is.
  2264. * @method setDragElPos
  2265. * @param {int} iPageX the X coordinate of the mousedown or drag event
  2266. * @param {int} iPageY the Y coordinate of the mousedown or drag event
  2267. */
  2268. setDragElPos: function(iPageX, iPageY) {
  2269. // the first time we do this, we are going to check to make sure
  2270. // the element has css positioning
  2271. var el = this.getDragEl();
  2272. this.alignElWithMouse(el, iPageX, iPageY);
  2273. },
  2274. <span id='Ext-dd-DD-method-alignElWithMouse'> /**
  2275. </span> * Sets the element to the location of the mousedown or click event,
  2276. * maintaining the cursor location relative to the location on the element
  2277. * that was clicked. Override this if you want to place the element in a
  2278. * location other than where the cursor is.
  2279. * @method alignElWithMouse
  2280. * @param {HTMLElement} el the element to move
  2281. * @param {int} iPageX the X coordinate of the mousedown or drag event
  2282. * @param {int} iPageY the Y coordinate of the mousedown or drag event
  2283. */
  2284. alignElWithMouse: function(el, iPageX, iPageY) {
  2285. var oCoord = this.getTargetCoord(iPageX, iPageY);
  2286. var fly = el.dom ? el : Ext.fly(el, '_dd');
  2287. if (!this.deltaSetXY) {
  2288. var aCoord = [oCoord.x, oCoord.y];
  2289. fly.setXY(aCoord);
  2290. var newLeft = fly.getLeft(true);
  2291. var newTop = fly.getTop(true);
  2292. this.deltaSetXY = [ newLeft - oCoord.x, newTop - oCoord.y ];
  2293. } else {
  2294. fly.setLeftTop(oCoord.x + this.deltaSetXY[0], oCoord.y + this.deltaSetXY[1]);
  2295. }
  2296. this.cachePosition(oCoord.x, oCoord.y);
  2297. this.autoScroll(oCoord.x, oCoord.y, el.offsetHeight, el.offsetWidth);
  2298. return oCoord;
  2299. },
  2300. <span id='Ext-dd-DD-method-cachePosition'> /**
  2301. </span> * Saves the most recent position so that we can reset the constraints and
  2302. * tick marks on-demand. We need to know this so that we can calculate the
  2303. * number of pixels the element is offset from its original position.
  2304. * @method cachePosition
  2305. * @param iPageX the current x position (optional, this just makes it so we
  2306. * don't have to look it up again)
  2307. * @param iPageY the current y position (optional, this just makes it so we
  2308. * don't have to look it up again)
  2309. */
  2310. cachePosition: function(iPageX, iPageY) {
  2311. if (iPageX) {
  2312. this.lastPageX = iPageX;
  2313. this.lastPageY = iPageY;
  2314. } else {
  2315. var aCoord = Ext.lib.Dom.getXY(this.getEl());
  2316. this.lastPageX = aCoord[0];
  2317. this.lastPageY = aCoord[1];
  2318. }
  2319. },
  2320. <span id='Ext-dd-DD-method-autoScroll'> /**
  2321. </span> * Auto-scroll the window if the dragged object has been moved beyond the
  2322. * visible window boundary.
  2323. * @method autoScroll
  2324. * @param {int} x the drag element's x position
  2325. * @param {int} y the drag element's y position
  2326. * @param {int} h the height of the drag element
  2327. * @param {int} w the width of the drag element
  2328. * @private
  2329. */
  2330. autoScroll: function(x, y, h, w) {
  2331. if (this.scroll) {
  2332. // The client height
  2333. var clientH = Ext.lib.Dom.getViewHeight();
  2334. // The client width
  2335. var clientW = Ext.lib.Dom.getViewWidth();
  2336. // The amt scrolled down
  2337. var st = this.DDM.getScrollTop();
  2338. // The amt scrolled right
  2339. var sl = this.DDM.getScrollLeft();
  2340. // Location of the bottom of the element
  2341. var bot = h + y;
  2342. // Location of the right of the element
  2343. var right = w + x;
  2344. // The distance from the cursor to the bottom of the visible area,
  2345. // adjusted so that we don't scroll if the cursor is beyond the
  2346. // element drag constraints
  2347. var toBot = (clientH + st - y - this.deltaY);
  2348. // The distance from the cursor to the right of the visible area
  2349. var toRight = (clientW + sl - x - this.deltaX);
  2350. // How close to the edge the cursor must be before we scroll
  2351. // var thresh = (document.all) ? 100 : 40;
  2352. var thresh = 40;
  2353. // How many pixels to scroll per autoscroll op. This helps to reduce
  2354. // clunky scrolling. IE is more sensitive about this ... it needs this
  2355. // value to be higher.
  2356. var scrAmt = (document.all) ? 80 : 30;
  2357. // Scroll down if we are near the bottom of the visible page and the
  2358. // obj extends below the crease
  2359. if ( bot &gt; clientH &amp;&amp; toBot &lt; thresh ) {
  2360. window.scrollTo(sl, st + scrAmt);
  2361. }
  2362. // Scroll up if the window is scrolled down and the top of the object
  2363. // goes above the top border
  2364. if ( y &lt; st &amp;&amp; st &gt; 0 &amp;&amp; y - st &lt; thresh ) {
  2365. window.scrollTo(sl, st - scrAmt);
  2366. }
  2367. // Scroll right if the obj is beyond the right border and the cursor is
  2368. // near the border.
  2369. if ( right &gt; clientW &amp;&amp; toRight &lt; thresh ) {
  2370. window.scrollTo(sl + scrAmt, st);
  2371. }
  2372. // Scroll left if the window has been scrolled to the right and the obj
  2373. // extends past the left border
  2374. if ( x &lt; sl &amp;&amp; sl &gt; 0 &amp;&amp; x - sl &lt; thresh ) {
  2375. window.scrollTo(sl - scrAmt, st);
  2376. }
  2377. }
  2378. },
  2379. <span id='Ext-dd-DD-method-getTargetCoord'> /**
  2380. </span> * Finds the location the element should be placed if we want to move
  2381. * it to where the mouse location less the click offset would place us.
  2382. * @method getTargetCoord
  2383. * @param {int} iPageX the X coordinate of the click
  2384. * @param {int} iPageY the Y coordinate of the click
  2385. * @return an object that contains the coordinates (Object.x and Object.y)
  2386. * @private
  2387. */
  2388. getTargetCoord: function(iPageX, iPageY) {
  2389. var x = iPageX - this.deltaX;
  2390. var y = iPageY - this.deltaY;
  2391. if (this.constrainX) {
  2392. if (x &lt; this.minX) { x = this.minX; }
  2393. if (x &gt; this.maxX) { x = this.maxX; }
  2394. }
  2395. if (this.constrainY) {
  2396. if (y &lt; this.minY) { y = this.minY; }
  2397. if (y &gt; this.maxY) { y = this.maxY; }
  2398. }
  2399. x = this.getTick(x, this.xTicks);
  2400. y = this.getTick(y, this.yTicks);
  2401. return {x:x, y:y};
  2402. },
  2403. <span id='Ext-dd-DD-method-applyConfig'> /**
  2404. </span> * Sets up config options specific to this class. Overrides
  2405. * Ext.dd.DragDrop, but all versions of this method through the
  2406. * inheritance chain are called
  2407. */
  2408. applyConfig: function() {
  2409. Ext.dd.DD.superclass.applyConfig.call(this);
  2410. this.scroll = (this.config.scroll !== false);
  2411. },
  2412. <span id='Ext-dd-DD-method-b4MouseDown'> /**
  2413. </span> * Event that fires prior to the onMouseDown event. Overrides
  2414. * Ext.dd.DragDrop.
  2415. */
  2416. b4MouseDown: function(e) {
  2417. // this.resetConstraints();
  2418. this.autoOffset(e.getPageX(),
  2419. e.getPageY());
  2420. },
  2421. <span id='Ext-dd-DD-method-b4Drag'> /**
  2422. </span> * Event that fires prior to the onDrag event. Overrides
  2423. * Ext.dd.DragDrop.
  2424. */
  2425. b4Drag: function(e) {
  2426. this.setDragElPos(e.getPageX(),
  2427. e.getPageY());
  2428. },
  2429. toString: function() {
  2430. return (&quot;DD &quot; + this.id);
  2431. }
  2432. //////////////////////////////////////////////////////////////////////////
  2433. // Debugging ygDragDrop events that can be overridden
  2434. //////////////////////////////////////////////////////////////////////////
  2435. /*
  2436. startDrag: function(x, y) {
  2437. },
  2438. onDrag: function(e) {
  2439. },
  2440. onDragEnter: function(e, id) {
  2441. },
  2442. onDragOver: function(e, id) {
  2443. },
  2444. onDragOut: function(e, id) {
  2445. },
  2446. onDragDrop: function(e, id) {
  2447. },
  2448. endDrag: function(e) {
  2449. }
  2450. */
  2451. });
  2452. <span id='Ext-dd-DDProxy-method-constructor'><span id='Ext-dd-DDProxy'>/**
  2453. </span></span> * @class Ext.dd.DDProxy
  2454. * A DragDrop implementation that inserts an empty, bordered div into
  2455. * the document that follows the cursor during drag operations. At the time of
  2456. * the click, the frame div is resized to the dimensions of the linked html
  2457. * element, and moved to the exact location of the linked element.
  2458. *
  2459. * References to the &quot;frame&quot; element refer to the single proxy element that
  2460. * was created to be dragged in place of all DDProxy elements on the
  2461. * page.
  2462. *
  2463. * @extends Ext.dd.DD
  2464. * @constructor
  2465. * @param {String} id the id of the linked html element
  2466. * @param {String} sGroup the group of related DragDrop objects
  2467. * @param {object} config an object containing configurable attributes
  2468. * Valid properties for DDProxy in addition to those in DragDrop:
  2469. * resizeFrame, centerFrame, dragElId
  2470. */
  2471. Ext.dd.DDProxy = function(id, sGroup, config) {
  2472. if (id) {
  2473. this.init(id, sGroup, config);
  2474. this.initFrame();
  2475. }
  2476. };
  2477. <span id='Ext-dd-DDProxy-static-property-Ext.dd.DDProxy.dragElId'>/**
  2478. </span> * The default drag frame div id
  2479. * @property Ext.dd.DDProxy.dragElId
  2480. * @type String
  2481. * @static
  2482. */
  2483. Ext.dd.DDProxy.dragElId = &quot;ygddfdiv&quot;;
  2484. Ext.extend(Ext.dd.DDProxy, Ext.dd.DD, {
  2485. <span id='Ext-dd-DDProxy-property-resizeFrame'> /**
  2486. </span> * By default we resize the drag frame to be the same size as the element
  2487. * we want to drag (this is to get the frame effect). We can turn it off
  2488. * if we want a different behavior.
  2489. * @property resizeFrame
  2490. * @type boolean
  2491. */
  2492. resizeFrame: true,
  2493. <span id='Ext-dd-DDProxy-property-centerFrame'> /**
  2494. </span> * By default the frame is positioned exactly where the drag element is, so
  2495. * we use the cursor offset provided by Ext.dd.DD. Another option that works only if
  2496. * you do not have constraints on the obj is to have the drag frame centered
  2497. * around the cursor. Set centerFrame to true for this effect.
  2498. * @property centerFrame
  2499. * @type boolean
  2500. */
  2501. centerFrame: false,
  2502. <span id='Ext-dd-DDProxy-method-createFrame'> /**
  2503. </span> * Creates the proxy element if it does not yet exist
  2504. * @method createFrame
  2505. */
  2506. createFrame: function() {
  2507. var self = this;
  2508. var body = document.body;
  2509. if (!body || !body.firstChild) {
  2510. setTimeout( function() { self.createFrame(); }, 50 );
  2511. return;
  2512. }
  2513. var div = this.getDragEl();
  2514. if (!div) {
  2515. div = document.createElement(&quot;div&quot;);
  2516. div.id = this.dragElId;
  2517. var s = div.style;
  2518. s.position = &quot;absolute&quot;;
  2519. s.visibility = &quot;hidden&quot;;
  2520. s.cursor = &quot;move&quot;;
  2521. s.border = &quot;2px solid #aaa&quot;;
  2522. s.zIndex = 999;
  2523. // appendChild can blow up IE if invoked prior to the window load event
  2524. // while rendering a table. It is possible there are other scenarios
  2525. // that would cause this to happen as well.
  2526. body.insertBefore(div, body.firstChild);
  2527. }
  2528. },
  2529. <span id='Ext-dd-DDProxy-method-initFrame'> /**
  2530. </span> * Initialization for the drag frame element. Must be called in the
  2531. * constructor of all subclasses
  2532. * @method initFrame
  2533. */
  2534. initFrame: function() {
  2535. this.createFrame();
  2536. },
  2537. applyConfig: function() {
  2538. Ext.dd.DDProxy.superclass.applyConfig.call(this);
  2539. this.resizeFrame = (this.config.resizeFrame !== false);
  2540. this.centerFrame = (this.config.centerFrame);
  2541. this.setDragElId(this.config.dragElId || Ext.dd.DDProxy.dragElId);
  2542. },
  2543. <span id='Ext-dd-DDProxy-method-showFrame'> /**
  2544. </span> * Resizes the drag frame to the dimensions of the clicked object, positions
  2545. * it over the object, and finally displays it
  2546. * @method showFrame
  2547. * @param {int} iPageX X click position
  2548. * @param {int} iPageY Y click position
  2549. * @private
  2550. */
  2551. showFrame: function(iPageX, iPageY) {
  2552. var el = this.getEl();
  2553. var dragEl = this.getDragEl();
  2554. var s = dragEl.style;
  2555. this._resizeProxy();
  2556. if (this.centerFrame) {
  2557. this.setDelta( Math.round(parseInt(s.width, 10)/2),
  2558. Math.round(parseInt(s.height, 10)/2) );
  2559. }
  2560. this.setDragElPos(iPageX, iPageY);
  2561. Ext.fly(dragEl).show();
  2562. },
  2563. <span id='Ext-dd-DDProxy-method-_resizeProxy'> /**
  2564. </span> * The proxy is automatically resized to the dimensions of the linked
  2565. * element when a drag is initiated, unless resizeFrame is set to false
  2566. * @method _resizeProxy
  2567. * @private
  2568. */
  2569. _resizeProxy: function() {
  2570. if (this.resizeFrame) {
  2571. var el = this.getEl();
  2572. Ext.fly(this.getDragEl()).setSize(el.offsetWidth, el.offsetHeight);
  2573. }
  2574. },
  2575. // overrides Ext.dd.DragDrop
  2576. b4MouseDown: function(e) {
  2577. var x = e.getPageX();
  2578. var y = e.getPageY();
  2579. this.autoOffset(x, y);
  2580. this.setDragElPos(x, y);
  2581. },
  2582. // overrides Ext.dd.DragDrop
  2583. b4StartDrag: function(x, y) {
  2584. // show the drag frame
  2585. this.showFrame(x, y);
  2586. },
  2587. // overrides Ext.dd.DragDrop
  2588. b4EndDrag: function(e) {
  2589. Ext.fly(this.getDragEl()).hide();
  2590. },
  2591. // overrides Ext.dd.DragDrop
  2592. // By default we try to move the element to the last location of the frame.
  2593. // This is so that the default behavior mirrors that of Ext.dd.DD.
  2594. endDrag: function(e) {
  2595. var lel = this.getEl();
  2596. var del = this.getDragEl();
  2597. // Show the drag frame briefly so we can get its position
  2598. del.style.visibility = &quot;&quot;;
  2599. this.beforeMove();
  2600. // Hide the linked element before the move to get around a Safari
  2601. // rendering bug.
  2602. lel.style.visibility = &quot;hidden&quot;;
  2603. Ext.dd.DDM.moveToEl(lel, del);
  2604. del.style.visibility = &quot;hidden&quot;;
  2605. lel.style.visibility = &quot;&quot;;
  2606. this.afterDrag();
  2607. },
  2608. beforeMove : function(){
  2609. },
  2610. afterDrag : function(){
  2611. },
  2612. toString: function() {
  2613. return (&quot;DDProxy &quot; + this.id);
  2614. }
  2615. });
  2616. <span id='Ext-dd-DDTarget-method-constructor'><span id='Ext-dd-DDTarget'>/**
  2617. </span></span> * @class Ext.dd.DDTarget
  2618. * A DragDrop implementation that does not move, but can be a drop
  2619. * target. You would get the same result by simply omitting implementation
  2620. * for the event callbacks, but this way we reduce the processing cost of the
  2621. * event listener and the callbacks.
  2622. * @extends Ext.dd.DragDrop
  2623. * @constructor
  2624. * @param {String} id the id of the element that is a drop target
  2625. * @param {String} sGroup the group of related DragDrop objects
  2626. * @param {object} config an object containing configurable attributes
  2627. * Valid properties for DDTarget in addition to those in
  2628. * DragDrop:
  2629. * none
  2630. */
  2631. Ext.dd.DDTarget = function(id, sGroup, config) {
  2632. if (id) {
  2633. this.initTarget(id, sGroup, config);
  2634. }
  2635. };
  2636. // Ext.dd.DDTarget.prototype = new Ext.dd.DragDrop();
  2637. Ext.extend(Ext.dd.DDTarget, Ext.dd.DragDrop, {
  2638. <span id='Ext-dd-DDTarget-method-getDragEl'> /**
  2639. </span> * @hide
  2640. * Overridden and disabled. A DDTarget does not support being dragged.
  2641. * @method
  2642. */
  2643. getDragEl: Ext.emptyFn,
  2644. <span id='Ext-dd-DDTarget-method-isValidHandleChild'> /**
  2645. </span> * @hide
  2646. * Overridden and disabled. A DDTarget does not support being dragged.
  2647. * @method
  2648. */
  2649. isValidHandleChild: Ext.emptyFn,
  2650. <span id='Ext-dd-DDTarget-method-startDrag'> /**
  2651. </span> * @hide
  2652. * Overridden and disabled. A DDTarget does not support being dragged.
  2653. * @method
  2654. */
  2655. startDrag: Ext.emptyFn,
  2656. <span id='Ext-dd-DDTarget-method-endDrag'> /**
  2657. </span> * @hide
  2658. * Overridden and disabled. A DDTarget does not support being dragged.
  2659. * @method
  2660. */
  2661. endDrag: Ext.emptyFn,
  2662. <span id='Ext-dd-DDTarget-method-onDrag'> /**
  2663. </span> * @hide
  2664. * Overridden and disabled. A DDTarget does not support being dragged.
  2665. * @method
  2666. */
  2667. onDrag: Ext.emptyFn,
  2668. <span id='Ext-dd-DDTarget-method-onDragDrop'> /**
  2669. </span> * @hide
  2670. * Overridden and disabled. A DDTarget does not support being dragged.
  2671. * @method
  2672. */
  2673. onDragDrop: Ext.emptyFn,
  2674. <span id='Ext-dd-DDTarget-method-onDragEnter'> /**
  2675. </span> * @hide
  2676. * Overridden and disabled. A DDTarget does not support being dragged.
  2677. * @method
  2678. */
  2679. onDragEnter: Ext.emptyFn,
  2680. <span id='Ext-dd-DDTarget-method-onDragOut'> /**
  2681. </span> * @hide
  2682. * Overridden and disabled. A DDTarget does not support being dragged.
  2683. * @method
  2684. */
  2685. onDragOut: Ext.emptyFn,
  2686. <span id='Ext-dd-DDTarget-method-onDragOver'> /**
  2687. </span> * @hide
  2688. * Overridden and disabled. A DDTarget does not support being dragged.
  2689. * @method
  2690. */
  2691. onDragOver: Ext.emptyFn,
  2692. <span id='Ext-dd-DDTarget-method-onInvalidDrop'> /**
  2693. </span> * @hide
  2694. * Overridden and disabled. A DDTarget does not support being dragged.
  2695. * @method
  2696. */
  2697. onInvalidDrop: Ext.emptyFn,
  2698. <span id='Ext-dd-DDTarget-method-onMouseDown'> /**
  2699. </span> * @hide
  2700. * Overridden and disabled. A DDTarget does not support being dragged.
  2701. * @method
  2702. */
  2703. onMouseDown: Ext.emptyFn,
  2704. <span id='Ext-dd-DDTarget-method-onMouseUp'> /**
  2705. </span> * @hide
  2706. * Overridden and disabled. A DDTarget does not support being dragged.
  2707. * @method
  2708. */
  2709. onMouseUp: Ext.emptyFn,
  2710. <span id='Ext-dd-DDTarget-method-setXConstraint'> /**
  2711. </span> * @hide
  2712. * Overridden and disabled. A DDTarget does not support being dragged.
  2713. * @method
  2714. */
  2715. setXConstraint: Ext.emptyFn,
  2716. <span id='Ext-dd-DDTarget-method-setYConstraint'> /**
  2717. </span> * @hide
  2718. * Overridden and disabled. A DDTarget does not support being dragged.
  2719. * @method
  2720. */
  2721. setYConstraint: Ext.emptyFn,
  2722. <span id='Ext-dd-DDTarget-method-resetConstraints'> /**
  2723. </span> * @hide
  2724. * Overridden and disabled. A DDTarget does not support being dragged.
  2725. * @method
  2726. */
  2727. resetConstraints: Ext.emptyFn,
  2728. <span id='Ext-dd-DDTarget-method-clearConstraints'> /**
  2729. </span> * @hide
  2730. * Overridden and disabled. A DDTarget does not support being dragged.
  2731. * @method
  2732. */
  2733. clearConstraints: Ext.emptyFn,
  2734. <span id='Ext-dd-DDTarget-method-clearTicks'> /**
  2735. </span> * @hide
  2736. * Overridden and disabled. A DDTarget does not support being dragged.
  2737. * @method
  2738. */
  2739. clearTicks: Ext.emptyFn,
  2740. <span id='Ext-dd-DDTarget-method-setInitPosition'> /**
  2741. </span> * @hide
  2742. * Overridden and disabled. A DDTarget does not support being dragged.
  2743. * @method
  2744. */
  2745. setInitPosition: Ext.emptyFn,
  2746. <span id='Ext-dd-DDTarget-method-setDragElId'> /**
  2747. </span> * @hide
  2748. * Overridden and disabled. A DDTarget does not support being dragged.
  2749. * @method
  2750. */
  2751. setDragElId: Ext.emptyFn,
  2752. <span id='Ext-dd-DDTarget-method-setHandleElId'> /**
  2753. </span> * @hide
  2754. * Overridden and disabled. A DDTarget does not support being dragged.
  2755. * @method
  2756. */
  2757. setHandleElId: Ext.emptyFn,
  2758. <span id='Ext-dd-DDTarget-method-setOuterHandleElId'> /**
  2759. </span> * @hide
  2760. * Overridden and disabled. A DDTarget does not support being dragged.
  2761. * @method
  2762. */
  2763. setOuterHandleElId: Ext.emptyFn,
  2764. <span id='Ext-dd-DDTarget-method-addInvalidHandleClass'> /**
  2765. </span> * @hide
  2766. * Overridden and disabled. A DDTarget does not support being dragged.
  2767. * @method
  2768. */
  2769. addInvalidHandleClass: Ext.emptyFn,
  2770. <span id='Ext-dd-DDTarget-method-addInvalidHandleId'> /**
  2771. </span> * @hide
  2772. * Overridden and disabled. A DDTarget does not support being dragged.
  2773. * @method
  2774. */
  2775. addInvalidHandleId: Ext.emptyFn,
  2776. <span id='Ext-dd-DDTarget-method-addInvalidHandleType'> /**
  2777. </span> * @hide
  2778. * Overridden and disabled. A DDTarget does not support being dragged.
  2779. * @method
  2780. */
  2781. addInvalidHandleType: Ext.emptyFn,
  2782. <span id='Ext-dd-DDTarget-method-removeInvalidHandleClass'> /**
  2783. </span> * @hide
  2784. * Overridden and disabled. A DDTarget does not support being dragged.
  2785. * @method
  2786. */
  2787. removeInvalidHandleClass: Ext.emptyFn,
  2788. <span id='Ext-dd-DDTarget-method-removeInvalidHandleId'> /**
  2789. </span> * @hide
  2790. * Overridden and disabled. A DDTarget does not support being dragged.
  2791. * @method
  2792. */
  2793. removeInvalidHandleId: Ext.emptyFn,
  2794. <span id='Ext-dd-DDTarget-method-removeInvalidHandleType'> /**
  2795. </span> * @hide
  2796. * Overridden and disabled. A DDTarget does not support being dragged.
  2797. * @method
  2798. */
  2799. removeInvalidHandleType: Ext.emptyFn,
  2800. toString: function() {
  2801. return (&quot;DDTarget &quot; + this.id);
  2802. }
  2803. });</pre>
  2804. </body>
  2805. </html>