jellyfin-web/dashboard-ui/bower_components/iron-menu-behavior/iron-menubar-behavior.html

82 lines
2.1 KiB
HTML
Raw Normal View History

2015-06-21 14:31:21 -07:00
<!--
@license
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="iron-menu-behavior.html">
<script>
/**
* `Polymer.IronMenubarBehavior` implements accessible menubar behavior.
*
* @polymerBehavior Polymer.IronMenubarBehavior
*/
Polymer.IronMenubarBehaviorImpl = {
hostAttributes: {
'role': 'menubar'
},
keyBindings: {
'left': '_onLeftKey',
'right': '_onRightKey'
},
_onUpKey: function(event) {
2015-09-23 19:31:40 -07:00
this.focusedItem.click();
event.detail.keyboardEvent.preventDefault();
2015-06-21 14:31:21 -07:00
},
_onDownKey: function(event) {
2015-09-23 19:31:40 -07:00
this.focusedItem.click();
event.detail.keyboardEvent.preventDefault();
2015-06-21 14:31:21 -07:00
},
2016-02-02 13:36:33 -07:00
get _isRTL() {
return window.getComputedStyle(this)['direction'] === 'rtl';
},
2016-02-22 10:20:38 -07:00
_onLeftKey: function(event) {
2016-02-02 13:36:33 -07:00
if (this._isRTL) {
this._focusNext();
} else {
this._focusPrevious();
}
2016-02-22 10:20:38 -07:00
event.detail.keyboardEvent.preventDefault();
2015-06-21 14:31:21 -07:00
},
2016-02-22 10:20:38 -07:00
_onRightKey: function(event) {
2016-02-02 13:36:33 -07:00
if (this._isRTL) {
this._focusPrevious();
} else {
this._focusNext();
}
2016-02-22 10:20:38 -07:00
event.detail.keyboardEvent.preventDefault();
2015-06-21 14:31:21 -07:00
},
_onKeydown: function(event) {
2015-09-23 19:31:40 -07:00
if (this.keyboardEventMatchesKeys(event, 'up down left right esc')) {
2015-06-21 14:31:21 -07:00
return;
}
// all other keys focus the menu item starting with that character
this._focusWithKeyboardEvent(event);
}
};
/** @polymerBehavior Polymer.IronMenubarBehavior */
Polymer.IronMenubarBehavior = [
Polymer.IronMenuBehavior,
Polymer.IronMenubarBehaviorImpl
];
</script>