diff --git a/client/client/src/address-edit/address-edit.html b/client/client/src/address-edit/address-edit.html index c1b9cb20d..1373b3812 100644 --- a/client/client/src/address-edit/address-edit.html +++ b/client/client/src/address-edit/address-edit.html @@ -96,7 +96,8 @@ diff --git a/client/client/src/credit-insurance-list/credit-insurance-list.html b/client/client/src/credit-insurance-list/credit-insurance-list.html index 2e0c9a1b6..a06283000 100644 --- a/client/client/src/credit-insurance-list/credit-insurance-list.html +++ b/client/client/src/credit-insurance-list/credit-insurance-list.html @@ -24,6 +24,6 @@ + fixed-bottom-right vn-tooltip="New classification" vn-bind="+" tooltip-position="left" ng-if="!$ctrl.isClosed"> \ No newline at end of file diff --git a/client/client/src/credit-list/credit-list.html b/client/client/src/credit-list/credit-list.html index 48f4a655e..a3d51aa0e 100644 --- a/client/client/src/credit-list/credit-list.html +++ b/client/client/src/credit-list/credit-list.html @@ -24,6 +24,6 @@ - + \ No newline at end of file diff --git a/client/client/src/greuge-list/greuge-list.html b/client/client/src/greuge-list/greuge-list.html index 2e8d5060f..5122006e8 100644 --- a/client/client/src/greuge-list/greuge-list.html +++ b/client/client/src/greuge-list/greuge-list.html @@ -32,7 +32,7 @@ - + \ No newline at end of file diff --git a/client/client/src/index/index.html b/client/client/src/index/index.html index 63f502e64..e0235052a 100644 --- a/client/client/src/index/index.html +++ b/client/client/src/index/index.html @@ -21,7 +21,7 @@ - + \ No newline at end of file diff --git a/client/client/src/recovery-list/recovery-list.html b/client/client/src/recovery-list/recovery-list.html index 433f934cf..86609e573 100644 --- a/client/client/src/recovery-list/recovery-list.html +++ b/client/client/src/recovery-list/recovery-list.html @@ -32,6 +32,6 @@ - + \ No newline at end of file diff --git a/client/core/src/components/icon-focusable/icon-focusable.html b/client/core/src/components/icon-focusable/icon-focusable.html new file mode 100644 index 000000000..4bd8ad78a --- /dev/null +++ b/client/core/src/components/icon-focusable/icon-focusable.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/client/core/src/components/icon-focusable/icon-focusable.js b/client/core/src/components/icon-focusable/icon-focusable.js new file mode 100644 index 000000000..691ee570f --- /dev/null +++ b/client/core/src/components/icon-focusable/icon-focusable.js @@ -0,0 +1,29 @@ +import ngModule from '../../module'; +import './style.scss'; + +export default class IconFocusable { + constructor($element) { + $element[0].tabIndex = 0; + $element.on("keyup", event => this.onKeyDown(event, $element)); + } + + onKeyDown(event, $element) { + if (event.defaultPrevented) return; + if (event.keyCode == 32 || event.keyCode == 13) { + event.preventDefault(); + $element.triggerHandler('click'); + } + } +} + +IconFocusable.$inject = ['$element']; +ngModule.component('vnIconFocusable', { + controller: IconFocusable, + template: require('./icon-focusable.html'), + bindings: { + icon: '@', + className: '@?', + enabled: ' i, + & > i.material-icons { + display: block; + font-size: inherit; + } +} \ No newline at end of file diff --git a/client/core/src/directives/bind.js b/client/core/src/directives/bind.js new file mode 100644 index 000000000..b9106d617 --- /dev/null +++ b/client/core/src/directives/bind.js @@ -0,0 +1,60 @@ +import ngModule from '../module'; + +directive.$inject = ['$document']; +export function directive($document) { + let modifiers = ["alt", "ctrl", "meta", "shift"]; + + function checkAttributes($attrs) { + let shortcut = $attrs.vnBind.split(' '); + let keys = {}; + + if (shortcut[0] == "") { + throw new Error('vnBind: Binding keys not defined'); + } + + if (shortcut.length == 1) { + keys.altKey = true; + keys.ctrlKey = true; + } else { + let mods = shortcut.splice(0, shortcut.length - 1); + for (let mod of mods) { + if (modifiers.indexOf(mod) == -1) + throw new Error('vnBind: Invalid modifier key in binding'); + + keys[`${mod}Key`] = true; + } + } + + keys.key = shortcut[0]; + if (keys.key == 'space') keys.key = ' '; + + return keys; + } + + return { + restrict: 'A', + link: function($scope, $element, $attrs) { + let shortcut = checkAttributes($attrs); + + function onKeyUp(event) { + if (event.defaultPrevented) return; + let correctShortcut = true; + + for (const key in shortcut) { + correctShortcut = correctShortcut && shortcut[key] == event[key]; + } + if (correctShortcut) { + event.preventDefault(); + $element.triggerHandler('click'); + } + } + + $document.on("keyup", onKeyUp); + $element.on('$destroy', function() { + $document.off('keyup', onKeyUp); + }); + } + }; +} +ngModule.directive('vnBind', directive); + diff --git a/client/core/src/directives/index.js b/client/core/src/directives/index.js index 23392e5e0..ed316a512 100644 --- a/client/core/src/directives/index.js +++ b/client/core/src/directives/index.js @@ -7,3 +7,4 @@ import './acl'; import './on-error-src'; import './zoom-image'; import './visible-by'; +import './bind'; diff --git a/client/core/src/directives/specs/bind.spec.js b/client/core/src/directives/specs/bind.spec.js new file mode 100644 index 000000000..e69de29bb diff --git a/client/item/src/barcode/barcode.html b/client/item/src/barcode/barcode.html index f741c96f6..20d00d9af 100644 --- a/client/item/src/barcode/barcode.html +++ b/client/item/src/barcode/barcode.html @@ -24,6 +24,7 @@ diff --git a/client/item/src/list/list.html b/client/item/src/list/list.html index 574ba7b46..71ee7ba88 100644 --- a/client/item/src/list/list.html +++ b/client/item/src/list/list.html @@ -21,7 +21,7 @@ - + diff --git a/client/item/src/niche/niche.html b/client/item/src/niche/niche.html index 8c4b4b5ee..d21220f2c 100644 --- a/client/item/src/niche/niche.html +++ b/client/item/src/niche/niche.html @@ -49,6 +49,7 @@ diff --git a/client/item/src/tags/tags.html b/client/item/src/tags/tags.html index bf71966fe..19a2f3eae 100644 --- a/client/item/src/tags/tags.html +++ b/client/item/src/tags/tags.html @@ -60,6 +60,7 @@ - + diff --git a/client/ticket/src/list/ticket-list.html b/client/ticket/src/list/ticket-list.html index ca5e9eca1..aee90bb23 100644 --- a/client/ticket/src/list/ticket-list.html +++ b/client/ticket/src/list/ticket-list.html @@ -65,7 +65,7 @@ - + diff --git a/client/ticket/src/package/index/package.html b/client/ticket/src/package/index/package.html index 3f3130f62..7116c81ed 100644 --- a/client/ticket/src/package/index/package.html +++ b/client/ticket/src/package/index/package.html @@ -56,6 +56,7 @@ pointer vn-tooltip="Add package" tooltip-position = "right" + vn-bind="+" icon="add_circle" ng-click="$ctrl.addPackage()"> diff --git a/client/ticket/src/tracking/index.html b/client/ticket/src/tracking/index.html index f57c654af..9a23345fa 100644 --- a/client/ticket/src/tracking/index.html +++ b/client/ticket/src/tracking/index.html @@ -24,6 +24,6 @@ - + \ No newline at end of file