Index: third_party/polymer/v0_8/components/paper-checkbox/paper-checkbox.html |
diff --git a/third_party/polymer/v0_8/components/paper-checkbox/paper-checkbox.html b/third_party/polymer/v0_8/components/paper-checkbox/paper-checkbox.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..84bb03f677fa77e6d8db82aa771ed4325be05bff |
--- /dev/null |
+++ b/third_party/polymer/v0_8/components/paper-checkbox/paper-checkbox.html |
@@ -0,0 +1,177 @@ |
+<!-- |
+@license |
+Copyright (c) 2015 The Polymer Project Authors. All rights reserved. |
+This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt |
+The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt |
+The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt |
+Code distributed by Google as part of the polymer project is also |
+subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt |
+--> |
+ |
+<link rel="import" href="../polymer/polymer.html"> |
+<link rel="import" href="../paper-ripple/paper-ripple.html"> |
+<link rel="import" href="../paper-styles/default-theme.html"> |
+ |
+<!-- |
+`paper-checkbox` is a button that can be either checked or unchecked. User |
+can tap the checkbox to check or uncheck it. Usually you use checkboxes |
+to allow user to select multiple options from a set. If you have a single |
+ON/OFF option, avoid using a single checkbox and use `paper-toggle-button` |
+instead. |
+ |
+Example: |
+ |
+ <paper-checkbox>label</paper-checkbox> |
+ |
+ <paper-checkbox checked> label</paper-checkbox> |
+ |
+Styling a checkbox: |
+ |
+<style is="x-style"> |
+ * { |
+ /* Unhecked state colors. */ |
+ --paper-checkbox-unchecked-color: #5a5a5a; |
+ --paper-checkbox-unchecked-ink-color: #5a5a5a; |
+ |
+ /* Checked state colors. */ |
+ --paper-checkbox-checked-color: #009688; |
+ --paper-checkbox-checked-ink-color: #009688; |
+ } |
+</style> |
+ |
+@group Paper Elements |
+@class paper-checkbox |
+--> |
+ |
+/* TODO: This needs to use core-focusable when it's ready. */ |
+<dom-module id="paper-checkbox"> |
+ <style is="x-style"> |
+ * { |
+ --paper-checkbox-unchecked-color: var(--primary-text-color); |
+ --paper-checkbox-unchecked-ink-color: var(--primary-text-color); |
+ |
+ --paper-checkbox-checked-color: var(--default-primary-color); |
+ --paper-checkbox-checked-ink-color: var(--default-primary-color); |
+ } |
+ </style> |
+ |
+ <link rel="import" type="css" href="paper-checkbox.css"> |
+ |
+ <template> |
+ |
+ <div id="checkboxContainer"> |
+ <paper-ripple id="ink" class="circle" recenters checked$="[[checked]]"></paper-ripple> |
+ <div id="checkbox" class$="[[_computeCheckboxClass(checked)]]"> |
+ <div id="checkmark" class$="[[_computeCheckmarkClass(checked)]]"></div> |
+ </div> |
+ </div> |
+ |
+ <div id="checkboxLabel" aria-hidden="true"><content></content></div> |
+ |
+ </template> |
+</dom-module> |
+ |
+<script> |
+ Polymer({ |
+ is: 'paper-checkbox', |
+ |
+ // The custom properties shim is currently an opt-in feature. |
+ enableCustomStyleProperties: true, |
+ |
+ hostAttributes: { |
+ role: 'checkbox', |
+ 'aria-checked': false, |
+ tabindex: 0 |
+ }, |
+ |
+ properties: { |
+ /** |
+ * Fired when the checked state changes due to user interaction. |
+ * |
+ * @event change |
+ */ |
+ |
+ /** |
+ * Fired when the checked state changes. |
+ * |
+ * @event iron-change |
+ */ |
+ |
+ /** |
+ * Gets or sets the state, `true` is checked and `false` is unchecked. |
+ * |
+ * @attribute checked |
+ * @type boolean |
+ * @default false |
+ */ |
+ checked: { |
+ type: Boolean, |
+ value: false, |
+ reflectToAttribute: true, |
+ observer: '_checkedChanged' |
+ }, |
+ |
+ /** |
+ * If true, the user cannot interact with this element. |
+ * |
+ * @attribute disabled |
+ * @type boolean |
+ * @default false |
+ */ |
+ disabled: { |
+ type: Boolean |
+ } |
+ }, |
+ |
+ listeners: { |
+ keydown: '_onKeyDown', |
+ mousedown: '_onMouseDown' |
+ }, |
+ |
+ ready: function() { |
+ if (this.$.checkboxLabel.textContent == '') { |
+ this.$.checkboxLabel.hidden = true; |
+ } else { |
+ this.setAttribute('aria-label', this.$.checkboxLabel.textContent); |
+ } |
+ }, |
+ |
+ _computeCheckboxClass: function(checked) { |
+ if (checked) { |
+ return 'checked'; |
+ } |
+ }, |
+ |
+ _computeCheckmarkClass: function(checked) { |
+ if (!checked) { |
+ return 'hidden'; |
+ } |
+ }, |
+ |
+ _onKeyDown: function(e) { |
+ // Enter key. |
+ if (e.keyCode === 13) { |
+ this._onMouseDown(); |
+ e.preventDefault(); |
+ } |
+ }, |
+ |
+ _onMouseDown: function() { |
+ if (this.disabled) { |
+ return; |
+ } |
+ |
+ var old = this.checked; |
+ this.checked = !this.checked; |
+ |
+ if (this.checked !== old) { |
+ this.fire('iron-change'); |
+ } |
+ }, |
+ |
+ _checkedChanged: function() { |
+ this.setAttribute('aria-checked', this.checked ? 'true' : 'false'); |
+ this.fire('iron-change'); |
+ } |
+ }) |
+</script> |