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