Web UI for ARGUS server
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.

271 lines
14 KiB

6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4. <title>The source code</title>
  5. <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  6. <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  7. </head>
  8. <body onload="prettyPrint();">
  9. <pre class="prettyprint lang-js">/*!
  10. * Ext JS Library 3.3.1
  11. * Copyright(c) 2006-2010 Sencha Inc.
  12. * licensing@sencha.com
  13. * http://www.sencha.com/license
  14. */
  15. <div id="cls-Ext.dd.DropZone"></div>/**
  16. * @class Ext.dd.DropZone
  17. * @extends Ext.dd.DropTarget
  18. * <p>This class provides a container DD instance that allows dropping on multiple child target nodes.</p>
  19. * <p>By default, this class requires that child nodes accepting drop are registered with {@link Ext.dd.Registry}.
  20. * However a simpler way to allow a DropZone to manage any number of target elements is to configure the
  21. * DropZone with an implementation of {@link #getTargetFromEvent} which interrogates the passed
  22. * mouse event to see if it has taken place within an element, or class of elements. This is easily done
  23. * by using the event's {@link Ext.EventObject#getTarget getTarget} method to identify a node based on a
  24. * {@link Ext.DomQuery} selector.</p>
  25. * <p>Once the DropZone has detected through calling getTargetFromEvent, that the mouse is over
  26. * a drop target, that target is passed as the first parameter to {@link #onNodeEnter}, {@link #onNodeOver},
  27. * {@link #onNodeOut}, {@link #onNodeDrop}. You may configure the instance of DropZone with implementations
  28. * of these methods to provide application-specific behaviour for these events to update both
  29. * application state, and UI state.</p>
  30. * <p>For example to make a GridPanel a cooperating target with the example illustrated in
  31. * {@link Ext.dd.DragZone DragZone}, the following technique might be used:</p><pre><code>
  32. myGridPanel.on('render', function() {
  33. myGridPanel.dropZone = new Ext.dd.DropZone(myGridPanel.getView().scroller, {
  34. // If the mouse is over a grid row, return that node. This is
  35. // provided as the "target" parameter in all "onNodeXXXX" node event handling functions
  36. getTargetFromEvent: function(e) {
  37. return e.getTarget(myGridPanel.getView().rowSelector);
  38. },
  39. // On entry into a target node, highlight that node.
  40. onNodeEnter : function(target, dd, e, data){
  41. Ext.fly(target).addClass('my-row-highlight-class');
  42. },
  43. // On exit from a target node, unhighlight that node.
  44. onNodeOut : function(target, dd, e, data){
  45. Ext.fly(target).removeClass('my-row-highlight-class');
  46. },
  47. // While over a target node, return the default drop allowed class which
  48. // places a "tick" icon into the drag proxy.
  49. onNodeOver : function(target, dd, e, data){
  50. return Ext.dd.DropZone.prototype.dropAllowed;
  51. },
  52. // On node drop we can interrogate the target to find the underlying
  53. // application object that is the real target of the dragged data.
  54. // In this case, it is a Record in the GridPanel's Store.
  55. // We can use the data set up by the DragZone's getDragData method to read
  56. // any data we decided to attach in the DragZone's getDragData method.
  57. onNodeDrop : function(target, dd, e, data){
  58. var rowIndex = myGridPanel.getView().findRowIndex(target);
  59. var r = myGridPanel.getStore().getAt(rowIndex);
  60. Ext.Msg.alert('Drop gesture', 'Dropped Record id ' + data.draggedRecord.id +
  61. ' on Record id ' + r.id);
  62. return true;
  63. }
  64. });
  65. }
  66. </code></pre>
  67. * See the {@link Ext.dd.DragZone DragZone} documentation for details about building a DragZone which
  68. * cooperates with this DropZone.
  69. * @constructor
  70. * @param {Mixed} el The container element
  71. * @param {Object} config
  72. */
  73. Ext.dd.DropZone = function(el, config){
  74. Ext.dd.DropZone.superclass.constructor.call(this, el, config);
  75. };
  76. Ext.extend(Ext.dd.DropZone, Ext.dd.DropTarget, {
  77. <div id="method-Ext.dd.DropZone-getTargetFromEvent"></div>/**
  78. * Returns a custom data object associated with the DOM node that is the target of the event. By default
  79. * this looks up the event target in the {@link Ext.dd.Registry}, although you can override this method to
  80. * provide your own custom lookup.
  81. * @param {Event} e The event
  82. * @return {Object} data The custom data
  83. */
  84. getTargetFromEvent : function(e){
  85. return Ext.dd.Registry.getTargetFromEvent(e);
  86. },
  87. <div id="method-Ext.dd.DropZone-onNodeEnter"></div>/**
  88. * Called when the DropZone determines that a {@link Ext.dd.DragSource} has entered a drop node
  89. * that has either been registered or detected by a configured implementation of {@link #getTargetFromEvent}.
  90. * This method has no default implementation and should be overridden to provide
  91. * node-specific processing if necessary.
  92. * @param {Object} nodeData The custom data associated with the drop node (this is the same value returned from
  93. * {@link #getTargetFromEvent} for this node)
  94. * @param {Ext.dd.DragSource} source The drag source that was dragged over this drop zone
  95. * @param {Event} e The event
  96. * @param {Object} data An object containing arbitrary data supplied by the drag source
  97. */
  98. onNodeEnter : function(n, dd, e, data){
  99. },
  100. <div id="method-Ext.dd.DropZone-onNodeOver"></div>/**
  101. * Called while the DropZone determines that a {@link Ext.dd.DragSource} is over a drop node
  102. * that has either been registered or detected by a configured implementation of {@link #getTargetFromEvent}.
  103. * The default implementation returns this.dropNotAllowed, so it should be
  104. * overridden to provide the proper feedback.
  105. * @param {Object} nodeData The custom data associated with the drop node (this is the same value returned from
  106. * {@link #getTargetFromEvent} for this node)
  107. * @param {Ext.dd.DragSource} source The drag source that was dragged over this drop zone
  108. * @param {Event} e The event
  109. * @param {Object} data An object containing arbitrary data supplied by the drag source
  110. * @return {String} status The CSS class that communicates the drop status back to the source so that the
  111. * underlying {@link Ext.dd.StatusProxy} can be updated
  112. */
  113. onNodeOver : function(n, dd, e, data){
  114. return this.dropAllowed;
  115. },
  116. <div id="method-Ext.dd.DropZone-onNodeOut"></div>/**
  117. * Called when the DropZone determines that a {@link Ext.dd.DragSource} has been dragged out of
  118. * the drop node without dropping. This method has no default implementation and should be overridden to provide
  119. * node-specific processing if necessary.
  120. * @param {Object} nodeData The custom data associated with the drop node (this is the same value returned from
  121. * {@link #getTargetFromEvent} for this node)
  122. * @param {Ext.dd.DragSource} source The drag source that was dragged over this drop zone
  123. * @param {Event} e The event
  124. * @param {Object} data An object containing arbitrary data supplied by the drag source
  125. */
  126. onNodeOut : function(n, dd, e, data){
  127. },
  128. <div id="method-Ext.dd.DropZone-onNodeDrop"></div>/**
  129. * Called when the DropZone determines that a {@link Ext.dd.DragSource} has been dropped onto
  130. * the drop node. The default implementation returns false, so it should be overridden to provide the
  131. * appropriate processing of the drop event and return true so that the drag source's repair action does not run.
  132. * @param {Object} nodeData The custom data associated with the drop node (this is the same value returned from
  133. * {@link #getTargetFromEvent} for this node)
  134. * @param {Ext.dd.DragSource} source The drag source that was dragged over this drop zone
  135. * @param {Event} e The event
  136. * @param {Object} data An object containing arbitrary data supplied by the drag source
  137. * @return {Boolean} True if the drop was valid, else false
  138. */
  139. onNodeDrop : function(n, dd, e, data){
  140. return false;
  141. },
  142. <div id="method-Ext.dd.DropZone-onContainerOver"></div>/**
  143. * Called while the DropZone determines that a {@link Ext.dd.DragSource} is being dragged over it,
  144. * but not over any of its registered drop nodes. The default implementation returns this.dropNotAllowed, so
  145. * it should be overridden to provide the proper feedback if necessary.
  146. * @param {Ext.dd.DragSource} source The drag source that was dragged over this drop zone
  147. * @param {Event} e The event
  148. * @param {Object} data An object containing arbitrary data supplied by the drag source
  149. * @return {String} status The CSS class that communicates the drop status back to the source so that the
  150. * underlying {@link Ext.dd.StatusProxy} can be updated
  151. */
  152. onContainerOver : function(dd, e, data){
  153. return this.dropNotAllowed;
  154. },
  155. <div id="method-Ext.dd.DropZone-onContainerDrop"></div>/**
  156. * Called when the DropZone determines that a {@link Ext.dd.DragSource} has been dropped on it,
  157. * but not on any of its registered drop nodes. The default implementation returns false, so it should be
  158. * overridden to provide the appropriate processing of the drop event if you need the drop zone itself to
  159. * be able to accept drops. It should return true when valid so that the drag source's repair action does not run.
  160. * @param {Ext.dd.DragSource} source The drag source that was dragged over this drop zone
  161. * @param {Event} e The event
  162. * @param {Object} data An object containing arbitrary data supplied by the drag source
  163. * @return {Boolean} True if the drop was valid, else false
  164. */
  165. onContainerDrop : function(dd, e, data){
  166. return false;
  167. },
  168. <div id="method-Ext.dd.DropZone-notifyEnter"></div>/**
  169. * The function a {@link Ext.dd.DragSource} calls once to notify this drop zone that the source is now over
  170. * the zone. The default implementation returns this.dropNotAllowed and expects that only registered drop
  171. * nodes can process drag drop operations, so if you need the drop zone itself to be able to process drops
  172. * you should override this method and provide a custom implementation.
  173. * @param {Ext.dd.DragSource} source The drag source that was dragged over this drop zone
  174. * @param {Event} e The event
  175. * @param {Object} data An object containing arbitrary data supplied by the drag source
  176. * @return {String} status The CSS class that communicates the drop status back to the source so that the
  177. * underlying {@link Ext.dd.StatusProxy} can be updated
  178. */
  179. notifyEnter : function(dd, e, data){
  180. return this.dropNotAllowed;
  181. },
  182. <div id="method-Ext.dd.DropZone-notifyOver"></div>/**
  183. * The function a {@link Ext.dd.DragSource} calls continuously while it is being dragged over the drop zone.
  184. * This method will be called on every mouse movement while the drag source is over the drop zone.
  185. * It will call {@link #onNodeOver} while the drag source is over a registered node, and will also automatically
  186. * delegate to the appropriate node-specific methods as necessary when the drag source enters and exits
  187. * registered nodes ({@link #onNodeEnter}, {@link #onNodeOut}). If the drag source is not currently over a
  188. * registered node, it will call {@link #onContainerOver}.
  189. * @param {Ext.dd.DragSource} source The drag source that was dragged over this drop zone
  190. * @param {Event} e The event
  191. * @param {Object} data An object containing arbitrary data supplied by the drag source
  192. * @return {String} status The CSS class that communicates the drop status back to the source so that the
  193. * underlying {@link Ext.dd.StatusProxy} can be updated
  194. */
  195. notifyOver : function(dd, e, data){
  196. var n = this.getTargetFromEvent(e);
  197. if(!n){ // not over valid drop target
  198. if(this.lastOverNode){
  199. this.onNodeOut(this.lastOverNode, dd, e, data);
  200. this.lastOverNode = null;
  201. }
  202. return this.onContainerOver(dd, e, data);
  203. }
  204. if(this.lastOverNode != n){
  205. if(this.lastOverNode){
  206. this.onNodeOut(this.lastOverNode, dd, e, data);
  207. }
  208. this.onNodeEnter(n, dd, e, data);
  209. this.lastOverNode = n;
  210. }
  211. return this.onNodeOver(n, dd, e, data);
  212. },
  213. <div id="method-Ext.dd.DropZone-notifyOut"></div>/**
  214. * The function a {@link Ext.dd.DragSource} calls once to notify this drop zone that the source has been dragged
  215. * out of the zone without dropping. If the drag source is currently over a registered node, the notification
  216. * will be delegated to {@link #onNodeOut} for node-specific handling, otherwise it will be ignored.
  217. * @param {Ext.dd.DragSource} source The drag source that was dragged over this drop target
  218. * @param {Event} e The event
  219. * @param {Object} data An object containing arbitrary data supplied by the drag zone
  220. */
  221. notifyOut : function(dd, e, data){
  222. if(this.lastOverNode){
  223. this.onNodeOut(this.lastOverNode, dd, e, data);
  224. this.lastOverNode = null;
  225. }
  226. },
  227. <div id="method-Ext.dd.DropZone-notifyDrop"></div>/**
  228. * The function a {@link Ext.dd.DragSource} calls once to notify this drop zone that the dragged item has
  229. * been dropped on it. The drag zone will look up the target node based on the event passed in, and if there
  230. * is a node registered for that event, it will delegate to {@link #onNodeDrop} for node-specific handling,
  231. * otherwise it will call {@link #onContainerDrop}.
  232. * @param {Ext.dd.DragSource} source The drag source that was dragged over this drop zone
  233. * @param {Event} e The event
  234. * @param {Object} data An object containing arbitrary data supplied by the drag source
  235. * @return {Boolean} True if the drop was valid, else false
  236. */
  237. notifyDrop : function(dd, e, data){
  238. if(this.lastOverNode){
  239. this.onNodeOut(this.lastOverNode, dd, e, data);
  240. this.lastOverNode = null;
  241. }
  242. var n = this.getTargetFromEvent(e);
  243. return n ?
  244. this.onNodeDrop(n, dd, e, data) :
  245. this.onContainerDrop(dd, e, data);
  246. },
  247. // private
  248. triggerCacheRefresh : function(){
  249. Ext.dd.DDM.refreshCache(this.groups);
  250. }
  251. });</pre>
  252. </body>
  253. </html>