Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Unified Diff: third_party/polymer/v0_8/components-chromium/paper-checkbox/paper-checkbox-extracted.js

Issue 1082403004: Import Polymer 0.8 and several key elements. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Also remove polymer/explainer Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/polymer/v0_8/components-chromium/paper-checkbox/paper-checkbox-extracted.js
diff --git a/third_party/polymer/v0_8/components-chromium/paper-checkbox/paper-checkbox-extracted.js b/third_party/polymer/v0_8/components-chromium/paper-checkbox/paper-checkbox-extracted.js
new file mode 100644
index 0000000000000000000000000000000000000000..acf136cb783d55cd3621f222f8039e0f0fd62881
--- /dev/null
+++ b/third_party/polymer/v0_8/components-chromium/paper-checkbox/paper-checkbox-extracted.js
@@ -0,0 +1,103 @@
+
+ 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');
+ }
+ })

Powered by Google App Engine
This is Rietveld 408576698