| OLD | NEW |
| (Empty) |
| 1 <!-- | |
| 2 Copyright (c) 2014 The Polymer Project Authors. All rights reserved. | |
| 3 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt | |
| 4 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt | |
| 5 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt | |
| 6 Code distributed by Google as part of the polymer project is also | |
| 7 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt | |
| 8 --> | |
| 9 | |
| 10 <!-- | |
| 11 `paper-checkbox` is a button that can be either checked or unchecked. User | |
| 12 can tap the checkbox to check or uncheck it. Usually you use checkboxes | |
| 13 to allow user to select multiple options from a set. If you have a single | |
| 14 ON/OFF option, avoid using a single checkbox and use `paper-toggle-button` | |
| 15 instead. | |
| 16 | |
| 17 Example: | |
| 18 | |
| 19 <paper-checkbox></paper-checkbox> | |
| 20 | |
| 21 <paper-checkbox checked></paper-checkbox> | |
| 22 | |
| 23 Styling checkbox: | |
| 24 | |
| 25 To change the ink color for checked state: | |
| 26 | |
| 27 paper-checkbox::shadow #ink[checked] { | |
| 28 color: #4285f4; | |
| 29 } | |
| 30 | |
| 31 To change the checkbox checked color: | |
| 32 | |
| 33 paper-checkbox::shadow #checkbox.checked { | |
| 34 background-color: #4285f4; | |
| 35 border-color: #4285f4; | |
| 36 } | |
| 37 | |
| 38 To change the ink color for unchecked state: | |
| 39 | |
| 40 paper-checkbox::shadow #ink { | |
| 41 color: #b5b5b5; | |
| 42 } | |
| 43 | |
| 44 To change the checbox unchecked color: | |
| 45 | |
| 46 paper-checkbox::shadow #checkbox { | |
| 47 border-color: #b5b5b5; | |
| 48 } | |
| 49 | |
| 50 @group Paper Elements | |
| 51 @element paper-checkbox | |
| 52 @extends paper-radio-button | |
| 53 @homepage github.io | |
| 54 --> | |
| 55 | |
| 56 <link rel="import" href="../paper-radio-button/paper-radio-button.html"> | |
| 57 | |
| 58 <polymer-element name="paper-checkbox" extends="paper-radio-button" role="checkb
ox"> | |
| 59 <template> | |
| 60 | |
| 61 <link rel="stylesheet" href="paper-checkbox.css"> | |
| 62 | |
| 63 <div id="checkboxContainer" class="{{ {labeled: label} | tokenList }}" > | |
| 64 | |
| 65 <paper-ripple id="ink" class="circle recenteringTouch" checked?="{{!checked}
}"></paper-ripple> | |
| 66 | |
| 67 <div id="checkbox"> | |
| 68 <div id="checkmark" on-animationend="{{checkboxAnimationEnd}}" on-webkitAn
imationEnd="{{checkboxAnimationEnd}}"></div> | |
| 69 </div> | |
| 70 | |
| 71 </div> | |
| 72 | |
| 73 <div id="checkboxLabel" hidden?="{{!label}}">{{label}}<content></content></div
> | |
| 74 | |
| 75 </template> | |
| 76 <script> | |
| 77 | |
| 78 Polymer('paper-checkbox', { | |
| 79 | |
| 80 /** | |
| 81 * Fired when the checked state changes due to user interaction. | |
| 82 * | |
| 83 * @event change | |
| 84 */ | |
| 85 | |
| 86 /** | |
| 87 * Fired when the checked state changes. | |
| 88 * | |
| 89 * @event core-change | |
| 90 */ | |
| 91 | |
| 92 toggles: true, | |
| 93 | |
| 94 checkedChanged: function() { | |
| 95 this.$.checkbox.classList.toggle('checked', this.checked); | |
| 96 this.setAttribute('aria-checked', this.checked ? 'true': 'false'); | |
| 97 this.$.checkmark.classList.toggle('hidden', !this.checked); | |
| 98 this.fire('core-change'); | |
| 99 }, | |
| 100 | |
| 101 checkboxAnimationEnd: function() { | |
| 102 var cl = this.$.checkmark.classList; | |
| 103 cl.toggle('hidden', !this.checked && cl.contains('hidden')); | |
| 104 } | |
| 105 | |
| 106 }); | |
| 107 | |
| 108 </script> | |
| 109 </polymer-element> | |
| OLD | NEW |