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 border-color: #4285f4; | |
35 } | |
36 | |
37 To change the ink color for unchecked state: | |
38 | |
39 paper-checkbox::shadow #ink { | |
40 color: #b5b5b5; | |
41 } | |
42 | |
43 To change the checbox unchecked color: | |
44 | |
45 paper-checkbox::shadow #checkbox { | |
46 border-color: #b5b5b5; | |
47 } | |
48 | |
49 @group Paper Elements | |
50 @element paper-checkbox | |
51 @extends paper-radio-button | |
52 @homepage github.io | |
53 --> | |
54 | |
55 <link rel="import" href="../paper-radio-button/paper-radio-button.html"> | |
56 | |
57 <polymer-element name="paper-checkbox" extends="paper-radio-button" role="checkb
ox"> | |
58 <template> | |
59 | |
60 <link rel="stylesheet" href="paper-checkbox.css"> | |
61 | |
62 <div id="checkboxContainer" class="{{ {labeled: label} | tokenList }}" > | |
63 | |
64 <paper-ripple id="ink" class="circle recenteringTouch" checked?="{{!checked}
}"></paper-ripple> | |
65 | |
66 <div id="checkbox" on-animationend="{{checkboxAnimationEnd}}" on-webkitAnima
tionEnd="{{checkboxAnimationEnd}}"></div> | |
67 | |
68 </div> | |
69 | |
70 <div id="checkboxLabel" hidden?="{{!label}}">{{label}}<content></content></div
> | |
71 | |
72 </template> | |
73 <script> | |
74 | |
75 Polymer('paper-checkbox', { | |
76 | |
77 /** | |
78 * Fired when the checked state changes due to user interaction. | |
79 * | |
80 * @event change | |
81 */ | |
82 | |
83 /** | |
84 * Fired when the checked state changes. | |
85 * | |
86 * @event core-change | |
87 */ | |
88 | |
89 toggles: true, | |
90 | |
91 checkedChanged: function() { | |
92 var cl = this.$.checkbox.classList; | |
93 cl.toggle('checked', this.checked); | |
94 cl.toggle('unchecked', !this.checked); | |
95 cl.toggle('checkmark', !this.checked); | |
96 cl.toggle('box', this.checked); | |
97 this.setAttribute('aria-checked', this.checked ? 'true': 'false'); | |
98 this.fire('core-change'); | |
99 }, | |
100 | |
101 checkboxAnimationEnd: function() { | |
102 var cl = this.$.checkbox.classList; | |
103 cl.toggle('checkmark', this.checked && !cl.contains('checkmark')); | |
104 cl.toggle('box', !this.checked && !cl.contains('box')); | |
105 } | |
106 | |
107 }); | |
108 | |
109 </script> | |
110 </polymer-element> | |
OLD | NEW |