2 -- Copyright 2013 The Chromium Authors. All rights reserved.
3 -- Use of this source code is governed by a BSD-style license that can be
4 -- found in the LICENSE file.
7 <polymer-element name="kb-altkey" attributes="char" on-pointerover="over"
8 on-pointerout="out" on-pointerup="up">
16 background-position: center center;
17 background-repeat: no-repeat;
18 background-size: contain;
28 * Filter out mouse/touch movements internal to this node. When moving
29 * inside a node, the event should be filter out.
30 * @param {Node} node The accent key node which receives event.
31 * @param {event} event A pointer move event.
32 * @return {boolean} True if event is externla to node.
34 function isRelevantEvent(node, event) {
35 return !(node.compareDocumentPosition(event.relatedTarget)
36 & Node.DOCUMENT_POSITION_CONTAINED_BY);
38 Polymer('kb-altkey', {
39 over: function(event) {
40 if (isRelevantEvent(this, event)) {
41 // Dragging over an accent key is equivalent to pressing on the accent
43 this.fire('key-down', {});
46 out: function(event) {
47 if (isRelevantEvent(this, event)) {
48 this.classList.remove('active');
53 char: this.char || this.textContent
55 this.fire('key-up', detail);
57 // TODO(bshe): kb-altkey should extend from kb-key-base.
58 autoRelease: function() {