• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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-checked-element-behavior/iron-checked-element-behavior.html">
13<link rel="import" href="paper-inky-focus-behavior.html">
14
15<script>
16
17  /**
18   * Use `Polymer.PaperCheckedElementBehavior` to implement a custom element
19   * that has a `checked` property similar to `Polymer.IronCheckedElementBehavior`
20   * and is compatible with having a ripple effect.
21   * @polymerBehavior Polymer.PaperCheckedElementBehavior
22   */
23  Polymer.PaperCheckedElementBehaviorImpl = {
24
25    /**
26     * Synchronizes the element's checked state with its ripple effect.
27     */
28    _checkedChanged: function() {
29      Polymer.IronCheckedElementBehaviorImpl._checkedChanged.call(this);
30      if (this.hasRipple()) {
31        if (this.checked) {
32          this._ripple.setAttribute('checked', '');
33        } else {
34          this._ripple.removeAttribute('checked');
35        }
36      }
37    },
38
39    /**
40     * Synchronizes the element's `active` and `checked` state.
41     */
42    _buttonStateChanged: function() {
43      Polymer.PaperRippleBehavior._buttonStateChanged.call(this);
44      if (this.disabled) {
45        return;
46      }
47      if (this.isAttached) {
48        this.checked = this.active;
49      }
50    }
51
52  };
53
54  /** @polymerBehavior Polymer.PaperCheckedElementBehavior */
55  Polymer.PaperCheckedElementBehavior = [
56    Polymer.PaperInkyFocusBehavior,
57    Polymer.IronCheckedElementBehavior,
58    Polymer.PaperCheckedElementBehaviorImpl
59  ];
60
61</script>
62