DragZone2.html 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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-grid-header-DragZone'>/**
  19. </span> * @private
  20. */
  21. Ext.define('Ext.grid.header.DragZone', {
  22. extend: 'Ext.dd.DragZone',
  23. colHeaderCls: Ext.baseCSSPrefix + 'column-header',
  24. maxProxyWidth: 120,
  25. constructor: function(headerCt) {
  26. this.headerCt = headerCt;
  27. this.ddGroup = this.getDDGroup();
  28. this.callParent([headerCt.el]);
  29. this.proxy.el.addCls(Ext.baseCSSPrefix + 'grid-col-dd');
  30. },
  31. getDDGroup: function() {
  32. return 'header-dd-zone-' + this.headerCt.up('[scrollerOwner]').id;
  33. },
  34. getDragData: function(e) {
  35. var header = e.getTarget('.'+this.colHeaderCls),
  36. headerCmp,
  37. ddel;
  38. if (header) {
  39. headerCmp = Ext.getCmp(header.id);
  40. if (!this.headerCt.dragging &amp;&amp; headerCmp.draggable &amp;&amp; !(headerCmp.isOnLeftEdge(e) || headerCmp.isOnRightEdge(e))) {
  41. ddel = document.createElement('div');
  42. ddel.innerHTML = Ext.getCmp(header.id).text;
  43. return {
  44. ddel: ddel,
  45. header: headerCmp
  46. };
  47. }
  48. }
  49. return false;
  50. },
  51. onBeforeDrag: function() {
  52. return !(this.headerCt.dragging || this.disabled);
  53. },
  54. onInitDrag: function() {
  55. this.headerCt.dragging = true;
  56. this.callParent(arguments);
  57. },
  58. onDragDrop: function() {
  59. this.headerCt.dragging = false;
  60. this.callParent(arguments);
  61. },
  62. afterRepair: function() {
  63. this.callParent();
  64. this.headerCt.dragging = false;
  65. },
  66. getRepairXY: function() {
  67. return this.dragData.header.el.getXY();
  68. },
  69. disable: function() {
  70. this.disabled = true;
  71. },
  72. enable: function() {
  73. this.disabled = false;
  74. }
  75. });
  76. </pre>
  77. </body>
  78. </html>