Skip to content

Commit

Permalink
Fix for #436. Thanks @swalters
Browse files Browse the repository at this point in the history
  • Loading branch information
jonricaurte committed Jun 27, 2013
1 parent 5e823dd commit d7fb194
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 66 deletions.
30 changes: 14 additions & 16 deletions build/ng-grid.debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* ng-grid JavaScript Library
* Authors: https://github.com/angular-ui/ng-grid/blob/master/README.md
* License: MIT (http://www.opensource.org/licenses/mit-license.php)
* Compiled At: 06/26/2013 08:34
* Compiled At: 06/26/2013 19:28
***********************************************/
(function(window, $) {
'use strict';
Expand Down Expand Up @@ -2821,22 +2821,12 @@ ngGridDirectives.directive('ngCellHasFocus', ['$domUtilityService',
$scope.isFocused = true;
domUtilityService.digest($scope);

//Remove html comments for IE8
var elementWithoutComments = angular.element(elm[0].children).filter(function () {
return this.nodeType !== 8;
});

var inputElement = angular.element(elementWithoutComments[0].children[0]);
$scope.$broadcast('ngGridEventStartCellEdit');

if (inputElement.length > 0) {
angular.element(inputElement).focus();
$scope.domAccessProvider.selectInputElement(inputElement[0]);
angular.element(inputElement).bind('blur', function(){
$scope.isFocused = false;
domUtilityService.digest($scope);
return true;
});
}
$scope.$on('ngGridEventEndCellEdit', function() {
$scope.isFocused = false;
domUtilityService.digest($scope);
});
};

return function($scope, elm) {
Expand Down Expand Up @@ -3229,6 +3219,14 @@ ngGridDirectives.directive('ngInput', [function() {
elm.bind('mousedown', function(evt) {
evt.stopPropagation();
});

scope.$on('ngGridEventStartCellEdit', function () {
elm.focus();
});

angular.element(elm).bind('blur', function () {
scope.$emit('ngGridEventEndCellEdit');
});
}
};
}]);
Expand Down
29 changes: 14 additions & 15 deletions build/ng-grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* ng-grid JavaScript Library
* Authors: https://github.com/angular-ui/ng-grid/blob/master/README.md
* License: MIT (http://www.opensource.org/licenses/mit-license.php)
* Compiled At: 06/26/2013 08:34
* Compiled At: 06/26/2013 19:28
***********************************************/
(function(window, $) {
'use strict';
Expand Down Expand Up @@ -2503,20 +2503,12 @@ ngGridDirectives.directive('ngCellHasFocus', ['$domUtilityService',
var focusOnInputElement = function($scope, elm){
$scope.isFocused = true;
domUtilityService.digest($scope);
var elementWithoutComments = angular.element(elm[0].children).filter(function () {
return this.nodeType !== 8;
});
$scope.$broadcast('ngGridEventStartCellEdit');

var inputElement = angular.element(elementWithoutComments[0].children[0]);
if (inputElement.length > 0) {
angular.element(inputElement).focus();
$scope.domAccessProvider.selectInputElement(inputElement[0]);
angular.element(inputElement).bind('blur', function(){
$scope.isFocused = false;
domUtilityService.digest($scope);
return true;
});
}
$scope.$on('ngGridEventEndCellEdit', function() {
$scope.isFocused = false;
domUtilityService.digest($scope);
});
};

return function($scope, elm) {
Expand Down Expand Up @@ -2872,7 +2864,14 @@ ngGridDirectives.directive('ngInput', [function() {
});
elm.bind('mousedown', function(evt) {
evt.stopPropagation();
});
});
scope.$on('ngGridEventStartCellEdit', function () {
elm.focus();
});

angular.element(elm).bind('blur', function () {
scope.$emit('ngGridEventEndCellEdit');
});
}
};
}]);
Expand Down
4 changes: 2 additions & 2 deletions build/ng-grid.min.js

Large diffs are not rendered by default.

30 changes: 14 additions & 16 deletions ng-grid-2.0.7.debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* ng-grid JavaScript Library
* Authors: https://github.com/angular-ui/ng-grid/blob/master/README.md
* License: MIT (http://www.opensource.org/licenses/mit-license.php)
* Compiled At: 06/26/2013 08:34
* Compiled At: 06/26/2013 19:28
***********************************************/
(function(window, $) {
'use strict';
Expand Down Expand Up @@ -2821,22 +2821,12 @@ ngGridDirectives.directive('ngCellHasFocus', ['$domUtilityService',
$scope.isFocused = true;
domUtilityService.digest($scope);

//Remove html comments for IE8
var elementWithoutComments = angular.element(elm[0].children).filter(function () {
return this.nodeType !== 8;
});

var inputElement = angular.element(elementWithoutComments[0].children[0]);
$scope.$broadcast('ngGridEventStartCellEdit');

if (inputElement.length > 0) {
angular.element(inputElement).focus();
$scope.domAccessProvider.selectInputElement(inputElement[0]);
angular.element(inputElement).bind('blur', function(){
$scope.isFocused = false;
domUtilityService.digest($scope);
return true;
});
}
$scope.$on('ngGridEventEndCellEdit', function() {
$scope.isFocused = false;
domUtilityService.digest($scope);
});
};

return function($scope, elm) {
Expand Down Expand Up @@ -3229,6 +3219,14 @@ ngGridDirectives.directive('ngInput', [function() {
elm.bind('mousedown', function(evt) {
evt.stopPropagation();
});

scope.$on('ngGridEventStartCellEdit', function () {
elm.focus();
});

angular.element(elm).bind('blur', function () {
scope.$emit('ngGridEventEndCellEdit');
});
}
};
}]);
Expand Down
4 changes: 2 additions & 2 deletions ng-grid-2.0.7.min.js

Large diffs are not rendered by default.

20 changes: 5 additions & 15 deletions src/directives/ng-cell-has-focus.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,12 @@ ngGridDirectives.directive('ngCellHasFocus', ['$domUtilityService',
$scope.isFocused = true;
domUtilityService.digest($scope);

//Remove html comments for IE8
var elementWithoutComments = angular.element(elm[0].children).filter(function () {
return this.nodeType !== 8;
});

var inputElement = angular.element(elementWithoutComments[0].children[0]);
$scope.$broadcast('ngGridEventStartCellEdit');

if (inputElement.length > 0) {
angular.element(inputElement).focus();
$scope.domAccessProvider.selectInputElement(inputElement[0]);
angular.element(inputElement).bind('blur', function(){
$scope.isFocused = false;
domUtilityService.digest($scope);
return true;
});
}
$scope.$on('ngGridEventEndCellEdit', function() {
$scope.isFocused = false;
domUtilityService.digest($scope);
});
};

return function($scope, elm) {
Expand Down
8 changes: 8 additions & 0 deletions src/directives/ng-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ ngGridDirectives.directive('ngInput', [function() {
elm.bind('mousedown', function(evt) {
evt.stopPropagation();
});

scope.$on('ngGridEventStartCellEdit', function () {
elm.focus();
});

angular.element(elm).bind('blur', function () {
scope.$emit('ngGridEventEndCellEdit');
});
}
};
}]);

0 comments on commit d7fb194

Please sign in to comment.