summaryrefslogtreecommitdiffstats
path: root/chromium/ui/keyboard/resources/elements/kb-altkey-container.html
blob: 552c70fedb0c698e9ede1ee209948c09867ef12a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<!--
  -- Copyright 2013 The Chromium Authors. All rights reserved.
  -- Use of this source code is governed by a BSD-style license that can be
  -- found in the LICENSE file.
  -->

<polymer-element name="kb-altkey-container" attributes="keyset"
    on-pointerup="{{up}}">
  <template>
    <style>
      :host {
        -webkit-box-flex: 1;
        background-color: rgba(0, 0, 0, 0.6);
        bottom: 0;
        left: 0;
        position: absolute;
        right: 0;
        top: 0;
      }
    </style>
    <content select="#{{keyset}}"></content>
  </template>
  <script>
    Polymer('kb-altkey-container', {
      resetActiveElement: function() {
        var activeAccentKeySet = this.querySelector('#' + this.keyset);
        var offset = activeAccentKeySet.offset;
        var element = activeAccentKeySet.firstElementChild;
        while (offset) {
          element = element.nextElementSibling;
          offset--;
        }
        element.classList.add('active');
      },
      up: function(detail) {
        this.hidden = true;
        this.resetActiveElement();
        this.keyset = null;
      },

      hiddenChanged: function() {
        this.fire('stateChange', {
          state: 'candidatePopupVisibility',
          value: !!this.hidden
        });
      },
    });
  </script>
</polymer-element>