diff --git a/source/nuComponents.DataTypes/Shared/ListPicker/ListPickerEditorController.js b/source/nuComponents.DataTypes/Shared/ListPicker/ListPickerEditorController.js index 8d812a3..a39c5c3 100644 --- a/source/nuComponents.DataTypes/Shared/ListPicker/ListPickerEditorController.js +++ b/source/nuComponents.DataTypes/Shared/ListPicker/ListPickerEditorController.js @@ -30,6 +30,18 @@ angular return $scope.isSelectable(option) && ($scope.selectedOptions.length < $scope.model.config.listPicker.maxItems || $scope.model.config.listPicker.maxItems <= 0); }; + $scope.cursorUp = function () { + // TODO: move highlight / active of next selectable + }; + + $scope.cursorDown = function () { + // TODO: move highlight / active of previous selectable + }; + + $scope.enterKey = function () { + // TODO: select highlighted + } + // picking an item from 'selectable' for 'selected' $scope.selectOption = function (option) { if ($scope.isValidSelection(option)) { diff --git a/source/nuComponents.DataTypes/Shared/ListPicker/ListPickerEditorDirectives.js b/source/nuComponents.DataTypes/Shared/ListPicker/ListPickerEditorDirectives.js index da6fcff..8bdbf4d 100644 --- a/source/nuComponents.DataTypes/Shared/ListPicker/ListPickerEditorDirectives.js +++ b/source/nuComponents.DataTypes/Shared/ListPicker/ListPickerEditorDirectives.js @@ -33,3 +33,20 @@ angular } } }); + +angular + .module("umbraco.directives") + .directive('nuEnterKey', function () { + return { + restrict: 'A', + link: function (scope, element, attrs) { + + element.bind('keydown keypress', function (event) { + if (event.which === 13) { + scope.$apply(attrs.nuCursorDown); + event.preventDefault(); + } + }); + } + } + }); diff --git a/source/nuComponents.DataTypes/Shared/PrefetchListPicker/PrefetchListPickerEditor.html b/source/nuComponents.DataTypes/Shared/PrefetchListPicker/PrefetchListPickerEditor.html index b42404c..ab1b5e2 100644 --- a/source/nuComponents.DataTypes/Shared/PrefetchListPicker/PrefetchListPickerEditor.html +++ b/source/nuComponents.DataTypes/Shared/PrefetchListPicker/PrefetchListPickerEditor.html @@ -13,7 +13,10 @@ + ng-trim="false" + nu-cursor-up="cursorUp()" + nu-cursor-down="cursorDown()" + nu-enter-key="enterKey()" /> diff --git a/source/nuComponents.DataTypes/Shared/TypeaheadListPicker/TypeaheadListPickerEditor.html b/source/nuComponents.DataTypes/Shared/TypeaheadListPicker/TypeaheadListPickerEditor.html index 769f889..024a866 100644 --- a/source/nuComponents.DataTypes/Shared/TypeaheadListPicker/TypeaheadListPickerEditor.html +++ b/source/nuComponents.DataTypes/Shared/TypeaheadListPicker/TypeaheadListPickerEditor.html @@ -14,7 +14,8 @@ autocomplete="off" ng-model="typeahead" nu-cursor-up="cursorUp()" - nu-cursor-down="cursorDown()" /> + nu-cursor-down="cursorDown()" + nu-enter-key="enterKey()" /> diff --git a/source/nuComponents.DataTypes/Shared/TypeaheadListPicker/TypeaheadListPickerEditorController.js b/source/nuComponents.DataTypes/Shared/TypeaheadListPicker/TypeaheadListPickerEditorController.js index c6912f8..dca1117 100644 --- a/source/nuComponents.DataTypes/Shared/TypeaheadListPicker/TypeaheadListPickerEditorController.js +++ b/source/nuComponents.DataTypes/Shared/TypeaheadListPicker/TypeaheadListPickerEditorController.js @@ -4,15 +4,7 @@ angular .controller("nuComponents.DataTypes.Shared.TypeaheadListPicker.TypeaheadListPickerEditorController", ['$scope', function ($scope) { - - $scope.cursorUp = function () { - // move highlight / active of selectable to next - }; - - $scope.cursorDown = function () { - // move highlight / active of selectable to previous - }; - + //$scope.clear = function () { // $scope.typeahead = null; // $scope.selectableOptions = null; @@ -36,7 +28,7 @@ angular } else { - $scope.selectableOptions = null; + $scope.selectableOptions = []; } });