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.

188 lines
6.6 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-StatusProxy-method-constructor'><span id='Ext-dd-StatusProxy'>/**
  19. </span></span> * @class Ext.dd.StatusProxy
  20. * A specialized drag proxy that supports a drop status icon, {@link Ext.Layer} styles and auto-repair. This is the
  21. * default drag proxy used by all Ext.dd components.
  22. * @constructor
  23. * @param {Object} config
  24. */
  25. Ext.dd.StatusProxy = function(config){
  26. Ext.apply(this, config);
  27. this.id = this.id || Ext.id();
  28. this.el = new Ext.Layer({
  29. dh: {
  30. id: this.id, tag: &quot;div&quot;, cls: &quot;x-dd-drag-proxy &quot;+this.dropNotAllowed, children: [
  31. {tag: &quot;div&quot;, cls: &quot;x-dd-drop-icon&quot;},
  32. {tag: &quot;div&quot;, cls: &quot;x-dd-drag-ghost&quot;}
  33. ]
  34. },
  35. shadow: !config || config.shadow !== false
  36. });
  37. this.ghost = Ext.get(this.el.dom.childNodes[1]);
  38. this.dropStatus = this.dropNotAllowed;
  39. };
  40. Ext.dd.StatusProxy.prototype = {
  41. <span id='Ext-dd-StatusProxy-cfg-dropAllowed'> /**
  42. </span> * @cfg {String} dropAllowed
  43. * The CSS class to apply to the status element when drop is allowed (defaults to &quot;x-dd-drop-ok&quot;).
  44. */
  45. dropAllowed : &quot;x-dd-drop-ok&quot;,
  46. <span id='Ext-dd-StatusProxy-cfg-dropNotAllowed'> /**
  47. </span> * @cfg {String} dropNotAllowed
  48. * The CSS class to apply to the status element when drop is not allowed (defaults to &quot;x-dd-drop-nodrop&quot;).
  49. */
  50. dropNotAllowed : &quot;x-dd-drop-nodrop&quot;,
  51. <span id='Ext-dd-StatusProxy-method-setStatus'> /**
  52. </span> * Updates the proxy's visual element to indicate the status of whether or not drop is allowed
  53. * over the current target element.
  54. * @param {String} cssClass The css class for the new drop status indicator image
  55. */
  56. setStatus : function(cssClass){
  57. cssClass = cssClass || this.dropNotAllowed;
  58. if(this.dropStatus != cssClass){
  59. this.el.replaceClass(this.dropStatus, cssClass);
  60. this.dropStatus = cssClass;
  61. }
  62. },
  63. <span id='Ext-dd-StatusProxy-method-reset'> /**
  64. </span> * Resets the status indicator to the default dropNotAllowed value
  65. * @param {Boolean} clearGhost True to also remove all content from the ghost, false to preserve it
  66. */
  67. reset : function(clearGhost){
  68. this.el.dom.className = &quot;x-dd-drag-proxy &quot; + this.dropNotAllowed;
  69. this.dropStatus = this.dropNotAllowed;
  70. if(clearGhost){
  71. this.ghost.update(&quot;&quot;);
  72. }
  73. },
  74. <span id='Ext-dd-StatusProxy-method-update'> /**
  75. </span> * Updates the contents of the ghost element
  76. * @param {String/HTMLElement} html The html that will replace the current innerHTML of the ghost element, or a
  77. * DOM node to append as the child of the ghost element (in which case the innerHTML will be cleared first).
  78. */
  79. update : function(html){
  80. if(typeof html == &quot;string&quot;){
  81. this.ghost.update(html);
  82. }else{
  83. this.ghost.update(&quot;&quot;);
  84. html.style.margin = &quot;0&quot;;
  85. this.ghost.dom.appendChild(html);
  86. }
  87. var el = this.ghost.dom.firstChild;
  88. if(el){
  89. Ext.fly(el).setStyle('float', 'none');
  90. }
  91. },
  92. <span id='Ext-dd-StatusProxy-method-getEl'> /**
  93. </span> * Returns the underlying proxy {@link Ext.Layer}
  94. * @return {Ext.Layer} el
  95. */
  96. getEl : function(){
  97. return this.el;
  98. },
  99. <span id='Ext-dd-StatusProxy-method-getGhost'> /**
  100. </span> * Returns the ghost element
  101. * @return {Ext.Element} el
  102. */
  103. getGhost : function(){
  104. return this.ghost;
  105. },
  106. <span id='Ext-dd-StatusProxy-method-hide'> /**
  107. </span> * Hides the proxy
  108. * @param {Boolean} clear True to reset the status and clear the ghost contents, false to preserve them
  109. */
  110. hide : function(clear){
  111. this.el.hide();
  112. if(clear){
  113. this.reset(true);
  114. }
  115. },
  116. <span id='Ext-dd-StatusProxy-method-stop'> /**
  117. </span> * Stops the repair animation if it's currently running
  118. */
  119. stop : function(){
  120. if(this.anim &amp;&amp; this.anim.isAnimated &amp;&amp; this.anim.isAnimated()){
  121. this.anim.stop();
  122. }
  123. },
  124. <span id='Ext-dd-StatusProxy-method-show'> /**
  125. </span> * Displays this proxy
  126. */
  127. show : function(){
  128. this.el.show();
  129. },
  130. <span id='Ext-dd-StatusProxy-method-sync'> /**
  131. </span> * Force the Layer to sync its shadow and shim positions to the element
  132. */
  133. sync : function(){
  134. this.el.sync();
  135. },
  136. <span id='Ext-dd-StatusProxy-method-repair'> /**
  137. </span> * Causes the proxy to return to its position of origin via an animation. Should be called after an
  138. * invalid drop operation by the item being dragged.
  139. * @param {Array} xy The XY position of the element ([x, y])
  140. * @param {Function} callback The function to call after the repair is complete.
  141. * @param {Object} scope The scope (&lt;code&gt;this&lt;/code&gt; reference) in which the callback function is executed. Defaults to the browser window.
  142. */
  143. repair : function(xy, callback, scope){
  144. this.callback = callback;
  145. this.scope = scope;
  146. if(xy &amp;&amp; this.animRepair !== false){
  147. this.el.addClass(&quot;x-dd-drag-repair&quot;);
  148. this.el.hideUnders(true);
  149. this.anim = this.el.shift({
  150. duration: this.repairDuration || .5,
  151. easing: 'easeOut',
  152. xy: xy,
  153. stopFx: true,
  154. callback: this.afterRepair,
  155. scope: this
  156. });
  157. }else{
  158. this.afterRepair();
  159. }
  160. },
  161. // private
  162. afterRepair : function(){
  163. this.hide(true);
  164. if(typeof this.callback == &quot;function&quot;){
  165. this.callback.call(this.scope || this);
  166. }
  167. this.callback = null;
  168. this.scope = null;
  169. },
  170. destroy: function(){
  171. Ext.destroy(this.ghost, this.el);
  172. }
  173. };</pre>
  174. </body>
  175. </html>