Web Interface For Lite Argus Control modules
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.

150 lines
6.7 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  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.DragZone"></div>/**
  16. * @class Ext.dd.DragZone
  17. * @extends Ext.dd.DragSource
  18. * <p>This class provides a container DD instance that allows dragging of multiple child source nodes.</p>
  19. * <p>This class does not move the drag target nodes, but a proxy element which may contain
  20. * any DOM structure you wish. The DOM element to show in the proxy is provided by either a
  21. * provided implementation of {@link #getDragData}, or by registered draggables registered with {@link Ext.dd.Registry}</p>
  22. * <p>If you wish to provide draggability for an arbitrary number of DOM nodes, each of which represent some
  23. * application object (For example nodes in a {@link Ext.DataView DataView}) then use of this class
  24. * is the most efficient way to "activate" those nodes.</p>
  25. * <p>By default, this class requires that draggable child nodes are registered with {@link Ext.dd.Registry}.
  26. * However a simpler way to allow a DragZone to manage any number of draggable elements is to configure
  27. * the DragZone with an implementation of the {@link #getDragData} method which interrogates the passed
  28. * mouse event to see if it has taken place within an element, or class of elements. This is easily done
  29. * by using the event's {@link Ext.EventObject#getTarget getTarget} method to identify a node based on a
  30. * {@link Ext.DomQuery} selector. For example, to make the nodes of a DataView draggable, use the following
  31. * technique. Knowledge of the use of the DataView is required:</p><pre><code>
  32. myDataView.on('render', function(v) {
  33. myDataView.dragZone = new Ext.dd.DragZone(v.getEl(), {
  34. // On receipt of a mousedown event, see if it is within a DataView node.
  35. // Return a drag data object if so.
  36. getDragData: function(e) {
  37. // Use the DataView's own itemSelector (a mandatory property) to
  38. // test if the mousedown is within one of the DataView's nodes.
  39. var sourceEl = e.getTarget(v.itemSelector, 10);
  40. // If the mousedown is within a DataView node, clone the node to produce
  41. // a ddel element for use by the drag proxy. Also add application data
  42. // to the returned data object.
  43. if (sourceEl) {
  44. d = sourceEl.cloneNode(true);
  45. d.id = Ext.id();
  46. return {
  47. ddel: d,
  48. sourceEl: sourceEl,
  49. repairXY: Ext.fly(sourceEl).getXY(),
  50. sourceStore: v.store,
  51. draggedRecord: v.{@link Ext.DataView#getRecord getRecord}(sourceEl)
  52. }
  53. }
  54. },
  55. // Provide coordinates for the proxy to slide back to on failed drag.
  56. // This is the original XY coordinates of the draggable element captured
  57. // in the getDragData method.
  58. getRepairXY: function() {
  59. return this.dragData.repairXY;
  60. }
  61. });
  62. });</code></pre>
  63. * See the {@link Ext.dd.DropZone DropZone} documentation for details about building a DropZone which
  64. * cooperates with this DragZone.
  65. * @constructor
  66. * @param {Mixed} el The container element
  67. * @param {Object} config
  68. */
  69. Ext.dd.DragZone = Ext.extend(Ext.dd.DragSource, {
  70. constructor : function(el, config){
  71. Ext.dd.DragZone.superclass.constructor.call(this, el, config);
  72. if(this.containerScroll){
  73. Ext.dd.ScrollManager.register(this.el);
  74. }
  75. },
  76. <div id="prop-Ext.dd.DragZone-dragData"></div>/**
  77. * This property contains the data representing the dragged object. This data is set up by the implementation
  78. * of the {@link #getDragData} method. It must contain a <tt>ddel</tt> property, but can contain
  79. * any other data according to the application's needs.
  80. * @type Object
  81. * @property dragData
  82. */
  83. <div id="cfg-Ext.dd.DragZone-containerScroll"></div>/**
  84. * @cfg {Boolean} containerScroll True to register this container with the Scrollmanager
  85. * for auto scrolling during drag operations.
  86. */
  87. <div id="cfg-Ext.dd.DragZone-hlColor"></div>/**
  88. * @cfg {String} hlColor The color to use when visually highlighting the drag source in the afterRepair
  89. * method after a failed drop (defaults to "c3daf9" - light blue)
  90. */
  91. <div id="method-Ext.dd.DragZone-getDragData"></div>/**
  92. * Called when a mousedown occurs in this container. Looks in {@link Ext.dd.Registry}
  93. * for a valid target to drag based on the mouse down. Override this method
  94. * to provide your own lookup logic (e.g. finding a child by class name). Make sure your returned
  95. * object has a "ddel" attribute (with an HTML Element) for other functions to work.
  96. * @param {EventObject} e The mouse down event
  97. * @return {Object} The dragData
  98. */
  99. getDragData : function(e){
  100. return Ext.dd.Registry.getHandleFromEvent(e);
  101. },
  102. <div id="method-Ext.dd.DragZone-onInitDrag"></div>/**
  103. * Called once drag threshold has been reached to initialize the proxy element. By default, it clones the
  104. * this.dragData.ddel
  105. * @param {Number} x The x position of the click on the dragged object
  106. * @param {Number} y The y position of the click on the dragged object
  107. * @return {Boolean} true to continue the drag, false to cancel
  108. */
  109. onInitDrag : function(x, y){
  110. this.proxy.update(this.dragData.ddel.cloneNode(true));
  111. this.onStartDrag(x, y);
  112. return true;
  113. },
  114. <div id="method-Ext.dd.DragZone-afterRepair"></div>/**
  115. * Called after a repair of an invalid drop. By default, highlights this.dragData.ddel
  116. */
  117. afterRepair : function(){
  118. if(Ext.enableFx){
  119. Ext.Element.fly(this.dragData.ddel).highlight(this.hlColor || "c3daf9");
  120. }
  121. this.dragging = false;
  122. },
  123. <div id="method-Ext.dd.DragZone-getRepairXY"></div>/**
  124. * Called before a repair of an invalid drop to get the XY to animate to. By default returns
  125. * the XY of this.dragData.ddel
  126. * @param {EventObject} e The mouse up event
  127. * @return {Array} The xy location (e.g. [100, 200])
  128. */
  129. getRepairXY : function(e){
  130. return Ext.Element.fly(this.dragData.ddel).getXY();
  131. },
  132. destroy : function(){
  133. Ext.dd.DragZone.superclass.destroy.call(this);
  134. if(this.containerScroll){
  135. Ext.dd.ScrollManager.unregister(this.el);
  136. }
  137. }
  138. });</pre>
  139. </body>
  140. </html>