2
2
* ng-grid JavaScript Library
3
3
* Authors: https://github.com/angular-ui/ng-grid/blob/master/README.md
4
4
* License: MIT (http://www.opensource.org/licenses/mit-license.php)
5
- * Compiled At: 09/02 /2014 10:22
5
+ * Compiled At: 11/04 /2014 09:19
6
6
***********************************************/
7
7
( function ( window , $ ) {
8
8
'use strict' ;
@@ -39,7 +39,11 @@ var ngGridFilters = angular.module('ngGrid.filters', []);
39
39
angular . module ( 'ngGrid' , [ 'ngGrid.services' , 'ngGrid.directives' , 'ngGrid.filters' ] ) ;
40
40
//set event binding on the grid so we can select using the up/down keys
41
41
var ngMoveSelectionHandler = function ( $scope , elm , evt , grid ) {
42
- if ( $scope . selectionProvider . selectedItems === undefined ) {
42
+ if ( $scope . selectionProvider . selectedItems === undefined || grid . config . noKeyboardNavigation ) {
43
+ return true ;
44
+ }
45
+
46
+ if ( document . activeElement . tagName === "INPUT" ) {
43
47
return true ;
44
48
}
45
49
@@ -60,7 +64,7 @@ var ngMoveSelectionHandler = function($scope, elm, evt, grid) {
60
64
if ( charCode !== 37 && charCode !== 38 && charCode !== 39 && charCode !== 40 && ( grid . config . noTabInterference || charCode !== 9 ) && charCode !== 13 ) {
61
65
return true ;
62
66
}
63
-
67
+
64
68
if ( $scope . enableCellSelection ) {
65
69
if ( charCode === 9 ) { //tab key
66
70
evt . preventDefault ( ) ;
@@ -71,7 +75,7 @@ var ngMoveSelectionHandler = function($scope, elm, evt, grid) {
71
75
var focusedOnLastVisibleColumns = newColumnIndex === ( visibleCols . length - 1 ) || newColumnIndex === ( visibleCols . length - 2 ) ;
72
76
var focusedOnLastColumn = visibleCols . indexOf ( $scope . col ) === ( visibleCols . length - 1 ) ;
73
77
var focusedOnLastPinnedColumn = pinnedCols . indexOf ( $scope . col ) === ( pinnedCols . length - 1 ) ;
74
-
78
+
75
79
if ( charCode === 37 || charCode === 9 && evt . shiftKey ) {
76
80
var scrollTo = 0 ;
77
81
@@ -94,13 +98,13 @@ var ngMoveSelectionHandler = function($scope, elm, evt, grid) {
94
98
}
95
99
96
100
grid . $viewport . scrollLeft ( scrollTo ) ;
97
-
101
+
98
102
}
99
103
else if ( charCode === 39 || charCode === 9 && ! evt . shiftKey ) {
100
104
if ( focusedOnLastVisibleColumns ) {
101
105
if ( focusedOnLastColumn && charCode === 9 && ! evt . shiftKey ) {
102
106
grid . $viewport . scrollLeft ( 0 ) ;
103
- newColumnIndex = $scope . showSelectionCheckbox ? 1 : 0 ;
107
+ newColumnIndex = $scope . showSelectionCheckbox ? 1 : 0 ;
104
108
lastInRow = true ;
105
109
}
106
110
else {
@@ -116,7 +120,7 @@ var ngMoveSelectionHandler = function($scope, elm, evt, grid) {
116
120
}
117
121
}
118
122
}
119
-
123
+
120
124
var items ;
121
125
if ( $scope . configGroups . length > 0 ) {
122
126
items = grid . rowFactory . parsedData . filter ( function ( row ) {
@@ -126,15 +130,15 @@ var ngMoveSelectionHandler = function($scope, elm, evt, grid) {
126
130
else {
127
131
items = grid . filteredRows ;
128
132
}
129
-
133
+
130
134
var offset = 0 ;
131
135
if ( rowIndex !== 0 && ( charCode === 38 || charCode === 13 && evt . shiftKey || charCode === 9 && evt . shiftKey && firstInRow ) ) { //arrow key up or shift enter or tab key and first item in row
132
136
offset = - 1 ;
133
137
}
134
138
else if ( rowIndex !== items . length - 1 && ( charCode === 40 || charCode === 13 && ! evt . shiftKey || charCode === 9 && lastInRow ) ) { //arrow key down, enter, or tab key and last item in row?
135
139
offset = 1 ;
136
140
}
137
-
141
+
138
142
if ( offset ) {
139
143
var r = items [ rowIndex + offset ] ;
140
144
if ( r . beforeSelectionChange ( r , evt ) ) {
@@ -149,7 +153,7 @@ var ngMoveSelectionHandler = function($scope, elm, evt, grid) {
149
153
}
150
154
}
151
155
}
152
-
156
+
153
157
if ( $scope . enableCellSelection ) {
154
158
setTimeout ( function ( ) {
155
159
$scope . domAccessProvider . focusCellElement ( $scope , $scope . renderedColumns . indexOf ( visibleCols [ newColumnIndex ] ) ) ;
@@ -1075,32 +1079,34 @@ var ngEventProvider = function (grid, $scope, domUtilityService, $timeout) {
1075
1079
self . setDraggables = function ( ) {
1076
1080
if ( ! grid . config . jqueryUIDraggable ) {
1077
1081
//Fix for FireFox. Instead of using jQuery on('dragstart', function) on find, we have to use addEventListeners for each column.
1078
- var columns = grid . $root . find ( '.ngHeaderSortColumn' ) ; //have to iterate if using addEventListener
1079
- angular . forEach ( columns , function ( col ) {
1080
- if ( col . className && col . className . indexOf ( "ngHeaderSortColumn" ) !== - 1 ) {
1081
- col . setAttribute ( 'draggable' , 'true' ) ;
1082
- //jQuery 'on' function doesn't have dataTransfer as part of event in handler unless added to event props, which is not recommended
1083
- //See more here: http://api.jquery.com/category/events/event-object/
1084
- if ( col . addEventListener ) { //IE8 doesn't have drag drop or event listeners
1085
- col . addEventListener ( 'dragstart' , self . dragStart ) ;
1086
-
1087
- angular . element ( col ) . on ( '$destroy' , function ( ) {
1088
- angular . element ( col ) . off ( 'dragstart' , self . dragStart ) ;
1089
- col . removeEventListener ( 'dragstart' , self . dragStart ) ;
1090
- } ) ;
1082
+ if ( grid . $root ) {
1083
+ var columns = grid . $root . find ( '.ngHeaderSortColumn' ) ; //have to iterate if using addEventListener
1084
+ angular . forEach ( columns , function ( col ) {
1085
+ if ( col . className && col . className . indexOf ( "ngHeaderSortColumn" ) !== - 1 ) {
1086
+ col . setAttribute ( 'draggable' , 'true' ) ;
1087
+ //jQuery 'on' function doesn't have dataTransfer as part of event in handler unless added to event props, which is not recommended
1088
+ //See more here: http://api.jquery.com/category/events/event-object/
1089
+ if ( col . addEventListener ) { //IE8 doesn't have drag drop or event listeners
1090
+ col . addEventListener ( 'dragstart' , self . dragStart ) ;
1091
+
1092
+ angular . element ( col ) . on ( '$destroy' , function ( ) {
1093
+ angular . element ( col ) . off ( 'dragstart' , self . dragStart ) ;
1094
+ col . removeEventListener ( 'dragstart' , self . dragStart ) ;
1095
+ } ) ;
1096
+ }
1091
1097
}
1092
- }
1093
- } ) ;
1094
- if ( navigator . userAgent . indexOf ( "MSIE" ) !== - 1 ) {
1095
- //call native IE dragDrop() to start dragging
1096
- var sortColumn = grid . $root . find ( '.ngHeaderSortColumn' ) ;
1097
- sortColumn . bind ( 'selectstart' , function ( ) {
1098
- this . dragDrop ( ) ;
1099
- return false ;
1100
- } ) ;
1101
- angular . element ( sortColumn ) . on ( '$destroy' , function ( ) {
1102
- sortColumn . off ( 'selectstart' ) ;
1103
1098
} ) ;
1099
+ if ( navigator . userAgent . indexOf ( "MSIE" ) !== - 1 ) {
1100
+ //call native IE dragDrop() to start dragging
1101
+ var sortColumn = grid . $root . find ( '.ngHeaderSortColumn' ) ;
1102
+ sortColumn . bind ( 'selectstart' , function ( ) {
1103
+ this . dragDrop ( ) ;
1104
+ return false ;
1105
+ } ) ;
1106
+ angular . element ( sortColumn ) . on ( '$destroy' , function ( ) {
1107
+ sortColumn . off ( 'selectstart' ) ;
1108
+ } ) ;
1109
+ }
1104
1110
}
1105
1111
} else {
1106
1112
if ( grid . $root ) {
@@ -3006,7 +3012,7 @@ var ngSelectionProvider = function (grid, $scope, $parse, $utils) {
3006
3012
if ( ! wasSelected && checkAll ) {
3007
3013
self . selectedItems . push ( rows [ i ] . entity ) ;
3008
3014
} else if ( wasSelected && ! checkAll ) {
3009
- index = self . selectedItems . indexOf ( rows [ i ] . entity ) ;
3015
+ index = self . getSelectionIndex ( rows [ i ] . entity ) ;
3010
3016
if ( index > - 1 ) {
3011
3017
self . selectedItems . splice ( index , 1 ) ;
3012
3018
}
0 commit comments