Proxy.html 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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-panel-Proxy'>/**
  19. </span> * A custom drag proxy implementation specific to {@link Ext.panel.Panel}s. This class
  20. * is primarily used internally for the Panel's drag drop implementation, and
  21. * should never need to be created directly.
  22. * @private
  23. */
  24. Ext.define('Ext.panel.Proxy', {
  25. alternateClassName: 'Ext.dd.PanelProxy',
  26. <span id='Ext-panel-Proxy-cfg-moveOnDrag'> /**
  27. </span> * @cfg {Boolean} [moveOnDrag=true]
  28. * True to move the panel to the dragged position when dropped
  29. */
  30. moveOnDrag: true,
  31. <span id='Ext-panel-Proxy-method-constructor'> /**
  32. </span> * Creates new panel proxy.
  33. * @param {Ext.panel.Panel} panel The {@link Ext.panel.Panel} to proxy for
  34. * @param {Object} [config] Config object
  35. */
  36. constructor: function(panel, config){
  37. var me = this;
  38. <span id='Ext-panel-Proxy-property-panel'> /**
  39. </span> * @property panel
  40. * @type Ext.panel.Panel
  41. */
  42. me.panel = panel;
  43. me.id = me.panel.id +'-ddproxy';
  44. Ext.apply(me, config);
  45. },
  46. <span id='Ext-panel-Proxy-cfg-insertProxy'> /**
  47. </span> * @cfg {Boolean} insertProxy
  48. * True to insert a placeholder proxy element while dragging the panel, false to drag with no proxy.
  49. * Most Panels are not absolute positioned and therefore we need to reserve this space.
  50. */
  51. insertProxy: true,
  52. // private overrides
  53. setStatus: Ext.emptyFn,
  54. reset: Ext.emptyFn,
  55. update: Ext.emptyFn,
  56. stop: Ext.emptyFn,
  57. sync: Ext.emptyFn,
  58. <span id='Ext-panel-Proxy-method-getEl'> /**
  59. </span> * Gets the proxy's element
  60. * @return {Ext.Element} The proxy's element
  61. */
  62. getEl: function(){
  63. return this.ghost.el;
  64. },
  65. <span id='Ext-panel-Proxy-method-getGhost'> /**
  66. </span> * Gets the proxy's ghost Panel
  67. * @return {Ext.panel.Panel} The proxy's ghost Panel
  68. */
  69. getGhost: function(){
  70. return this.ghost;
  71. },
  72. <span id='Ext-panel-Proxy-method-getProxy'> /**
  73. </span> * Gets the proxy element. This is the element that represents where the
  74. * Panel was before we started the drag operation.
  75. * @return {Ext.Element} The proxy's element
  76. */
  77. getProxy: function(){
  78. return this.proxy;
  79. },
  80. <span id='Ext-panel-Proxy-method-hide'> /**
  81. </span> * Hides the proxy
  82. */
  83. hide : function(){
  84. var me = this;
  85. if (me.ghost) {
  86. if (me.proxy) {
  87. me.proxy.remove();
  88. delete me.proxy;
  89. }
  90. // Unghost the Panel, do not move the Panel to where the ghost was
  91. me.panel.unghost(null, me.moveOnDrag);
  92. delete me.ghost;
  93. }
  94. },
  95. <span id='Ext-panel-Proxy-method-show'> /**
  96. </span> * Shows the proxy
  97. */
  98. show: function(){
  99. var me = this,
  100. panelSize;
  101. if (!me.ghost) {
  102. panelSize = me.panel.getSize();
  103. me.panel.el.setVisibilityMode(Ext.Element.DISPLAY);
  104. me.ghost = me.panel.ghost();
  105. if (me.insertProxy) {
  106. // bc Panels aren't absolute positioned we need to take up the space
  107. // of where the panel previously was
  108. me.proxy = me.panel.el.insertSibling({cls: Ext.baseCSSPrefix + 'panel-dd-spacer'});
  109. me.proxy.setSize(panelSize);
  110. }
  111. }
  112. },
  113. // private
  114. repair: function(xy, callback, scope) {
  115. this.hide();
  116. Ext.callback(callback, scope || this);
  117. },
  118. <span id='Ext-panel-Proxy-method-moveProxy'> /**
  119. </span> * Moves the proxy to a different position in the DOM. This is typically
  120. * called while dragging the Panel to keep the proxy sync'd to the Panel's
  121. * location.
  122. * @param {HTMLElement} parentNode The proxy's parent DOM node
  123. * @param {HTMLElement} [before] The sibling node before which the
  124. * proxy should be inserted. Defaults to the parent's last child if not
  125. * specified.
  126. */
  127. moveProxy : function(parentNode, before){
  128. if (this.proxy) {
  129. parentNode.insertBefore(this.proxy.dom, before);
  130. }
  131. }
  132. });
  133. </pre>
  134. </body>
  135. </html>