Skip to content
This repository has been archived by the owner. It is now read-only.

feat(timepicker): have up/down arrow keys control time selection #3068

Closed
wants to merge 4 commits into from

Conversation

@joshfriend
Copy link
Contributor

joshfriend commented Dec 8, 2014

Similar to #2316, but:

  • has tests/docs.
  • properly consumes up/down events with preventDefault.
@joshfriend joshfriend force-pushed the MichiganLabs:arrowkeys branch from acca308 to 8a50318 Dec 8, 2014
@joshfriend joshfriend force-pushed the MichiganLabs:arrowkeys branch from 8a50318 to a3acc79 Dec 9, 2014
@wesleycho wesleycho force-pushed the angular-ui:master branch from e373941 to 2c2dba6 Mar 23, 2015
hoursInputEl.bind('keydown', function(e) {
if ( e.which === 38 ) { // up
$scope.$apply(function() {
$scope.incrementHours();

This comment has been minimized.

Copy link
@wesleycho

wesleycho Mar 23, 2015

Member

This should be rewritten as

$scope.incrementHours();
$scope.$apply();
}
else if ( e.which === 40 ) { // down
$scope.$apply(function() {
$scope.decrementHours();

This comment has been minimized.

Copy link
@wesleycho

wesleycho Mar 23, 2015

Member

Similarly here.

$scope.$apply(function() {
$scope.incrementHours();
});
e.preventDefault();

This comment has been minimized.

Copy link
@wesleycho

wesleycho Mar 23, 2015

Member

This should be at the top of the if conditional

$scope.$apply(function() {
$scope.decrementHours();
});
e.preventDefault();

This comment has been minimized.

Copy link
@wesleycho

wesleycho Mar 23, 2015

Member

Same here

$scope.$apply(function() {
$scope.incrementMinutes();
});
e.preventDefault();

This comment has been minimized.

Copy link
@wesleycho

wesleycho Mar 23, 2015

Member

Same with this if block

$scope.$apply(function() {
$scope.decrementMinutes();
});
e.preventDefault();

This comment has been minimized.

Copy link
@wesleycho

wesleycho Mar 23, 2015

Member

Same here.

@@ -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.

Copy link
@wesleycho

wesleycho Mar 23, 2015

Member

This would be better changed to use the isolate scope in the directive.

This comment has been minimized.

Copy link
@joshfriend

joshfriend Mar 23, 2015

Author Contributor

meaning I should use $scope.$eval instead of $scope.$parent.$eval?

@wesleycho wesleycho added this to the 0.14 milestone Mar 23, 2015
@@ -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.

Copy link
@wesleycho

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.

Copy link
@wesleycho

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.

@wesleycho
Copy link
Member

wesleycho commented Mar 23, 2015

This LGTM once that change is made back to use $scope.$parent.$eval.

…ope"

This reverts commit 0027763.
@joshfriend
Copy link
Contributor Author

joshfriend commented Mar 23, 2015

@wesleycho would you like me to rebase this branch so that 0027763 and 8eb93ce are squashed?

@wesleycho
Copy link
Member

wesleycho commented Mar 23, 2015

That won't be necessary, I can do the rebasing if needed.

@wesleycho
Copy link
Member

wesleycho commented Mar 23, 2015

Landed as 2296115, thanks!

@wesleycho wesleycho closed this Mar 23, 2015
@wesleycho wesleycho removed the needs: work label Mar 23, 2015
@wesleycho wesleycho modified the milestones: 0.13.0, 0.14 Mar 23, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.