Fix improper implementation of getKeyboardEvent
Bug: Issue 5088 Change-Id: Iee82c135230f78f823c25982aaeba1ea6ece1709
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
<!--
|
||||
Copyright (C) 2016 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<link rel="import" href="../../bower_components/polymer/polymer.html">
|
||||
<link rel="import" href="../../bower_components/iron-a11y-keys-behavior/iron-a11y-keys-behavior.html">
|
||||
|
||||
<script>
|
||||
(function(window) {
|
||||
'use strict';
|
||||
|
||||
var getKeyboardEvent = function(e) {
|
||||
return Polymer.dom(e.detail ? e.detail.keyboardEvent : e);
|
||||
};
|
||||
|
||||
var KeyboardShortcutBehaviorImpl = {
|
||||
modifierPressed: function(e) {
|
||||
e = getKeyboardEvent(e);
|
||||
// When e is a keyboardEvent, e.event is not null.
|
||||
if (e.event) { e = e.event; }
|
||||
return e.altKey || e.ctrlKey || e.metaKey || e.shiftKey;
|
||||
},
|
||||
|
||||
shouldSuppressKeyboardShortcut: function(e) {
|
||||
e = getKeyboardEvent(e);
|
||||
if (e.path[0].tagName === 'INPUT' || e.path[0].tagName === 'TEXTAREA') {
|
||||
return true;
|
||||
}
|
||||
for (var i = 0; i < e.path.length; i++) {
|
||||
if (e.path[i].tagName === 'GR-OVERLAY') { return true; }
|
||||
}
|
||||
return false;
|
||||
},
|
||||
};
|
||||
|
||||
window.Gerrit = window.Gerrit || {};
|
||||
/** @polymerBehavior Gerrit.KeyboardShortcutBehavior */
|
||||
window.Gerrit.KeyboardShortcutBehavior = [
|
||||
Polymer.IronA11yKeysBehavior,
|
||||
KeyboardShortcutBehaviorImpl,
|
||||
];
|
||||
})(window);
|
||||
</script>
|
||||
Reference in New Issue
Block a user