From 97ec0ecd08222522b8556c561bf75c4dde049265 Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Tue, 25 Jul 2017 15:48:04 +0200 Subject: [PATCH 1/8] add umb-dropdown component --- .../components/umbdropdown.directive.js | 19 +++++++++++++++++++ .../components/umbdropdownitem.directive.js | 19 +++++++++++++++++++ .../views/components/umb-dropdown-item.html | 1 + .../src/views/components/umb-dropdown.html | 1 + 4 files changed, 40 insertions(+) create mode 100644 src/Umbraco.Web.UI.Client/src/common/directives/components/umbdropdown.directive.js create mode 100644 src/Umbraco.Web.UI.Client/src/common/directives/components/umbdropdownitem.directive.js create mode 100644 src/Umbraco.Web.UI.Client/src/views/components/umb-dropdown-item.html create mode 100644 src/Umbraco.Web.UI.Client/src/views/components/umb-dropdown.html diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/umbdropdown.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/umbdropdown.directive.js new file mode 100644 index 0000000000..8447083de3 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/umbdropdown.directive.js @@ -0,0 +1,19 @@ +(function() { + 'use strict'; + + function umbDropdown() { + + var directive = { + restrict: 'E', + replace: true, + transclude: true, + templateUrl: 'views/components/umb-dropdown.html' + }; + + return directive; + + } + + angular.module('umbraco.directives').directive('umbDropdown', umbDropdown); + +})(); diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/umbdropdownitem.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/umbdropdownitem.directive.js new file mode 100644 index 0000000000..88f033d4e6 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/umbdropdownitem.directive.js @@ -0,0 +1,19 @@ +(function() { + 'use strict'; + + function umbDropdownItem() { + + var directive = { + restrict: 'E', + replace: true, + transclude: true, + templateUrl: 'views/components/umb-dropdown-item.html', + }; + + return directive; + + } + + angular.module('umbraco.directives').directive('umbDropdownItem', umbDropdownItem); + +})(); diff --git a/src/Umbraco.Web.UI.Client/src/views/components/umb-dropdown-item.html b/src/Umbraco.Web.UI.Client/src/views/components/umb-dropdown-item.html new file mode 100644 index 0000000000..11fe294919 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/views/components/umb-dropdown-item.html @@ -0,0 +1 @@ +
  • \ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/src/views/components/umb-dropdown.html b/src/Umbraco.Web.UI.Client/src/views/components/umb-dropdown.html new file mode 100644 index 0000000000..3410665f4a --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/views/components/umb-dropdown.html @@ -0,0 +1 @@ + \ No newline at end of file From abbee60c9c699fb2198fc7b142a9533f86ba2cd5 Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Tue, 25 Jul 2017 15:56:51 +0200 Subject: [PATCH 2/8] add directive to navigate a list with arrow up and down --- .../util/umbkeyboardlist.directive.js | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 src/Umbraco.Web.UI.Client/src/common/directives/util/umbkeyboardlist.directive.js diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/util/umbkeyboardlist.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/util/umbkeyboardlist.directive.js new file mode 100644 index 0000000000..0b189e3669 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/common/directives/util/umbkeyboardlist.directive.js @@ -0,0 +1,55 @@ +angular.module('umbraco.directives') + .directive('umbKeyboardList', ['$document', '$timeout', function ($document, $timeout) { + + return { + restrict: 'A', + link: function (scope, element, attr) { + + var listItems = []; + var currentIndex = 0; + var focusSet = false; + + $timeout(function(){ + // get list of all links in the list + listItems = element.find("li a"); + }); + + // Handle keydown events + function keydown(event) { + + // arrow down + if (event.keyCode === 40) { + if(currentIndex < listItems.length - 1) { + // we do this to focus the first element when + // using the arrow down key the first time + if(focusSet) { + currentIndex++; + } + listItems[currentIndex].focus(); + focusSet = true; + } + } + + // arrow up + if (event.keyCode === 38) { + if(currentIndex > 0) { + currentIndex--; + listItems[currentIndex].focus(); + } + } + } + + // Stop to listen typing. + function stopListening() { + $document.off('keydown', keydown); + } + + // Start listening to key typing. + $document.on('keydown', keydown); + + // Stop listening when scope is destroyed. + scope.$on('$destroy', stopListening); + + } + }; + }]); \ No newline at end of file From 9b1f2352bd4a176fa5a2f4d61da9e2640a62be40 Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Tue, 25 Jul 2017 15:58:14 +0200 Subject: [PATCH 3/8] update view to use the new dropdown component and the list navigation directive --- .../src/views/users/views/users/users.html | 48 +++++++++---------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/users/views/users/users.html b/src/Umbraco.Web.UI.Client/src/views/users/views/users/users.html index 4490b33e43..167ebcc221 100644 --- a/src/Umbraco.Web.UI.Client/src/views/users/views/users/users.html +++ b/src/Umbraco.Web.UI.Client/src/views/users/views/users/users.html @@ -1,7 +1,5 @@
    - - @@ -102,51 +100,51 @@
    -