/javascripts/lib/docs/source/PanelDD.html

https://bitbucket.org/ksokmesa/sina-asian · HTML · 164 lines · 152 code · 12 blank · 0 comment · 0 complexity · fc7370d6955241034365031f5e6dd832 MD5 · raw file

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