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.

171 lines
5.5 KiB

2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>The source code</title>
  6. <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  7. <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  8. <style type="text/css">
  9. .highlight { display: block; background-color: #ddd; }
  10. </style>
  11. <script type="text/javascript">
  12. function highlight() {
  13. document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
  14. }
  15. </script>
  16. </head>
  17. <body onload="prettyPrint(); highlight();">
  18. <pre class="prettyprint lang-js"><span id='Ext-dd-PanelProxy-method-constructor'><span id='Ext-dd-PanelProxy'>/**
  19. </span></span> * @class Ext.dd.PanelProxy
  20. * A custom drag proxy implementation specific to {@link Ext.Panel}s. This class is primarily used internally
  21. * for the Panel's drag drop implementation, and should never need to be created directly.
  22. * @constructor
  23. * @param panel The {@link Ext.Panel} to proxy for
  24. * @param config Configuration options
  25. */
  26. Ext.dd.PanelProxy = Ext.extend(Object, {
  27. constructor : function(panel, config){
  28. this.panel = panel;
  29. this.id = this.panel.id +'-ddproxy';
  30. Ext.apply(this, config);
  31. },
  32. <span id='Ext-dd-PanelProxy-cfg-insertProxy'> /**
  33. </span> * @cfg {Boolean} insertProxy True to insert a placeholder proxy element while dragging the panel,
  34. * false to drag with no proxy (defaults to true).
  35. */
  36. insertProxy : true,
  37. <span id='Ext-dd-PanelProxy-method-setStatus'> // private overrides
  38. </span> setStatus : Ext.emptyFn,
  39. <span id='Ext-dd-PanelProxy-method-reset'> reset : Ext.emptyFn,
  40. </span><span id='Ext-dd-PanelProxy-method-update'> update : Ext.emptyFn,
  41. </span><span id='Ext-dd-PanelProxy-method-stop'> stop : Ext.emptyFn,
  42. </span><span id='Ext-dd-PanelProxy-method-sync'> sync: Ext.emptyFn,
  43. </span>
  44. <span id='Ext-dd-PanelProxy-method-getEl'> /**
  45. </span> * Gets the proxy's element
  46. * @return {Element} The proxy's element
  47. */
  48. getEl : function(){
  49. return this.ghost;
  50. },
  51. <span id='Ext-dd-PanelProxy-method-getGhost'> /**
  52. </span> * Gets the proxy's ghost element
  53. * @return {Element} The proxy's ghost element
  54. */
  55. getGhost : function(){
  56. return this.ghost;
  57. },
  58. <span id='Ext-dd-PanelProxy-method-getProxy'> /**
  59. </span> * Gets the proxy's element
  60. * @return {Element} The proxy's element
  61. */
  62. getProxy : function(){
  63. return this.proxy;
  64. },
  65. <span id='Ext-dd-PanelProxy-method-hide'> /**
  66. </span> * Hides the proxy
  67. */
  68. hide : function(){
  69. if(this.ghost){
  70. if(this.proxy){
  71. this.proxy.remove();
  72. delete this.proxy;
  73. }
  74. this.panel.el.dom.style.display = '';
  75. this.ghost.remove();
  76. delete this.ghost;
  77. }
  78. },
  79. <span id='Ext-dd-PanelProxy-method-show'> /**
  80. </span> * Shows the proxy
  81. */
  82. show : function(){
  83. if(!this.ghost){
  84. this.ghost = this.panel.createGhost(this.panel.initialConfig.cls, undefined, Ext.getBody());
  85. this.ghost.setXY(this.panel.el.getXY());
  86. if(this.insertProxy){
  87. this.proxy = this.panel.el.insertSibling({cls:'x-panel-dd-spacer'});
  88. this.proxy.setSize(this.panel.getSize());
  89. }
  90. this.panel.el.dom.style.display = 'none';
  91. }
  92. },
  93. <span id='Ext-dd-PanelProxy-method-repair'> // private
  94. </span> repair : function(xy, callback, scope){
  95. this.hide();
  96. if(typeof callback == &quot;function&quot;){
  97. callback.call(scope || this);
  98. }
  99. },
  100. <span id='Ext-dd-PanelProxy-method-moveProxy'> /**
  101. </span> * Moves the proxy to a different position in the DOM. This is typically called while dragging the Panel
  102. * to keep the proxy sync'd to the Panel's location.
  103. * @param {HTMLElement} parentNode The proxy's parent DOM node
  104. * @param {HTMLElement} before (optional) The sibling node before which the proxy should be inserted (defaults
  105. * to the parent's last child if not specified)
  106. */
  107. moveProxy : function(parentNode, before){
  108. if(this.proxy){
  109. parentNode.insertBefore(this.proxy.dom, before);
  110. }
  111. }
  112. });
  113. // private - DD implementation for Panels
  114. Ext.Panel.DD = Ext.extend(Ext.dd.DragSource, {
  115. constructor : function(panel, cfg){
  116. this.panel = panel;
  117. this.dragData = {panel: panel};
  118. this.proxy = new Ext.dd.PanelProxy(panel, cfg);
  119. Ext.Panel.DD.superclass.constructor.call(this, panel.el, cfg);
  120. var h = panel.header,
  121. el = panel.body;
  122. if(h){
  123. this.setHandleElId(h.id);
  124. el = panel.header;
  125. }
  126. el.setStyle('cursor', 'move');
  127. this.scroll = false;
  128. },
  129. showFrame: Ext.emptyFn,
  130. startDrag: Ext.emptyFn,
  131. b4StartDrag: function(x, y) {
  132. this.proxy.show();
  133. },
  134. b4MouseDown: function(e) {
  135. var x = e.getPageX(),
  136. y = e.getPageY();
  137. this.autoOffset(x, y);
  138. },
  139. onInitDrag : function(x, y){
  140. this.onStartDrag(x, y);
  141. return true;
  142. },
  143. createFrame : Ext.emptyFn,
  144. getDragEl : function(e){
  145. return this.proxy.ghost.dom;
  146. },
  147. endDrag : function(e){
  148. this.proxy.hide();
  149. this.panel.saveState();
  150. },
  151. autoOffset : function(x, y) {
  152. x -= this.startPageX;
  153. y -= this.startPageY;
  154. this.setDelta(x, y);
  155. }
  156. });</pre>
  157. </body>
  158. </html>