ViewDropZone.html 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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-ViewDropZone'>/**
  19. </span> * @private
  20. */
  21. Ext.define('Ext.grid.ViewDropZone', {
  22. extend: 'Ext.view.DropZone',
  23. indicatorHtml: '&lt;div class=&quot;' + Ext.baseCSSPrefix + 'grid-drop-indicator-left&quot;&gt;&lt;/div&gt;&lt;div class=&quot;' + Ext.baseCSSPrefix + 'grid-drop-indicator-right&quot;&gt;&lt;/div&gt;',
  24. indicatorCls: Ext.baseCSSPrefix + 'grid-drop-indicator',
  25. handleNodeDrop : function(data, record, position) {
  26. var view = this.view,
  27. store = view.getStore(),
  28. index, records, i, len;
  29. // If the copy flag is set, create a copy of the Models with the same IDs
  30. if (data.copy) {
  31. records = data.records;
  32. data.records = [];
  33. for (i = 0, len = records.length; i &lt; len; i++) {
  34. data.records.push(records[i].copy(records[i].getId()));
  35. }
  36. } else {
  37. /*
  38. * Remove from the source store. We do this regardless of whether the store
  39. * is the same bacsue the store currently doesn't handle moving records
  40. * within the store. In the future it should be possible to do this.
  41. * Here was pass the isMove parameter if we're moving to the same view.
  42. */
  43. data.view.store.remove(data.records, data.view === view);
  44. }
  45. index = store.indexOf(record);
  46. // 'after', or undefined (meaning a drop at index -1 on an empty View)...
  47. if (position !== 'before') {
  48. index++;
  49. }
  50. store.insert(index, data.records);
  51. view.getSelectionModel().select(data.records);
  52. }
  53. });</pre>
  54. </body>
  55. </html>