1<!--
2@license
3Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
4This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
5The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
6The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
7Code distributed by Google as part of the polymer project is also
8subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
9-->
10
11<link rel="import" href="../polymer/polymer.html">
12<link rel="import" href="../iron-behaviors/iron-button-state.html">
13<link rel="import" href="paper-ripple-behavior.html">
14
15<script>
16  /**
17   * `Polymer.PaperInkyFocusBehavior` implements a ripple when the element has keyboard focus.
18   *
19   * @polymerBehavior Polymer.PaperInkyFocusBehavior
20   */
21  Polymer.PaperInkyFocusBehaviorImpl = {
22    observers: [
23      '_focusedChanged(receivedFocusFromKeyboard)'
24    ],
25
26    _focusedChanged: function(receivedFocusFromKeyboard) {
27      if (receivedFocusFromKeyboard) {
28        this.ensureRipple();
29      }
30      if (this.hasRipple()) {
31        this._ripple.holdDown = receivedFocusFromKeyboard;
32      }
33    },
34
35    _createRipple: function() {
36      var ripple = Polymer.PaperRippleBehavior._createRipple();
37      ripple.id = 'ink';
38      ripple.setAttribute('center', '');
39      ripple.classList.add('circle');
40      return ripple;
41    }
42  };
43
44  /** @polymerBehavior Polymer.PaperInkyFocusBehavior */
45  Polymer.PaperInkyFocusBehavior = [
46    Polymer.IronButtonState,
47    Polymer.IronControlState,
48    Polymer.PaperRippleBehavior,
49    Polymer.PaperInkyFocusBehaviorImpl
50  ];
51</script>
52