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