Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upfeat(timepicker): have up/down arrow keys control time selection #3068
Conversation
| hoursInputEl.bind('keydown', function(e) { | ||
| if ( e.which === 38 ) { // up | ||
| $scope.$apply(function() { | ||
| $scope.incrementHours(); |
This comment has been minimized.
This comment has been minimized.
| } | ||
| else if ( e.which === 40 ) { // down | ||
| $scope.$apply(function() { | ||
| $scope.decrementHours(); |
This comment has been minimized.
This comment has been minimized.
| $scope.$apply(function() { | ||
| $scope.incrementHours(); | ||
| }); | ||
| e.preventDefault(); |
This comment has been minimized.
This comment has been minimized.
| $scope.$apply(function() { | ||
| $scope.decrementHours(); | ||
| }); | ||
| e.preventDefault(); |
This comment has been minimized.
This comment has been minimized.
| $scope.$apply(function() { | ||
| $scope.incrementMinutes(); | ||
| }); | ||
| e.preventDefault(); |
This comment has been minimized.
This comment has been minimized.
| $scope.$apply(function() { | ||
| $scope.decrementMinutes(); | ||
| }); | ||
| e.preventDefault(); |
This comment has been minimized.
This comment has been minimized.
| @@ -26,6 +27,11 @@ angular.module('ui.bootstrap.timepicker', []) | |||
| this.setupMousewheelEvents( hoursInputEl, minutesInputEl ); | |||
| } | |||
|
|
|||
| var arrowkeys = angular.isDefined($attrs.arrowkeys) ? $scope.$parent.$eval($attrs.arrowkeys) : timepickerConfig.arrowkeys; | |||
This comment has been minimized.
This comment has been minimized.
wesleycho
Mar 23, 2015
Member
This would be better changed to use the isolate scope in the directive.
This comment has been minimized.
This comment has been minimized.
joshfriend
Mar 23, 2015
Author
Contributor
meaning I should use $scope.$eval instead of $scope.$parent.$eval?
| @@ -26,6 +27,11 @@ angular.module('ui.bootstrap.timepicker', []) | |||
| this.setupMousewheelEvents( hoursInputEl, minutesInputEl ); | |||
| } | |||
|
|
|||
| var arrowkeys = angular.isDefined($attrs.arrowkeys) ? $scope.$eval($attrs.arrowkeys) : timepickerConfig.arrowkeys; | |||
This comment has been minimized.
This comment has been minimized.
wesleycho
Mar 23, 2015
Member
I meant modify the directive scope to set arrowkeys: '=?'. It should be present by the time the init function is run, so you can directly pull the value from $scope.arrowkeys in that case.
This comment has been minimized.
This comment has been minimized.
wesleycho
Mar 23, 2015
Member
Actually upon looking at the rest of the source, change this back to $scope.$parent.$eval - I would rather have consistency with the rest of the source for now.
|
This LGTM once that change is made back to use $scope.$parent.$eval. |
|
@wesleycho would you like me to rebase this branch so that 0027763 and 8eb93ce are squashed? |
|
That won't be necessary, I can do the rebasing if needed. |
|
Landed as 2296115, thanks! |
joshfriend commentedDec 8, 2014
Similar to #2316, but:
preventDefault.