|
32 | 32 | }
|
33 | 33 | });
|
34 | 34 |
|
35 |
| - /** |
36 |
| - * @ngdoc object |
37 |
| - * @name ui.grid.cellNav.object:RowCol |
38 |
| - * @param {GridRow} row The row for this pair |
39 |
| - * @param {GridColumn} column The column for this pair |
40 |
| - * @description A row and column pair that represents the intersection of these two entities. |
41 |
| - */ |
42 |
| - module.factory('RowColFactory', ['$parse', '$filter', |
43 |
| - function($parse, $filter){ |
44 |
| - var RowCol = function RowCol(row, col) { |
45 |
| - /** |
46 |
| - * @ngdoc object |
47 |
| - * @name row |
48 |
| - * @propertyOf ui.grid.cellNav.object:RowCol |
49 |
| - * @description {@link ui.grid.class:GridRow } |
50 |
| - */ |
51 |
| - this.row = row; |
52 |
| - /** |
53 |
| - * @ngdoc object |
54 |
| - * @name col |
55 |
| - * @propertyOf ui.grid.cellNav.object:RowCol |
56 |
| - * @description {@link ui.grid.class:GridColumn } |
57 |
| - */ |
58 |
| - this.col = col; |
59 |
| - }; |
60 |
| - |
61 |
| - /** |
62 |
| - * @ngdoc function |
63 |
| - * @name getIntersectionValueRaw |
64 |
| - * @methodOf ui.grid.cellNav.object:RowCol |
65 |
| - * @description Gets the intersection of where the row and column meet. |
66 |
| - * @returns {String|Number|Object} The value from the grid data that this RowCol points too. |
67 |
| - * If the column has a cellFilter this will NOT return the filtered value. |
68 |
| - */ |
69 |
| - RowCol.prototype.getIntersectionValueRaw = function(){ |
70 |
| - var getter = $parse(this.row.getEntityQualifiedColField(this.col)); |
71 |
| - var context = this.row; |
72 |
| - return getter(context); |
73 |
| - }; |
74 |
| - /** |
75 |
| - * @ngdoc function |
76 |
| - * @name getIntersectionValueFiltered |
77 |
| - * @methodOf ui.grid.cellNav.object:RowCol |
78 |
| - * @description Gets the intersection of where the row and column meet. |
79 |
| - * @returns {String|Number|Object} The value from the grid data that this RowCol points too. |
80 |
| - * If the column has a cellFilter this will also apply the filter to it and return the value that the filter displays. |
81 |
| - */ |
82 |
| - RowCol.prototype.getIntersectionValueFiltered = function(){ |
83 |
| - var value = this.getIntersectionValueRaw(); |
84 |
| - if (this.col.cellFilter && this.col.cellFilter !== ''){ |
85 |
| - var getFilterIfExists = function(filterName){ |
86 |
| - try { |
87 |
| - return $filter(filterName); |
88 |
| - } catch (e){ |
89 |
| - return null; |
90 |
| - } |
91 |
| - }; |
92 |
| - var filter = getFilterIfExists(this.col.cellFilter); |
93 |
| - if (filter) { // Check if this is filter name or a filter string |
94 |
| - value = filter(value); |
95 |
| - } else { // We have the template version of a filter so we need to parse it apart |
96 |
| - // Get the filter params out using a regex |
97 |
| - // Test out this regex here https://regex101.com/r/rC5eR5/2 |
98 |
| - var re = /([^:]*):([^:]*):?([\s\S]+)?/; |
99 |
| - var matches; |
100 |
| - if ((matches = re.exec(this.col.cellFilter)) !== null) { |
101 |
| - // View your result using the matches-variable. |
102 |
| - // eg matches[0] etc. |
103 |
| - value = $filter(matches[1])(value, matches[2], matches[3]); |
104 |
| - } |
105 |
| - } |
106 |
| - } |
107 |
| - return value; |
108 |
| - }; |
109 |
| - return RowCol; |
110 |
| - }]); |
111 |
| - |
112 | 35 |
|
113 |
| - module.factory('uiGridCellNavFactory', ['gridUtil', 'uiGridConstants', 'uiGridCellNavConstants', 'RowColFactory', '$q', |
114 |
| - function (gridUtil, uiGridConstants, uiGridCellNavConstants, RowCol, $q) { |
| 36 | + module.factory('uiGridCellNavFactory', ['gridUtil', 'uiGridConstants', 'uiGridCellNavConstants', 'GridRowColumn', '$q', |
| 37 | + function (gridUtil, uiGridConstants, uiGridCellNavConstants, GridRowColumn, $q) { |
115 | 38 | /**
|
116 | 39 | * @ngdoc object
|
117 | 40 | * @name ui.grid.cellNav.object:CellNav
|
|
188 | 111 |
|
189 | 112 | var curRowIndex = 0;
|
190 | 113 | var curColIndex = 0;
|
191 |
| - return new RowCol(focusableRows[0], focusableCols[0]); //return same row |
| 114 | + return new GridRowColumn(focusableRows[0], focusableCols[0]); //return same row |
192 | 115 | };
|
193 | 116 |
|
194 | 117 | UiGridCellNav.prototype.getRowColLeft = function (curRow, curCol) {
|
|
211 | 134 | // return null;
|
212 | 135 | // }
|
213 | 136 | if (curRowIndex === 0) {
|
214 |
| - return new RowCol(curRow, focusableCols[nextColIndex]); //return same row |
| 137 | + return new GridRowColumn(curRow, focusableCols[nextColIndex]); //return same row |
215 | 138 | }
|
216 | 139 | else {
|
217 | 140 | //up one row and far right column
|
218 |
| - return new RowCol(focusableRows[curRowIndex - 1], focusableCols[nextColIndex]); |
| 141 | + return new GridRowColumn(focusableRows[curRowIndex - 1], focusableCols[nextColIndex]); |
219 | 142 | }
|
220 | 143 | }
|
221 | 144 | else {
|
222 |
| - return new RowCol(curRow, focusableCols[nextColIndex]); |
| 145 | + return new GridRowColumn(curRow, focusableCols[nextColIndex]); |
223 | 146 | }
|
224 | 147 | };
|
225 | 148 |
|
|
239 | 162 |
|
240 | 163 | if (nextColIndex < curColIndex) {
|
241 | 164 | if (curRowIndex === focusableRows.length - 1) {
|
242 |
| - return new RowCol(curRow, focusableCols[nextColIndex]); //return same row |
| 165 | + return new GridRowColumn(curRow, focusableCols[nextColIndex]); //return same row |
243 | 166 | }
|
244 | 167 | else {
|
245 | 168 | //down one row and far left column
|
246 |
| - return new RowCol(focusableRows[curRowIndex + 1], focusableCols[nextColIndex]); |
| 169 | + return new GridRowColumn(focusableRows[curRowIndex + 1], focusableCols[nextColIndex]); |
247 | 170 | }
|
248 | 171 | }
|
249 | 172 | else {
|
250 |
| - return new RowCol(curRow, focusableCols[nextColIndex]); |
| 173 | + return new GridRowColumn(curRow, focusableCols[nextColIndex]); |
251 | 174 | }
|
252 | 175 | };
|
253 | 176 |
|
|
263 | 186 | }
|
264 | 187 |
|
265 | 188 | if (curRowIndex === focusableRows.length - 1) {
|
266 |
| - return new RowCol(curRow, focusableCols[curColIndex]); //return same row |
| 189 | + return new GridRowColumn(curRow, focusableCols[curColIndex]); //return same row |
267 | 190 | }
|
268 | 191 | else {
|
269 | 192 | //down one row
|
270 |
| - return new RowCol(focusableRows[curRowIndex + 1], focusableCols[curColIndex]); |
| 193 | + return new GridRowColumn(focusableRows[curRowIndex + 1], focusableCols[curColIndex]); |
271 | 194 | }
|
272 | 195 | };
|
273 | 196 |
|
|
284 | 207 |
|
285 | 208 | var pageSize = this.bodyContainer.minRowsToRender();
|
286 | 209 | if (curRowIndex >= focusableRows.length - pageSize) {
|
287 |
| - return new RowCol(focusableRows[focusableRows.length - 1], focusableCols[curColIndex]); //return last row |
| 210 | + return new GridRowColumn(focusableRows[focusableRows.length - 1], focusableCols[curColIndex]); //return last row |
288 | 211 | }
|
289 | 212 | else {
|
290 | 213 | //down one page
|
291 |
| - return new RowCol(focusableRows[curRowIndex + pageSize], focusableCols[curColIndex]); |
| 214 | + return new GridRowColumn(focusableRows[curRowIndex + pageSize], focusableCols[curColIndex]); |
292 | 215 | }
|
293 | 216 | };
|
294 | 217 |
|
|
304 | 227 | }
|
305 | 228 |
|
306 | 229 | if (curRowIndex === 0) {
|
307 |
| - return new RowCol(curRow, focusableCols[curColIndex]); //return same row |
| 230 | + return new GridRowColumn(curRow, focusableCols[curColIndex]); //return same row |
308 | 231 | }
|
309 | 232 | else {
|
310 | 233 | //up one row
|
311 |
| - return new RowCol(focusableRows[curRowIndex - 1], focusableCols[curColIndex]); |
| 234 | + return new GridRowColumn(focusableRows[curRowIndex - 1], focusableCols[curColIndex]); |
312 | 235 | }
|
313 | 236 | };
|
314 | 237 |
|
|
325 | 248 |
|
326 | 249 | var pageSize = this.bodyContainer.minRowsToRender();
|
327 | 250 | if (curRowIndex - pageSize < 0) {
|
328 |
| - return new RowCol(focusableRows[0], focusableCols[curColIndex]); //return first row |
| 251 | + return new GridRowColumn(focusableRows[0], focusableCols[curColIndex]); //return first row |
329 | 252 | }
|
330 | 253 | else {
|
331 | 254 | //up one page
|
332 |
| - return new RowCol(focusableRows[curRowIndex - pageSize], focusableCols[curColIndex]); |
| 255 | + return new GridRowColumn(focusableRows[curRowIndex - pageSize], focusableCols[curColIndex]); |
333 | 256 | }
|
334 | 257 | };
|
335 | 258 | return UiGridCellNav;
|
|
342 | 265 | * @description Services for cell navigation features. If you don't like the key maps we use,
|
343 | 266 | * or the direction cells navigation, override with a service decorator (see angular docs)
|
344 | 267 | */
|
345 |
| - module.service('uiGridCellNavService', ['gridUtil', 'uiGridConstants', 'uiGridCellNavConstants', '$q', 'uiGridCellNavFactory', 'RowColFactory', 'ScrollEvent', |
346 |
| - function (gridUtil, uiGridConstants, uiGridCellNavConstants, $q, UiGridCellNav, RowCol, ScrollEvent) { |
| 268 | + module.service('uiGridCellNavService', ['gridUtil', 'uiGridConstants', 'uiGridCellNavConstants', '$q', 'uiGridCellNavFactory', 'GridRowColumn', 'ScrollEvent', |
| 269 | + function (gridUtil, uiGridConstants, uiGridCellNavConstants, $q, UiGridCellNav, GridRowColumn, ScrollEvent) { |
347 | 270 |
|
348 | 271 | var service = {
|
349 | 272 |
|
|
452 | 375 | * @ngdoc function
|
453 | 376 | * @name rowColSelectIndex
|
454 | 377 | * @methodOf ui.grid.cellNav.api:PublicApi
|
455 |
| - * @description returns the index in the order in which the RowCol was selected, returns -1 if the RowCol |
| 378 | + * @description returns the index in the order in which the GridRowColumn was selected, returns -1 if the GridRowColumn |
456 | 379 | * isn't selected
|
457 | 380 | * @param {object} rowCol the rowCol to evaluate
|
458 | 381 | */
|
|
696 | 619 | </file>
|
697 | 620 | </example>
|
698 | 621 | */
|
699 |
| - module.directive('uiGridCellnav', ['gridUtil', 'uiGridCellNavService', 'uiGridCellNavConstants', 'uiGridConstants', 'RowColFactory', '$timeout', '$compile', |
700 |
| - function (gridUtil, uiGridCellNavService, uiGridCellNavConstants, uiGridConstants, RowCol, $timeout, $compile) { |
| 622 | + module.directive('uiGridCellnav', ['gridUtil', 'uiGridCellNavService', 'uiGridCellNavConstants', 'uiGridConstants', 'GridRowColumn', '$timeout', '$compile', |
| 623 | + function (gridUtil, uiGridCellNavService, uiGridCellNavConstants, uiGridConstants, GridRowColumn, $timeout, $compile) { |
701 | 624 | return {
|
702 | 625 | replace: true,
|
703 | 626 | priority: -150,
|
|
716 | 639 |
|
717 | 640 | //Ensure that the object has all of the methods we expect it to
|
718 | 641 | uiGridCtrl.cellNav.makeRowCol = function (obj) {
|
719 |
| - if (!(obj instanceof RowCol)) { |
720 |
| - obj = new RowCol(obj.row, obj.col); |
| 642 | + if (!(obj instanceof GridRowColumn)) { |
| 643 | + obj = new GridRowColumn(obj.row, obj.col); |
721 | 644 | }
|
722 | 645 | return obj;
|
723 | 646 | };
|
|
756 | 679 | var rowColSelectIndex = uiGridCtrl.grid.api.cellNav.rowColSelectIndex(rowCol);
|
757 | 680 |
|
758 | 681 | if (grid.cellNav.lastRowCol === null || rowColSelectIndex === -1) {
|
759 |
| - var newRowCol = new RowCol(row, col); |
| 682 | + var newRowCol = new GridRowColumn(row, col); |
760 | 683 |
|
761 | 684 | grid.api.cellNav.raise.navigate(newRowCol, grid.cellNav.lastRowCol);
|
762 | 685 | grid.cellNav.lastRowCol = newRowCol;
|
|
1088 | 1011 | * @restrict A
|
1089 | 1012 | * @description Stacks on top of ui.grid.uiGridCell to provide cell navigation
|
1090 | 1013 | */
|
1091 |
| - module.directive('uiGridCell', ['$timeout', '$document', 'uiGridCellNavService', 'gridUtil', 'uiGridCellNavConstants', 'uiGridConstants', 'RowColFactory', |
1092 |
| - function ($timeout, $document, uiGridCellNavService, gridUtil, uiGridCellNavConstants, uiGridConstants, RowCol) { |
| 1014 | + module.directive('uiGridCell', ['$timeout', '$document', 'uiGridCellNavService', 'gridUtil', 'uiGridCellNavConstants', 'uiGridConstants', 'GridRowColumn', |
| 1015 | + function ($timeout, $document, uiGridCellNavService, gridUtil, uiGridCellNavConstants, uiGridConstants, GridRowColumn) { |
1093 | 1016 | return {
|
1094 | 1017 | priority: -150, // run after default uiGridCell directive and ui.grid.edit uiGridCell
|
1095 | 1018 | restrict: 'A',
|
|
1114 | 1037 |
|
1115 | 1038 | // When a cell is clicked, broadcast a cellNav event saying that this row+col combo is now focused
|
1116 | 1039 | $elm.find('div').on('click', function (evt) {
|
1117 |
| - uiGridCtrl.cellNav.broadcastCellNav(new RowCol($scope.row, $scope.col), evt.ctrlKey || evt.metaKey, evt); |
| 1040 | + uiGridCtrl.cellNav.broadcastCellNav(new GridRowColumn($scope.row, $scope.col), evt.ctrlKey || evt.metaKey, evt); |
1118 | 1041 |
|
1119 | 1042 | evt.stopPropagation();
|
1120 | 1043 | $scope.$apply();
|
|
1152 | 1075 |
|
1153 | 1076 | //You can only focus on elements with a tabindex value
|
1154 | 1077 | $elm.on('focus', function (evt) {
|
1155 |
| - uiGridCtrl.cellNav.broadcastCellNav(new RowCol($scope.row, $scope.col), false, evt); |
| 1078 | + uiGridCtrl.cellNav.broadcastCellNav(new GridRowColumn($scope.row, $scope.col), false, evt); |
1156 | 1079 | evt.stopPropagation();
|
1157 | 1080 | $scope.$apply();
|
1158 | 1081 | });
|
|
0 commit comments