DD2.html 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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-DD'>/**
  19. </span> * DD implementation for Panels.
  20. * @private
  21. */
  22. Ext.define('Ext.panel.DD', {
  23. extend: 'Ext.dd.DragSource',
  24. requires: ['Ext.panel.Proxy'],
  25. constructor : function(panel, cfg){
  26. var me = this;
  27. me.panel = panel;
  28. me.dragData = {panel: panel};
  29. me.panelProxy = new Ext.panel.Proxy(panel, cfg);
  30. me.proxy = me.panelProxy.proxy;
  31. me.callParent([panel.el, cfg]);
  32. me.setupEl(panel);
  33. },
  34. setupEl: function(panel){
  35. var me = this,
  36. header = panel.header,
  37. el = panel.body;
  38. if (header) {
  39. me.setHandleElId(header.id);
  40. el = header.el;
  41. }
  42. if (el) {
  43. el.setStyle('cursor', 'move');
  44. me.scroll = false;
  45. } else {
  46. // boxready fires after first layout, so we'll definitely be rendered
  47. panel.on('boxready', me.setupEl, me, {single: true});
  48. }
  49. },
  50. showFrame: Ext.emptyFn,
  51. startDrag: Ext.emptyFn,
  52. b4StartDrag: function(x, y) {
  53. this.panelProxy.show();
  54. },
  55. b4MouseDown: function(e) {
  56. var x = e.getPageX(),
  57. y = e.getPageY();
  58. this.autoOffset(x, y);
  59. },
  60. onInitDrag : function(x, y){
  61. this.onStartDrag(x, y);
  62. return true;
  63. },
  64. createFrame : Ext.emptyFn,
  65. getDragEl : function(e){
  66. return this.panelProxy.ghost.el.dom;
  67. },
  68. endDrag : function(e){
  69. this.panelProxy.hide();
  70. this.panel.saveState();
  71. },
  72. autoOffset : function(x, y) {
  73. x -= this.startPageX;
  74. y -= this.startPageY;
  75. this.setDelta(x, y);
  76. },
  77. // Override this, we don't want to repair on an &quot;invalid&quot; drop, the panel
  78. // should main it's position
  79. onInvalidDrop: function(target, e, id) {
  80. var me = this;
  81. me.beforeInvalidDrop(target, e, id);
  82. if (me.cachedTarget) {
  83. if(me.cachedTarget.isNotifyTarget){
  84. me.cachedTarget.notifyOut(me, e, me.dragData);
  85. }
  86. me.cacheTarget = null;
  87. }
  88. if (me.afterInvalidDrop) {
  89. <span id='Ext-panel-DD-method-afterInvalidDrop'> /**
  90. </span> * An empty function by default, but provided so that you can perform a custom action
  91. * after an invalid drop has occurred by providing an implementation.
  92. * @param {Event} e The event object
  93. * @param {String} id The id of the dropped element
  94. * @method afterInvalidDrop
  95. */
  96. me.afterInvalidDrop(e, id);
  97. }
  98. }
  99. });</pre>
  100. </body>
  101. </html>