| OLD | NEW |
| 1 <!-- | 1 <!-- |
| 2 @license | 2 @license |
| 3 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. | 3 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. |
| 4 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt | 4 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt |
| 5 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt | 5 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt |
| 6 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt | 6 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt |
| 7 Code distributed by Google as part of the polymer project is also | 7 Code distributed by Google as part of the polymer project is also |
| 8 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt | 8 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt |
| 9 --> | 9 --> |
| 10 | 10 |
| 11 <link rel="import" href="../polymer/polymer.html"> | 11 <link rel="import" href="../polymer/polymer.html"> |
| 12 <link rel="import" href="../paper-ripple/paper-ripple.html"> | 12 <link rel="import" href="../paper-ripple/paper-ripple.html"> |
| 13 <link rel="import" href="../paper-styles/default-theme.html"> | 13 <link rel="import" href="../paper-styles/default-theme.html"> |
| 14 <link rel="import" href="../paper-behaviors/paper-radio-button-behavior.html"> | 14 <link rel="import" href="../paper-behaviors/paper-inky-focus-behavior.html"> |
| 15 | 15 |
| 16 <!-- | 16 <!-- |
| 17 | 17 |
| 18 `paper-checkbox` is a button that can be either checked or unchecked. User | 18 `paper-checkbox` is a button that can be either checked or unchecked. User |
| 19 can tap the checkbox to check or uncheck it. Usually you use checkboxes | 19 can tap the checkbox to check or uncheck it. Usually you use checkboxes |
| 20 to allow user to select multiple options from a set. If you have a single | 20 to allow user to select multiple options from a set. If you have a single |
| 21 ON/OFF option, avoid using a single checkbox and use `paper-toggle-button` | 21 ON/OFF option, avoid using a single checkbox and use `paper-toggle-button` |
| 22 instead. | 22 instead. |
| 23 | 23 |
| 24 Example: | 24 Example: |
| (...skipping 10 matching lines...) Expand all Loading... |
| 35 ----------------|-------------|---------- | 35 ----------------|-------------|---------- |
| 36 `--paper-checkbox-unchecked-color` | Checkbox color when the input is not checke
d | `--primary-text-color` | 36 `--paper-checkbox-unchecked-color` | Checkbox color when the input is not checke
d | `--primary-text-color` |
| 37 `--paper-checkbox-unchecked-ink-color` | Selected/focus ripple color when the in
put is not checked | `--primary-text-color` | 37 `--paper-checkbox-unchecked-ink-color` | Selected/focus ripple color when the in
put is not checked | `--primary-text-color` |
| 38 `--paper-checkbox-checked-color` | Checkbox color when the input is checked | `-
-default-primary-color` | 38 `--paper-checkbox-checked-color` | Checkbox color when the input is checked | `-
-default-primary-color` |
| 39 `--paper-checkbox-checked-ink-color` | Selected/focus ripple color when the inpu
t is checked | `--default-primary-color` | 39 `--paper-checkbox-checked-ink-color` | Selected/focus ripple color when the inpu
t is checked | `--default-primary-color` |
| 40 `--paper-checkbox-label-color` | Label color | `--primary-text-color` | 40 `--paper-checkbox-label-color` | Label color | `--primary-text-color` |
| 41 | 41 |
| 42 @demo demo/index.html | 42 @demo demo/index.html |
| 43 --> | 43 --> |
| 44 | 44 |
| 45 <style is="custom-style"> | |
| 46 :root { | |
| 47 --paper-checkbox-unchecked-color: var(--primary-text-color); | |
| 48 --paper-checkbox-unchecked-ink-color: var(--primary-text-color); | |
| 49 | |
| 50 --paper-checkbox-checked-color: var(--default-primary-color); | |
| 51 --paper-checkbox-checked-ink-color: var(--default-primary-color); | |
| 52 | |
| 53 --paper-checkbox-label-color: var(--primary-text-color); | |
| 54 } | |
| 55 </style> | |
| 56 | |
| 57 <dom-module id="paper-checkbox"> | 45 <dom-module id="paper-checkbox"> |
| 58 <link rel="import" type="css" href="paper-checkbox.css"> | 46 <link rel="import" type="css" href="paper-checkbox.css"> |
| 59 | 47 |
| 60 <template> | 48 <template> |
| 61 | 49 |
| 62 <div id="checkboxContainer"> | 50 <div id="checkboxContainer"> |
| 63 <paper-ripple id="ink" class="circle" center checked$="[[checked]]"></pape
r-ripple> | 51 <paper-ripple id="ink" class="circle" center checked$="[[checked]]"></pape
r-ripple> |
| 64 <div id="checkbox" class$="[[_computeCheckboxClass(checked)]]"> | 52 <div id="checkbox" class$="[[_computeCheckboxClass(checked)]]"> |
| 65 <div id="checkmark" class$="[[_computeCheckmarkClass(checked)]]"></div> | 53 <div id="checkmark" class$="[[_computeCheckmarkClass(checked)]]"></div> |
| 66 </div> | 54 </div> |
| 67 </div> | 55 </div> |
| 68 | 56 |
| 69 <div id="checkboxLabel" aria-hidden="true"><content></content></div> | 57 <div id="checkboxLabel" aria-hidden="true"><content></content></div> |
| 70 | 58 |
| 71 </template> | 59 </template> |
| 72 | 60 |
| 73 <script> | 61 <script> |
| 74 Polymer({ | 62 Polymer({ |
| 75 is: 'paper-checkbox', | 63 is: 'paper-checkbox', |
| 76 | 64 |
| 77 behaviors: [ | 65 behaviors: [ |
| 78 Polymer.PaperRadioButtonBehavior | 66 Polymer.PaperInkyFocusBehavior |
| 79 ], | 67 ], |
| 80 | 68 |
| 81 hostAttributes: { | 69 hostAttributes: { |
| 82 role: 'checkbox', | 70 role: 'checkbox', |
| 83 'aria-checked': false, | 71 'aria-checked': false, |
| 84 tabindex: 0 | 72 tabindex: 0 |
| 85 }, | 73 }, |
| 86 | 74 |
| 87 properties: { | 75 properties: { |
| 88 /** | 76 /** |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 _checkedChanged: function(checked) { | 129 _checkedChanged: function(checked) { |
| 142 this.setAttribute('aria-checked', this.checked ? 'true' : 'false'); | 130 this.setAttribute('aria-checked', this.checked ? 'true' : 'false'); |
| 143 this.active = this.checked; | 131 this.active = this.checked; |
| 144 this.fire('iron-change'); | 132 this.fire('iron-change'); |
| 145 }, | 133 }, |
| 146 | 134 |
| 147 _computeCheckboxClass: function(checked) { | 135 _computeCheckboxClass: function(checked) { |
| 148 if (checked) { | 136 if (checked) { |
| 149 return 'checked'; | 137 return 'checked'; |
| 150 } | 138 } |
| 139 return ''; |
| 151 }, | 140 }, |
| 152 | 141 |
| 153 _computeCheckmarkClass: function(checked) { | 142 _computeCheckmarkClass: function(checked) { |
| 154 if (!checked) { | 143 if (!checked) { |
| 155 return 'hidden'; | 144 return 'hidden'; |
| 156 } | 145 } |
| 146 return ''; |
| 157 } | 147 } |
| 158 }) | 148 }) |
| 159 </script> | 149 </script> |
| 160 | 150 |
| 161 </dom-module> | 151 </dom-module> |
| OLD | NEW |