@refinitiv-ui/efx-grid 6.0.2 → 6.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/column-dragging/es6/ColumnDragging.d.ts +49 -0
- package/lib/column-dragging/es6/ColumnDragging.js +764 -0
- package/lib/column-dragging/es6/index.d.ts +1 -0
- package/lib/column-dragging/es6/index.js +1 -0
- package/lib/column-format-dialog/lib/column-format-dialog.d.ts +13 -1
- package/lib/column-selection-dialog/lib/column-selection-dialog.d.ts +15 -2
- package/lib/column-selection-dialog/lib/column-selection-dialog.js +146 -5
- package/lib/core/dist/core.css +1 -1
- package/lib/core/dist/core.js +468 -1092
- package/lib/core/dist/core.min.js +1 -1
- package/lib/core/es6/data/ColumnStats.d.ts +2 -2
- package/lib/core/es6/data/DataCache.d.ts +4 -4
- package/lib/core/es6/data/DataTable.d.ts +5 -5
- package/lib/core/es6/data/DataTable.js +33 -11
- package/lib/core/es6/data/DataView.d.ts +12 -18
- package/lib/core/es6/data/DataView.js +0 -4
- package/lib/core/es6/data/Segment.d.ts +2 -0
- package/lib/core/es6/data/Segment.js +7 -0
- package/lib/core/es6/data/SegmentCollection.d.ts +3 -3
- package/lib/core/es6/data/WrappedView.d.ts +13 -13
- package/lib/core/es6/data/WrappedView.js +6 -6
- package/lib/core/es6/grid/Core.d.ts +31 -27
- package/lib/core/es6/grid/Core.js +47 -11
- package/lib/core/es6/grid/ILayoutGrid.d.ts +15 -15
- package/lib/core/es6/grid/LayoutGrid.js +54 -26
- package/lib/core/es6/grid/VirtualizedLayoutGrid.js +71 -0
- package/lib/core/es6/grid/components/Cell.d.ts +4 -4
- package/lib/core/es6/grid/components/CellFloatingPanel.d.ts +1 -1
- package/lib/core/es6/grid/components/CellSpans.d.ts +8 -8
- package/lib/core/es6/grid/components/Column.d.ts +1 -1
- package/lib/core/es6/grid/components/ElementWrapper.d.ts +6 -6
- package/lib/core/es6/grid/components/Scrollbar.d.ts +3 -1
- package/lib/core/es6/grid/components/Scrollbar.js +13 -0
- package/lib/core/es6/grid/components/StretchedCells.js +2 -2
- package/lib/core/es6/grid/plugins/SortableTitlePlugin.d.ts +14 -6
- package/lib/core/es6/grid/plugins/SortableTitlePlugin.js +147 -81
- package/lib/core/es6/grid/util/Conflator.d.ts +2 -2
- package/lib/core/es6/grid/util/ElementFrameWork.d.ts +3 -3
- package/lib/core/es6/grid/util/HttpRequest.d.ts +2 -2
- package/lib/core/es6/grid/util/PercentBarRenderer.d.ts +1 -1
- package/lib/core/es6/grid/util/RangeBar.d.ts +1 -1
- package/lib/core/es6/grid/util/SectionSettings.d.ts +5 -5
- package/lib/core/es6/grid/util/SectionSettings.js +5 -0
- package/lib/core/es6/grid/util/SelectionList.d.ts +2 -2
- package/lib/core/es6/grid/util/TrackLayout.d.ts +7 -3
- package/lib/core/es6/grid/util/TrackLayout.js +27 -0
- package/lib/core/es6/grid/util/util.d.ts +2 -2
- package/lib/core/es6/index.d.ts +1 -5
- package/lib/core/es6/index.js +1 -7
- package/lib/core/es6/tr-grid-theme.js +1 -1
- package/lib/filter-dialog/lib/checkbox-list.d.ts +13 -1
- package/lib/filter-dialog/lib/filter-dialog.d.ts +14 -1
- package/lib/filter-dialog/lib/filter-dialog.js +86 -26
- package/lib/filter-dialog/themes/base-checkbox.less +8 -1
- package/lib/filter-dialog/themes/base.less +69 -1
- package/lib/filter-dialog/themes/elemental/dark/checkbox-list.js +1 -1
- package/lib/filter-dialog/themes/elemental/dark/es5/all-elements.js +2 -2
- package/lib/filter-dialog/themes/elemental/dark/filter-dialog.js +1 -1
- package/lib/filter-dialog/themes/elemental/light/checkbox-list.js +1 -1
- package/lib/filter-dialog/themes/elemental/light/es5/all-elements.js +2 -2
- package/lib/filter-dialog/themes/elemental/light/filter-dialog.js +1 -1
- package/lib/filter-dialog/themes/halo/dark/checkbox-list.js +1 -1
- package/lib/filter-dialog/themes/halo/dark/es5/all-elements.js +2 -2
- package/lib/filter-dialog/themes/halo/dark/filter-dialog.js +1 -1
- package/lib/filter-dialog/themes/halo/light/checkbox-list.js +1 -1
- package/lib/filter-dialog/themes/halo/light/es5/all-elements.js +2 -2
- package/lib/filter-dialog/themes/halo/light/filter-dialog.js +1 -1
- package/lib/filter-dialog/themes/solar/charcoal/checkbox-list.js +1 -1
- package/lib/filter-dialog/themes/solar/charcoal/es5/all-elements.js +2 -2
- package/lib/filter-dialog/themes/solar/charcoal/filter-dialog.js +1 -1
- package/lib/filter-dialog/themes/solar/pearl/checkbox-list.js +1 -1
- package/lib/filter-dialog/themes/solar/pearl/es5/all-elements.js +2 -2
- package/lib/filter-dialog/themes/solar/pearl/filter-dialog.js +1 -1
- package/lib/grid/lib/efx-grid.d.ts +25 -10
- package/lib/grid/lib/efx-grid.js +22 -56
- package/lib/grid/themes/base.less +1 -1
- package/lib/grid/themes/halo/dark/efx-grid.js +1 -1
- package/lib/grid/themes/halo/dark/es5/all-elements.js +1 -1
- package/lib/grid/themes/halo/efx-grid.less +33 -39
- package/lib/grid/themes/halo/light/efx-grid.js +1 -1
- package/lib/grid/themes/halo/light/es5/all-elements.js +1 -1
- package/lib/grid/themes/solar/charcoal/efx-grid.js +1 -1
- package/lib/grid/themes/solar/charcoal/es5/all-elements.js +1 -1
- package/lib/grid/themes/solar/pearl/efx-grid.js +1 -1
- package/lib/grid/themes/solar/pearl/es5/all-elements.js +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -0
- package/lib/row-segmenting/es6/RowSegmenting.d.ts +7 -2
- package/lib/row-segmenting/es6/RowSegmenting.js +98 -11
- package/lib/rt-grid/dist/rt-grid.js +1244 -1249
- package/lib/rt-grid/dist/rt-grid.min.js +1 -1
- package/lib/rt-grid/es6/ColumnDefinition.d.ts +5 -3
- package/lib/rt-grid/es6/ColumnDefinition.js +17 -108
- package/lib/rt-grid/es6/DataConnector.d.ts +3 -3
- package/lib/rt-grid/es6/Grid.d.ts +24 -9
- package/lib/rt-grid/es6/Grid.js +285 -103
- package/lib/rt-grid/es6/RowDefSorter.d.ts +19 -0
- package/lib/rt-grid/es6/RowDefSorter.js +137 -0
- package/lib/rt-grid/es6/RowDefinition.d.ts +9 -7
- package/lib/rt-grid/es6/RowDefinition.js +6 -0
- package/lib/rt-grid/es6/SnapshotFiller.d.ts +6 -1
- package/lib/rt-grid/es6/SnapshotFiller.js +144 -15
- package/lib/tr-grid-checkbox/es6/Checkbox.d.ts +4 -3
- package/lib/tr-grid-checkbox/es6/Checkbox.js +51 -21
- package/lib/tr-grid-column-selection/es6/ColumnSelection.js +46 -9
- package/lib/tr-grid-column-stack/es6/ColumnStack.d.ts +8 -4
- package/lib/tr-grid-column-stack/es6/ColumnStack.js +240 -125
- package/lib/tr-grid-conditional-coloring/es6/ConditionalColoring.d.ts +4 -3
- package/lib/tr-grid-conditional-coloring/es6/ConditionalColoring.js +28 -13
- package/lib/tr-grid-in-cell-editing/es6/InCellEditing.d.ts +8 -5
- package/lib/tr-grid-in-cell-editing/es6/InCellEditing.js +106 -3
- package/lib/tr-grid-percent-bar/es6/PercentBar.js +1 -1
- package/lib/tr-grid-printer/es6/CellWriter.d.ts +3 -3
- package/lib/tr-grid-printer/es6/GridPrinter.d.ts +1 -1
- package/lib/tr-grid-printer/es6/GridPrinter.js +26 -13
- package/lib/tr-grid-printer/es6/PrintTrait.d.ts +2 -2
- package/lib/tr-grid-printer/es6/SectionWriter.d.ts +3 -3
- package/lib/tr-grid-row-dragging/es6/RowDragging.d.ts +3 -4
- package/lib/tr-grid-row-dragging/es6/RowDragging.js +86 -195
- package/lib/tr-grid-row-grouping/es6/RowGrouping.d.ts +7 -2
- package/lib/tr-grid-row-grouping/es6/RowGrouping.js +97 -7
- package/lib/tr-grid-row-selection/es6/RowSelection.d.ts +8 -8
- package/lib/tr-grid-row-selection/es6/RowSelection.js +55 -31
- package/lib/tr-grid-textformatting/es6/TextFormatting.d.ts +1 -1
- package/lib/tr-grid-textformatting/es6/TextFormatting.js +12 -0
- package/lib/tr-grid-util/es6/CellPainter.js +1 -1
- package/lib/tr-grid-util/es6/DragUI.d.ts +16 -0
- package/lib/tr-grid-util/es6/DragUI.js +214 -0
- package/lib/tr-grid-util/es6/ElementObserver.d.ts +2 -0
- package/lib/tr-grid-util/es6/ElementObserver.js +32 -2
- package/lib/tr-grid-util/es6/ElfUtil.d.ts +4 -1
- package/lib/tr-grid-util/es6/ElfUtil.js +131 -28
- package/lib/tr-grid-util/es6/ExpanderIcon.js +2 -2
- package/lib/tr-grid-util/es6/FieldFormatter.js +7 -5
- package/lib/tr-grid-util/es6/GridPlugin.js +8 -4
- package/lib/tr-grid-util/es6/MultiTableManager.d.ts +8 -0
- package/lib/tr-grid-util/es6/MultiTableManager.js +164 -57
- package/lib/tr-grid-util/es6/NumberFormatter.d.ts +2 -0
- package/lib/tr-grid-util/es6/NumberFormatter.js +64 -19
- package/lib/tr-grid-util/es6/RowPainter.js +57 -19
- package/lib/tr-grid-util/es6/formula/Formula.js +9 -1
- package/lib/tr-grid-util/es6/jsx.d.ts +223 -0
- package/lib/types/es6/Checkbox.d.ts +4 -3
- package/lib/types/es6/ColumnStack.d.ts +8 -4
- package/lib/types/es6/CompositeGrid/ColumnSelectionPlugin.d.ts +3 -2
- package/lib/types/es6/CompositeGrid/ColumnWidthAdjustingPlugin.d.ts +2 -1
- package/lib/types/es6/CompositeGrid/CompositeGrid.d.ts +20 -18
- package/lib/types/es6/CompositeGrid/DragAndDropTitlePlugin.d.ts +2 -1
- package/lib/types/es6/CompositeGrid/DraggableContentPlugin.d.ts +3 -2
- package/lib/types/es6/CompositeGrid/Plugin.d.ts +28 -0
- package/lib/types/es6/CompositeGrid/ResizableTitlePlugin.d.ts +2 -1
- package/lib/types/es6/CompositeGrid/RowSelectionPlugin.d.ts +5 -4
- package/lib/types/es6/CompositeGrid/TreeIndentingPlugin.d.ts +2 -1
- package/lib/types/es6/CompositeGrid/index.d.ts +9 -9
- package/lib/types/es6/ConditionalColoring.d.ts +4 -3
- package/lib/types/es6/Core/data/ColumnStats.d.ts +2 -2
- package/lib/types/es6/Core/data/DataCache.d.ts +4 -4
- package/lib/types/es6/Core/data/DataTable.d.ts +5 -5
- package/lib/types/es6/Core/data/DataView.d.ts +12 -18
- package/lib/types/es6/Core/data/Segment.d.ts +2 -0
- package/lib/types/es6/Core/data/SegmentCollection.d.ts +3 -3
- package/lib/types/es6/Core/data/WrappedView.d.ts +13 -13
- package/lib/types/es6/Core/grid/Core.d.ts +31 -27
- package/lib/types/es6/Core/grid/ILayoutGrid.d.ts +15 -15
- package/lib/types/es6/Core/grid/components/Cell.d.ts +4 -4
- package/lib/types/es6/Core/grid/components/CellFloatingPanel.d.ts +1 -1
- package/lib/types/es6/Core/grid/components/CellSpans.d.ts +8 -8
- package/lib/types/es6/Core/grid/components/Column.d.ts +1 -1
- package/lib/types/es6/Core/grid/components/ElementWrapper.d.ts +6 -6
- package/lib/types/es6/Core/grid/components/Scrollbar.d.ts +3 -1
- package/lib/types/es6/Core/grid/plugins/SortableTitlePlugin.d.ts +14 -6
- package/lib/types/es6/Core/grid/util/Conflator.d.ts +2 -2
- package/lib/types/es6/Core/grid/util/ElementFrameWork.d.ts +3 -3
- package/lib/types/es6/Core/grid/util/HttpRequest.d.ts +2 -2
- package/lib/types/es6/Core/grid/util/PercentBarRenderer.d.ts +1 -1
- package/lib/types/es6/Core/grid/util/RangeBar.d.ts +1 -1
- package/lib/types/es6/Core/grid/util/SectionSettings.d.ts +5 -5
- package/lib/types/es6/Core/grid/util/SelectionList.d.ts +2 -2
- package/lib/types/es6/Core/grid/util/TrackLayout.d.ts +7 -3
- package/lib/types/es6/Core/grid/util/util.d.ts +2 -2
- package/lib/types/es6/Core/index.d.ts +1 -5
- package/lib/types/es6/ExtensionOptions.d.ts +2 -0
- package/lib/types/es6/InCellEditing.d.ts +8 -5
- package/lib/types/es6/RealtimeGrid/ColumnDefinition.d.ts +5 -3
- package/lib/types/es6/RealtimeGrid/DataConnector.d.ts +3 -3
- package/lib/types/es6/RealtimeGrid/Grid.d.ts +24 -9
- package/lib/types/es6/RealtimeGrid/RowDefSorter.d.ts +19 -0
- package/lib/types/es6/RealtimeGrid/RowDefinition.d.ts +9 -7
- package/lib/types/es6/RealtimeGrid/SnapshotFiller.d.ts +6 -1
- package/lib/types/es6/RowDragging.d.ts +3 -4
- package/lib/types/es6/RowGrouping.d.ts +7 -2
- package/lib/types/es6/RowSegmenting.d.ts +7 -2
- package/lib/types/es6/RowSelection.d.ts +8 -8
- package/lib/types/es6/TextFormatting.d.ts +1 -1
- package/lib/types/es6/index.d.ts +1 -0
- package/lib/versions.json +17 -16
- package/package.json +1 -1
- package/lib/core/es6/grid/plugins/DragAndDropTitlePlugin.d.ts +0 -24
- package/lib/core/es6/grid/plugins/DragAndDropTitlePlugin.js +0 -615
- package/lib/core/es6/grid/plugins/Plugin.d.ts +0 -28
- package/lib/core/es6/grid/plugins/Plugin.js +0 -272
- package/lib/types/es6/Core/grid/plugins/DragAndDropTitlePlugin.d.ts +0 -24
- package/lib/types/es6/Core/grid/plugins/Plugin.d.ts +0 -28
@@ -0,0 +1,764 @@
|
|
1
|
+
import { Ext } from "../../tr-grid-util/es6/Ext.js";
|
2
|
+
import { preventDefault } from "../../tr-grid-util/es6/EventDispatcher.js";
|
3
|
+
import { GridPlugin } from "../../tr-grid-util/es6/GridPlugin.js";
|
4
|
+
import { ElfUtil } from "../../tr-grid-util/es6/ElfUtil.js";
|
5
|
+
import { cloneObject } from "../../tr-grid-util/es6/Util.js";
|
6
|
+
import { DragUI } from "../../tr-grid-util/es6/DragUI.js";
|
7
|
+
|
8
|
+
/** @typedef {Object} ColumnDraggingPlugin~Options
|
9
|
+
* @description The options can be specified by `columnDragging` property of the main grid's options
|
10
|
+
* @property {Function=} dragStart Function handler for dragStart event
|
11
|
+
* @property {Function=} drag Function handler for drag event
|
12
|
+
* @property {Function=} dragEnd Function handler for dragEnd event
|
13
|
+
* @property {Function=} preColumnMoved Function handler for preColumnMoved event
|
14
|
+
* @property {Function=} columnMoved Function handler for columnMoved event
|
15
|
+
* @property {Function=} dragInterval Function handler for dragInterval event
|
16
|
+
* @property {Function=} dragBoxRenderer Allow user to customize dragBox
|
17
|
+
*/
|
18
|
+
|
19
|
+
/** @event ColumnDraggingPlugin#drag
|
20
|
+
* @description Fired on each mousemove or touchmove
|
21
|
+
* @type {Object}
|
22
|
+
*/
|
23
|
+
/** @event ColumnDraggingPlugin#dragStart
|
24
|
+
* @description The event is fired at the beginning of the drag operation. You can cancel the operation by setting cancel property to true.
|
25
|
+
* @type {Object}
|
26
|
+
* @example
|
27
|
+
* // ...
|
28
|
+
* dragStart: function(e) {
|
29
|
+
* e.cancel = true; // To cancel the operation
|
30
|
+
* }, // ..
|
31
|
+
*/
|
32
|
+
/** @event ColumnDraggingPlugin#dragEnd
|
33
|
+
* @description The event will always be fired at the end of the drag operation. This is to allow clearing of any resource used. You can cancel the data moving operation by setting cancel property to true.
|
34
|
+
* @type {Object}
|
35
|
+
*/
|
36
|
+
|
37
|
+
/** @event ColumnDraggingPlugin#preColumnMoved
|
38
|
+
* @description Fired before the actual move
|
39
|
+
* @type {Object}
|
40
|
+
* @property {number} startColumnIndex
|
41
|
+
* @property {number} destColumnIndex
|
42
|
+
* @example
|
43
|
+
* // ...
|
44
|
+
* preColumnMoved: function(e) {
|
45
|
+
* e.cancel = true; // To cancel the operation
|
46
|
+
* }, // ..
|
47
|
+
*/
|
48
|
+
/** @event ColumnDraggingPlugin#columnMoved
|
49
|
+
* @description Fired if the column is successfully moved by drag and drop operation
|
50
|
+
* @type {Object}
|
51
|
+
* @property {number} startColumnIndex
|
52
|
+
* @property {number} destColumnIndex
|
53
|
+
*/
|
54
|
+
|
55
|
+
/** @event ColumnDraggingPlugin#dragInterval
|
56
|
+
* @description Fired at an interval during drag
|
57
|
+
* @type {Object}
|
58
|
+
*/
|
59
|
+
|
60
|
+
/** @constructor
|
61
|
+
* @param {ColumnDraggingPlugin~Options=} options
|
62
|
+
* @extends {GridPlugin}
|
63
|
+
*/
|
64
|
+
var ColumnDraggingPlugin = function (options) {
|
65
|
+
var t = this;
|
66
|
+
t._onMouseUp = t._onMouseUp.bind(t);
|
67
|
+
t._onMouseDown = t._onMouseDown.bind(t);
|
68
|
+
|
69
|
+
t._onDrag = t._onDrag.bind(t);
|
70
|
+
t._onDragStart = t._onDragStart.bind(t);
|
71
|
+
t._onDragEnd = t._onDragEnd.bind(t);
|
72
|
+
t._onDragPulse = t._onDragPulse.bind(t);
|
73
|
+
t._onThemeLoaded = t._onThemeLoaded.bind(t);
|
74
|
+
|
75
|
+
t._hosts = [];
|
76
|
+
|
77
|
+
t._guideline = document.createElement("div");
|
78
|
+
t._guideline.className = "guideline";
|
79
|
+
t._dragBox = document.createElement("div");
|
80
|
+
t._dragBox.className = "drag-box-disabled"; // defualt disable dragbox
|
81
|
+
t._dragBoxIcon = document.createElement("ef-icon");
|
82
|
+
t._dragBoxIcon.className = "drag-box-icon";
|
83
|
+
|
84
|
+
if(options) {
|
85
|
+
this.config({ "columnDragging": options });
|
86
|
+
}
|
87
|
+
};
|
88
|
+
Ext.inherits(ColumnDraggingPlugin, GridPlugin);
|
89
|
+
|
90
|
+
/** @private
|
91
|
+
* @type {Core}
|
92
|
+
*/
|
93
|
+
ColumnDraggingPlugin.prototype._clickedGrid = null;
|
94
|
+
/** @private
|
95
|
+
* @type {ILayoutGrid}
|
96
|
+
*/
|
97
|
+
ColumnDraggingPlugin.prototype._clickedSection = null;
|
98
|
+
/** @private
|
99
|
+
* @type {number}
|
100
|
+
*/
|
101
|
+
ColumnDraggingPlugin.prototype._clickedRow = -1;
|
102
|
+
/** @private
|
103
|
+
* @type {Element}
|
104
|
+
*/
|
105
|
+
ColumnDraggingPlugin.prototype._guideline = null;
|
106
|
+
/** @private
|
107
|
+
* @type {Element}
|
108
|
+
*/
|
109
|
+
ColumnDraggingPlugin.prototype._dragBox = null;
|
110
|
+
/** @private
|
111
|
+
* @type {Element}
|
112
|
+
*/
|
113
|
+
ColumnDraggingPlugin.prototype._dragBoxIcon = null;
|
114
|
+
/** @type {Object}
|
115
|
+
* @private
|
116
|
+
*/
|
117
|
+
ColumnDraggingPlugin.prototype._dragBoxRenderer = null;
|
118
|
+
/** @private
|
119
|
+
* @type {number}
|
120
|
+
*/
|
121
|
+
ColumnDraggingPlugin.prototype._timerId = 0;
|
122
|
+
/** @private
|
123
|
+
* @type {number}
|
124
|
+
*/
|
125
|
+
ColumnDraggingPlugin.prototype._dragPulseId = 0;
|
126
|
+
/** @private
|
127
|
+
* @type {Object}
|
128
|
+
*/
|
129
|
+
ColumnDraggingPlugin.prototype._pos = null; // Cache of current mouse position
|
130
|
+
/** @private
|
131
|
+
* @type {number}
|
132
|
+
*/
|
133
|
+
ColumnDraggingPlugin.prototype._cacheLeft = 0;
|
134
|
+
/** @private
|
135
|
+
* @type {number}
|
136
|
+
*/
|
137
|
+
ColumnDraggingPlugin.prototype._cacheWidth = 0;
|
138
|
+
|
139
|
+
/** @private
|
140
|
+
* @type {number}
|
141
|
+
*/
|
142
|
+
ColumnDraggingPlugin.prototype._startColumn = -1;
|
143
|
+
/** @private
|
144
|
+
* @type {number}
|
145
|
+
*/
|
146
|
+
ColumnDraggingPlugin.prototype._endColumn = -1;
|
147
|
+
/** @private
|
148
|
+
* @type {number}
|
149
|
+
*/
|
150
|
+
ColumnDraggingPlugin.prototype._destColumn = -1;
|
151
|
+
/** @private
|
152
|
+
* @type {number}
|
153
|
+
*/
|
154
|
+
ColumnDraggingPlugin.prototype._leftMovableBorder = -1;
|
155
|
+
/** @private
|
156
|
+
* @type {number}
|
157
|
+
*/
|
158
|
+
ColumnDraggingPlugin.prototype._rightMovableBorder = -1;
|
159
|
+
/** @private
|
160
|
+
* @type {boolean}
|
161
|
+
*/
|
162
|
+
ColumnDraggingPlugin.prototype._isDragging = false;
|
163
|
+
/** @private
|
164
|
+
* @type {boolean}
|
165
|
+
*/
|
166
|
+
ColumnDraggingPlugin.prototype._lockFrozen = false;
|
167
|
+
/** @private
|
168
|
+
* @type {boolean}
|
169
|
+
*/
|
170
|
+
ColumnDraggingPlugin.prototype._disabled = false;
|
171
|
+
/** @private
|
172
|
+
* @type {boolean}
|
173
|
+
*/
|
174
|
+
ColumnDraggingPlugin.prototype._noColumnMoving = false;
|
175
|
+
/** @private
|
176
|
+
* @type {boolean}
|
177
|
+
*/
|
178
|
+
ColumnDraggingPlugin.prototype._noDragBox = false;
|
179
|
+
/** @type {string}
|
180
|
+
* @private
|
181
|
+
*/
|
182
|
+
ColumnDraggingPlugin._styles = ""; // Static variable
|
183
|
+
/** @private
|
184
|
+
* @type {Object}
|
185
|
+
*/
|
186
|
+
ColumnDraggingPlugin.prototype._dragUI = null;
|
187
|
+
|
188
|
+
/** @public
|
189
|
+
* @return {string}
|
190
|
+
*/
|
191
|
+
ColumnDraggingPlugin.prototype.getName = function () {
|
192
|
+
return "ColumnDraggingPlugin"; // Read Only
|
193
|
+
};
|
194
|
+
/** Plugin that has multi-table support means that it can have multiple hosts/tables and share its states across those hosts/tables.
|
195
|
+
* @public
|
196
|
+
* @return {boolean}
|
197
|
+
*/
|
198
|
+
ColumnDraggingPlugin.prototype.hasMultiTableSupport = function () {
|
199
|
+
return true;
|
200
|
+
};
|
201
|
+
|
202
|
+
/** @public
|
203
|
+
* @param {Object} host core grid instance
|
204
|
+
* @param {Object=} options
|
205
|
+
*/
|
206
|
+
ColumnDraggingPlugin.prototype.initialize = function (host, options) {
|
207
|
+
if (this._hosts.indexOf(host) >= 0) {
|
208
|
+
return;
|
209
|
+
}
|
210
|
+
|
211
|
+
this._hosts.push(host);
|
212
|
+
host.unloadPlugin("DragAndDropTitlePlugin");
|
213
|
+
|
214
|
+
host.listen("mousedown", this._onMouseDown);
|
215
|
+
host.listen("dragstart", preventDefault);
|
216
|
+
|
217
|
+
this.config(options);
|
218
|
+
|
219
|
+
this._dragUI = new DragUI({
|
220
|
+
dragBox: this._dragBox,
|
221
|
+
dragBoxIcon: this._dragBoxIcon
|
222
|
+
});
|
223
|
+
|
224
|
+
// Share dragging styles
|
225
|
+
if(DragUI.stylePromise) {
|
226
|
+
DragUI.applyThemeColor(host);
|
227
|
+
} else {
|
228
|
+
DragUI.stylePromise = ElfUtil.getThemeColors();
|
229
|
+
DragUI.stylePromise.then(this._onThemeLoaded);
|
230
|
+
}
|
231
|
+
};
|
232
|
+
/** @public
|
233
|
+
* @param {Object=} host core grid instance
|
234
|
+
*/
|
235
|
+
ColumnDraggingPlugin.prototype.unload = function (host) {
|
236
|
+
var at = this._hosts.indexOf(host);
|
237
|
+
if (at < 0) {
|
238
|
+
return;
|
239
|
+
}
|
240
|
+
|
241
|
+
this._hosts.splice(at, 1);
|
242
|
+
host.unlisten("mousedown", this._onMouseDown);
|
243
|
+
|
244
|
+
if(!this._hosts.length) {
|
245
|
+
if(this._dragPulseId) {
|
246
|
+
window.clearInterval(this._dragPulseId);
|
247
|
+
this._dragPulseId = 0;
|
248
|
+
}
|
249
|
+
}
|
250
|
+
|
251
|
+
this._dispose();
|
252
|
+
};
|
253
|
+
|
254
|
+
/** @private
|
255
|
+
* @param {Object} colors
|
256
|
+
*/
|
257
|
+
ColumnDraggingPlugin.prototype._onThemeLoaded = function(colors) {
|
258
|
+
this._dragUI.onThemeLoaded(colors); // TODO : onThemeLoaded should be static function like DragUI.applyThemeColor
|
259
|
+
for(var i = this._hosts.length; --i >= 0;) {
|
260
|
+
DragUI.applyThemeColor(this._hosts[i]);
|
261
|
+
}
|
262
|
+
};
|
263
|
+
|
264
|
+
/** @public
|
265
|
+
* @param {Object=} options Grid configuration object
|
266
|
+
*/
|
267
|
+
ColumnDraggingPlugin.prototype.config = function (options) {
|
268
|
+
if (!options) { return; }
|
269
|
+
|
270
|
+
var noColumnDragging = options["noColumnDragging"];
|
271
|
+
if (noColumnDragging == null && options["columnReorder"] != null) {
|
272
|
+
noColumnDragging = !options["columnReorder"];
|
273
|
+
}
|
274
|
+
if (noColumnDragging != null) {
|
275
|
+
this._disabled = noColumnDragging ? true : false;
|
276
|
+
}
|
277
|
+
|
278
|
+
var extOptions = options.columnDragging;
|
279
|
+
if (!extOptions) { return; }
|
280
|
+
|
281
|
+
if (typeof extOptions["dragBoxRenderer"] === "function") {
|
282
|
+
this._dragBoxRenderer = extOptions["dragBoxRenderer"];
|
283
|
+
this._dragBox.className = "drag-box";
|
284
|
+
}
|
285
|
+
this.addListener(extOptions, "dragStart");
|
286
|
+
this.addListener(extOptions, "drag");
|
287
|
+
this.addListener(extOptions, "dragEnd");
|
288
|
+
this.addListener(extOptions, "preColumnMoved");
|
289
|
+
this.addListener(extOptions, "columnMoved");
|
290
|
+
this.addListener(extOptions, "dragInterval");
|
291
|
+
};
|
292
|
+
|
293
|
+
/** @public
|
294
|
+
* @param {Object=} gridOptions
|
295
|
+
* @return {!Object}
|
296
|
+
*/
|
297
|
+
ColumnDraggingPlugin.prototype.getConfigObject = function (gridOptions) {
|
298
|
+
var obj = gridOptions || {};
|
299
|
+
|
300
|
+
if(this._disabled) {
|
301
|
+
obj.noColumnDragging = true;
|
302
|
+
}
|
303
|
+
|
304
|
+
var extOptions = obj.columnDragging;
|
305
|
+
if(!extOptions) {
|
306
|
+
extOptions = obj.columnDragging = {};
|
307
|
+
}
|
308
|
+
|
309
|
+
return obj;
|
310
|
+
};
|
311
|
+
|
312
|
+
/**
|
313
|
+
* Lock moving of frozen column. If true is spsecified, dragging is disabled for frozen column.
|
314
|
+
* @public
|
315
|
+
* @param {boolean} lock
|
316
|
+
*/
|
317
|
+
ColumnDraggingPlugin.prototype.lockFrozenColumn = function(lock) {
|
318
|
+
this._lockFrozen = lock;
|
319
|
+
};
|
320
|
+
|
321
|
+
/** Disable this plugin entirely
|
322
|
+
* @public
|
323
|
+
* @param {boolean=} opt_disabled
|
324
|
+
*/
|
325
|
+
ColumnDraggingPlugin.prototype.disable = function(opt_disabled) {
|
326
|
+
this._disabled = opt_disabled !== false;
|
327
|
+
};
|
328
|
+
/** Disable column moving. Only cursor is showing and events are fired. No real column moving.
|
329
|
+
* @public
|
330
|
+
* @param {boolean=} opt_disabled
|
331
|
+
*/
|
332
|
+
ColumnDraggingPlugin.prototype.disableMoving = function(opt_disabled) {
|
333
|
+
this._noColumnMoving = opt_disabled !== false;
|
334
|
+
};
|
335
|
+
/** Disable column moving. Only cursor is showing and events are fired. No real column moving.
|
336
|
+
* @public
|
337
|
+
* @param {boolean=} opt_disabled
|
338
|
+
*/
|
339
|
+
ColumnDraggingPlugin.prototype.disableDragBox = function(opt_disabled) {
|
340
|
+
this._noDragBox = opt_disabled !== false;
|
341
|
+
};
|
342
|
+
|
343
|
+
/** @private
|
344
|
+
* @param {number} colIndex
|
345
|
+
* @return {boolean}
|
346
|
+
*/
|
347
|
+
ColumnDraggingPlugin.prototype._isAllowed = function(colIndex) {
|
348
|
+
var host = this._clickedGrid || this._hosts[0];
|
349
|
+
if (host) {
|
350
|
+
var stationaryIndex = host.getStationaryColumnIndex();
|
351
|
+
if (stationaryIndex < 0) {
|
352
|
+
return true;
|
353
|
+
}
|
354
|
+
if (colIndex <= stationaryIndex) {
|
355
|
+
return false;
|
356
|
+
}
|
357
|
+
}
|
358
|
+
return true;
|
359
|
+
};
|
360
|
+
/** @private
|
361
|
+
* @param {Event} e
|
362
|
+
*/
|
363
|
+
ColumnDraggingPlugin.prototype._onMouseDown = function (e) {
|
364
|
+
if(this._disabled) {
|
365
|
+
return;
|
366
|
+
}
|
367
|
+
if(e.shiftKey || e.ctrlKey || e.altKey) {
|
368
|
+
return; // Ignore mousedown event, if modifier key is detected
|
369
|
+
}
|
370
|
+
if(e.button) {
|
371
|
+
return; // We don't allow drag with middle click (button == 1), or right click (button == 2)
|
372
|
+
}
|
373
|
+
if(this._timerId) {
|
374
|
+
return; // Drag timer is already start
|
375
|
+
}
|
376
|
+
|
377
|
+
var host = this.getRelativeGrid(e);
|
378
|
+
if(!host) {
|
379
|
+
return; // Given event should be within grid element
|
380
|
+
}
|
381
|
+
|
382
|
+
this._pos = host.getRelativePosition(e);
|
383
|
+
if (this._pos["hit"] === false) {
|
384
|
+
return; // Only start dragging when mouse is down on the grid
|
385
|
+
}
|
386
|
+
|
387
|
+
var section = /** @type{ILayoutGrid} */(this._pos["section"]);
|
388
|
+
if(!section) {
|
389
|
+
return; // The section that is not in the target section list cannot be dragged
|
390
|
+
} else if(this._pos["sectionType"] !== "title") {
|
391
|
+
return; // Sections other than title section cannot be dragged by default
|
392
|
+
}
|
393
|
+
|
394
|
+
var colIndex = this._pos["colIndex"];
|
395
|
+
if(!this._isAllowed(colIndex)) {
|
396
|
+
return; // The column cannot be dragged
|
397
|
+
}
|
398
|
+
if(this._lockFrozen && host.isPinnedColumn(colIndex)) {
|
399
|
+
return; // If the lock frag is on, frozen columns cannot be dragged
|
400
|
+
}
|
401
|
+
|
402
|
+
var rowIndex = this._pos["rowIndex"]; // rowIndex may not exist
|
403
|
+
var movableBorder = this._findMoveableBorder(colIndex, rowIndex - 1, section);
|
404
|
+
var movingColumns = this._getSpan(colIndex, rowIndex, section);
|
405
|
+
|
406
|
+
this._clickedGrid = host;
|
407
|
+
this._clickedSection = section;
|
408
|
+
this._clickedRow = rowIndex;
|
409
|
+
|
410
|
+
this._startColumn = movingColumns["left"];
|
411
|
+
this._endColumn = movingColumns["right"];
|
412
|
+
this._leftMovableBorder = movableBorder["left"];
|
413
|
+
this._rightMovableBorder = movableBorder["right"];
|
414
|
+
this._destColumn = this._startColumn;
|
415
|
+
this._timerId = setTimeout(this._onDragStart, 300);
|
416
|
+
window.addEventListener("mouseup", this._onMouseUp, false);
|
417
|
+
};
|
418
|
+
/** @private
|
419
|
+
* @param {Object} e
|
420
|
+
*/
|
421
|
+
ColumnDraggingPlugin.prototype._onMouseUp = function (e) {
|
422
|
+
if(this._timerId) {
|
423
|
+
window.clearTimeout(this._timerId);
|
424
|
+
window.removeEventListener("mouseup", this._onMouseUp, false);
|
425
|
+
this._timerId = 0;
|
426
|
+
this._clearCache();
|
427
|
+
}
|
428
|
+
};
|
429
|
+
|
430
|
+
/** @private
|
431
|
+
* @param {*} e
|
432
|
+
*/
|
433
|
+
ColumnDraggingPlugin.prototype._onDragStart = function (e) {
|
434
|
+
if(this._disabled || this._isDragging) { return; }
|
435
|
+
if (this.hasListener("dragStart")) {
|
436
|
+
this._dispatch("dragStart", /** @type{!Object} */(this._pos));
|
437
|
+
}
|
438
|
+
|
439
|
+
if (this._pos["cancel"]) {
|
440
|
+
return;
|
441
|
+
}
|
442
|
+
|
443
|
+
this._timerId = 0;
|
444
|
+
window.removeEventListener("mouseup", this._onMouseUp, false);
|
445
|
+
|
446
|
+
if(!this._clickedGrid) {
|
447
|
+
return;
|
448
|
+
}
|
449
|
+
|
450
|
+
this._isDragging = true;
|
451
|
+
document.body.classList.add("tr-dragging"); // Prevent text selection
|
452
|
+
// document.body.classList.add("tr-move-cursor");
|
453
|
+
|
454
|
+
window.addEventListener("mousemove", this._onDrag, false); // TODO: support touch operation
|
455
|
+
window.addEventListener("mouseup", this._onDragEnd, true);
|
456
|
+
|
457
|
+
var host = this._clickedGrid;
|
458
|
+
var height = host.getHeight();
|
459
|
+
var sectionBound = this._clickedSection.getBoundingClientRect();
|
460
|
+
var clickedCellBound = this._clickedSection.getCell(this._startColumn, this._clickedRow).getBoundingClientRect();
|
461
|
+
|
462
|
+
var gridElem = host.getElement();
|
463
|
+
this._guideline.style.top = (clickedCellBound.top - sectionBound.top) + "px";
|
464
|
+
this._guideline.style.height = (height - 1) + "px";
|
465
|
+
|
466
|
+
// TODO: guideline and drag box should be outside of grid area
|
467
|
+
gridElem.parentNode.classList.add("mouse-dragging"); // change cursor
|
468
|
+
|
469
|
+
|
470
|
+
// TODO: guideline and drag box should be outside of grid area
|
471
|
+
gridElem.appendChild(this._guideline);
|
472
|
+
|
473
|
+
if (this._dragBoxRenderer) { // For custom drag box rendering
|
474
|
+
var arg = cloneObject(e); // TODO: Check if cloning is necessary
|
475
|
+
var id = this.getColumnId(this._startColumn);
|
476
|
+
var index = this.getColumnIndex(id);
|
477
|
+
var field = this._getField(this._startColumn);
|
478
|
+
|
479
|
+
arg.dragBox = this._dragBox;
|
480
|
+
arg.columnData = {
|
481
|
+
index: index,
|
482
|
+
field: field,
|
483
|
+
id: id
|
484
|
+
};
|
485
|
+
this._dragBoxRenderer(arg);
|
486
|
+
}
|
487
|
+
this._dimCol(true);
|
488
|
+
this._renderGuideline();
|
489
|
+
|
490
|
+
// For step scrolling // TODO: Merge this logic with DraggableContentPlugin
|
491
|
+
this._scrollStep = Math.floor(host.getScrollWidth() / 25); // Update the scrollbar first
|
492
|
+
if(this._scrollStep < 40) {
|
493
|
+
this._scrollStep = 40;
|
494
|
+
} else if(this._scrollStep > 400) {
|
495
|
+
this._scrollStep = 400;
|
496
|
+
}
|
497
|
+
var scrollbar = host.getHScrollbar();
|
498
|
+
this._cacheLeft = scrollbar.getLeft() + 20;
|
499
|
+
this._cacheWidth = scrollbar.getLeft() + scrollbar.getWidth() - 20;
|
500
|
+
|
501
|
+
this._dragPulseId = window.setInterval(this._onDragPulse, 150); // Start pulse
|
502
|
+
};
|
503
|
+
/** @private
|
504
|
+
* @param {Event} e
|
505
|
+
*/
|
506
|
+
ColumnDraggingPlugin.prototype._onDrag = function (e) {
|
507
|
+
if(!this._isDragging) { return; }
|
508
|
+
|
509
|
+
preventDefault(e);
|
510
|
+
this._pos = this._clickedGrid.getRelativePosition(e); // Relative to the clicked grid
|
511
|
+
|
512
|
+
var host = this.getRelativeGrid(e);
|
513
|
+
if (!host || host !== this._clickedGrid) { return; }
|
514
|
+
|
515
|
+
var colIndex = this._pos["colIndex"];
|
516
|
+
if ((colIndex >= this._leftMovableBorder) &&
|
517
|
+
(colIndex <= this._rightMovableBorder) &&
|
518
|
+
this._isAllowed(colIndex) &&
|
519
|
+
!(this._lockFrozen && host.isPinnedColumn(colIndex))) {
|
520
|
+
e.dragBox = this._dragBox;
|
521
|
+
this._renderGuideline();
|
522
|
+
this._dispatch("drag", /** @type{!Object} */(e));
|
523
|
+
}
|
524
|
+
if(!this._noDragBox) {
|
525
|
+
var drop = this._dragUI.renderDragBox(e, this._clickedGrid);
|
526
|
+
if(!drop) { // can not be drop or not allow to drop or insertion
|
527
|
+
this._pos["cancel"] = true;
|
528
|
+
}
|
529
|
+
}
|
530
|
+
};
|
531
|
+
/** @private
|
532
|
+
* @param {Event} e
|
533
|
+
*/
|
534
|
+
ColumnDraggingPlugin.prototype._onDragEnd = function (e) {
|
535
|
+
if(!this._isDragging) {
|
536
|
+
return;
|
537
|
+
}
|
538
|
+
|
539
|
+
this._isDragging = false;
|
540
|
+
document.body.classList.remove("tr-dragging");
|
541
|
+
// document.body.classList.remove("tr-move-cursor");
|
542
|
+
this._dimCol(false);
|
543
|
+
|
544
|
+
var pn = this._guideline.parentNode;
|
545
|
+
if(pn) {
|
546
|
+
pn.removeChild(this._guideline);
|
547
|
+
}
|
548
|
+
|
549
|
+
pn = this._dragBox.parentNode;
|
550
|
+
if(pn) {
|
551
|
+
pn.removeChild(this._dragBox);
|
552
|
+
}
|
553
|
+
this._clickedGrid.getElement().parentNode.classList.remove("mouse-dragging"); // retain mouse cursor
|
554
|
+
|
555
|
+
window.removeEventListener("mousemove", this._onDrag, false);
|
556
|
+
window.removeEventListener("mouseup", this._onDragEnd, true);
|
557
|
+
|
558
|
+
if(this._dragPulseId) {
|
559
|
+
window.clearInterval(this._dragPulseId);
|
560
|
+
this._dragPulseId = 0;
|
561
|
+
}
|
562
|
+
var destPos = this._pos;
|
563
|
+
this._pos = null;
|
564
|
+
|
565
|
+
preventDefault(e);
|
566
|
+
var operationCancelled = false;
|
567
|
+
if(destPos["cancel"]) {
|
568
|
+
operationCancelled = true;
|
569
|
+
}
|
570
|
+
|
571
|
+
//When move to the right, the first position is the current one.
|
572
|
+
if (this._destColumn > this._startColumn) {
|
573
|
+
--this._destColumn;
|
574
|
+
}
|
575
|
+
//Cancel moving if the destination column is the current column or not allowed column
|
576
|
+
if ((!this._destColumn && this._destColumn !== 0) || // undefined, NaN, null
|
577
|
+
this._destColumn < 0 ||
|
578
|
+
!this._isAllowed(this._destColumn) ||
|
579
|
+
(this._destColumn >= this._startColumn && this._destColumn <= this._endColumn)) {
|
580
|
+
operationCancelled = true;
|
581
|
+
}
|
582
|
+
|
583
|
+
var arg = null;
|
584
|
+
|
585
|
+
if(!operationCancelled) {
|
586
|
+
arg = {
|
587
|
+
"startColumnIndex": this._startColumn,
|
588
|
+
"destColumnIndex": this._destColumn
|
589
|
+
};
|
590
|
+
this._dispatch("preColumnMoved", arg);
|
591
|
+
if(arg["cancel"]) {
|
592
|
+
operationCancelled = true;
|
593
|
+
}
|
594
|
+
}
|
595
|
+
|
596
|
+
if (!operationCancelled) {
|
597
|
+
if (!this._noColumnMoving) {
|
598
|
+
var shiftStart = -1;
|
599
|
+
var shiftEnd = -1;
|
600
|
+
var moveSize = -1;
|
601
|
+
if (this._startColumn > this._destColumn) { //Move backward
|
602
|
+
shiftStart = this._destColumn;
|
603
|
+
shiftEnd = this._startColumn - 1;
|
604
|
+
moveSize = -1 * (this._startColumn - this._destColumn); //Move to the left
|
605
|
+
} else
|
606
|
+
if (this._startColumn < this._destColumn) { //Move foward
|
607
|
+
shiftStart = this._endColumn + 1;
|
608
|
+
shiftEnd = this._destColumn;
|
609
|
+
moveSize = ((shiftEnd - shiftStart) + 1); //Move to the right
|
610
|
+
}
|
611
|
+
|
612
|
+
//Perform moving all columns in the range
|
613
|
+
for(var j = this._hosts.length; --j >= 0;) {
|
614
|
+
var host = this._hosts[j];
|
615
|
+
var i;
|
616
|
+
if (moveSize > 0) { //Move forward
|
617
|
+
for (i = this._startColumn; i <= this._endColumn; i++) {
|
618
|
+
host.moveColumn(this._startColumn, this._destColumn);
|
619
|
+
}
|
620
|
+
} else { //Move backward
|
621
|
+
for (i = this._startColumn; i <= this._endColumn; i++) {
|
622
|
+
host.moveColumn(this._startColumn + (i - this._startColumn), this._destColumn + (i - this._startColumn));
|
623
|
+
}
|
624
|
+
}
|
625
|
+
}
|
626
|
+
}
|
627
|
+
|
628
|
+
if (this.hasListener("columnMoved")) {
|
629
|
+
this._dispatch("columnMoved", {
|
630
|
+
"startColumnIndex": this._startColumn,
|
631
|
+
"endColumnIndex": this._endColumn,
|
632
|
+
"destColumnIndex": this._destColumn,
|
633
|
+
"clickedRow": this._clickedRow
|
634
|
+
});
|
635
|
+
}
|
636
|
+
}
|
637
|
+
|
638
|
+
this._dispatch("dragEnd", destPos || {}); // Always fire drag end for client to clean up its resource
|
639
|
+
this._clearCache();
|
640
|
+
};
|
641
|
+
|
642
|
+
/** @private
|
643
|
+
*/
|
644
|
+
ColumnDraggingPlugin.prototype._onDragPulse = function() {
|
645
|
+
if(!this._isDragging || !this._pos) { return; }
|
646
|
+
|
647
|
+
this._dispatch("dragInterval", /** @type{!Object} */(this._pos));
|
648
|
+
|
649
|
+
var host = this._clickedGrid;
|
650
|
+
if(!host || !host.getHScrollbar().isActive()) { return; }
|
651
|
+
|
652
|
+
var x = this._pos["x"];
|
653
|
+
var scrollVal = 0;
|
654
|
+
if(x < this._cacheLeft) {
|
655
|
+
scrollVal = -Math.floor(this._scrollStep * (0.8 + Math.random()));
|
656
|
+
|
657
|
+
} else if(x > this._cacheWidth) {
|
658
|
+
scrollVal = Math.floor(this._scrollStep * (0.8 + Math.random()));
|
659
|
+
}
|
660
|
+
|
661
|
+
var len = this._hosts ? this._hosts.length : 0;
|
662
|
+
for(var i = 0; i < len; ++i) {
|
663
|
+
this._hosts[i].scrollRight(scrollVal);
|
664
|
+
}
|
665
|
+
};
|
666
|
+
/** @private
|
667
|
+
*/
|
668
|
+
ColumnDraggingPlugin.prototype._clearCache = function() {
|
669
|
+
this._startColumn = this._endColumn = this._destColumn = -1;
|
670
|
+
|
671
|
+
this._leftMovableBorder = this._rightMovableBorder = -1;
|
672
|
+
|
673
|
+
this._clickedRow = -1;
|
674
|
+
this._clickedSection = this._clickedGrid = null;
|
675
|
+
};
|
676
|
+
|
677
|
+
/** @private
|
678
|
+
* @param {number} colIndex
|
679
|
+
* @param {number} row
|
680
|
+
* @param {ILayoutGrid} section
|
681
|
+
* @return {!Object}
|
682
|
+
*/
|
683
|
+
ColumnDraggingPlugin.prototype._getSpan = function(colIndex, row, section) {
|
684
|
+
var cellSpan = section.getCellColSpan(colIndex, row);
|
685
|
+
|
686
|
+
if (cellSpan <= 0) { // The specified cell is being occupied
|
687
|
+
colIndex += cellSpan; // Convert the given negative index to the spanning cell
|
688
|
+
cellSpan = section.getCellColSpan(colIndex, row);
|
689
|
+
}
|
690
|
+
|
691
|
+
return { "left": colIndex, "right": (colIndex + cellSpan - 1) };
|
692
|
+
};
|
693
|
+
/** @private
|
694
|
+
* @param {number} col
|
695
|
+
* @param {number} row
|
696
|
+
* @param {ILayoutGrid} section
|
697
|
+
* @return {!Object}
|
698
|
+
*/
|
699
|
+
ColumnDraggingPlugin.prototype._findMoveableBorder = function(col, row, section) {
|
700
|
+
if (row < 0 || (!row && row !== 0)) { // Guaranteed to get out of infinite loop by checking undefined, NaN, null
|
701
|
+
return { "left": 0, "right": (section.getColumnCount() - 1) };
|
702
|
+
}
|
703
|
+
var span = this._getSpan(col, row, section);
|
704
|
+
if (span["right"] >= span["left"]) {
|
705
|
+
return span;
|
706
|
+
} else {
|
707
|
+
return this._findMoveableBorder(col, row - 1, section);
|
708
|
+
}
|
709
|
+
};
|
710
|
+
/**
|
711
|
+
* @private
|
712
|
+
*/
|
713
|
+
ColumnDraggingPlugin.prototype._renderGuideline = function() {
|
714
|
+
var colIndex = this._pos["colIndex"];
|
715
|
+
if(colIndex == null || colIndex < 0) { // undefined, null or negative number
|
716
|
+
return;
|
717
|
+
}
|
718
|
+
|
719
|
+
var currentSpan = this._getSpan(colIndex, this._clickedRow, this._clickedSection);
|
720
|
+
var colStart = currentSpan["left"]; // This can be different from colIndex
|
721
|
+
var colEnd = currentSpan["right"];
|
722
|
+
var colLeft = this._clickedGrid.getColumnLeft(colStart);
|
723
|
+
var colWidth = 0;
|
724
|
+
for(var i = colStart; i <= colEnd; ++i) {
|
725
|
+
colWidth += this._clickedGrid.getColumnWidth(i);
|
726
|
+
}
|
727
|
+
|
728
|
+
var rightHand = this._pos["x"] > colLeft + colWidth / 2;
|
729
|
+
var destColumn = (rightHand) ? colEnd + 1 : colStart;
|
730
|
+
|
731
|
+
colLeft = this._clickedGrid.getColumnLeft(this._destColumn);
|
732
|
+
// If destination exceeds the specified bounds
|
733
|
+
if (destColumn < this._leftMovableBorder) {
|
734
|
+
destColumn = this._leftMovableBorder;
|
735
|
+
} else if (destColumn > this._rightMovableBorder) {
|
736
|
+
destColumn = this._rightMovableBorder + 1;
|
737
|
+
if(rightHand) {
|
738
|
+
colLeft -= 4; // Shift guideline to the left if this is the rightmost column
|
739
|
+
}
|
740
|
+
}
|
741
|
+
|
742
|
+
this._destColumn = destColumn;
|
743
|
+
this._guideline.style.left = colLeft + "px";
|
744
|
+
};
|
745
|
+
|
746
|
+
/**
|
747
|
+
* @private
|
748
|
+
* @param {boolean} inOut
|
749
|
+
*/
|
750
|
+
ColumnDraggingPlugin.prototype._dimCol = function(inOut) {
|
751
|
+
var host = this._clickedGrid;
|
752
|
+
var titleCell = host.getSection("title").getColumn(this._startColumn).getCell(0);
|
753
|
+
var titleCellEl = titleCell.getElement();
|
754
|
+
if(inOut) {
|
755
|
+
titleCellEl.classList.add("drag-indicator");
|
756
|
+
} else {
|
757
|
+
titleCellEl.classList.remove("drag-indicator");
|
758
|
+
}
|
759
|
+
};
|
760
|
+
|
761
|
+
|
762
|
+
|
763
|
+
export default ColumnDraggingPlugin;
|
764
|
+
export { ColumnDraggingPlugin, ColumnDraggingPlugin as ColumnDragging, ColumnDraggingPlugin as ColumnDraggingExtension };
|