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

Side by Side 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, 7 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 unified diff | Download patch
OLDNEW
(Empty)
1
2 Polymer({
3 is: 'paper-checkbox',
4
5 // The custom properties shim is currently an opt-in feature.
6 enableCustomStyleProperties: true,
7
8 hostAttributes: {
9 role: 'checkbox',
10 'aria-checked': false,
11 tabindex: 0
12 },
13
14 properties: {
15 /**
16 * Fired when the checked state changes due to user interaction.
17 *
18 * @event change
19 */
20
21 /**
22 * Fired when the checked state changes.
23 *
24 * @event iron-change
25 */
26
27 /**
28 * Gets or sets the state, `true` is checked and `false` is unchecked.
29 *
30 * @attribute checked
31 * @type boolean
32 * @default false
33 */
34 checked: {
35 type: Boolean,
36 value: false,
37 reflectToAttribute: true,
38 observer: '_checkedChanged'
39 },
40
41 /**
42 * If true, the user cannot interact with this element.
43 *
44 * @attribute disabled
45 * @type boolean
46 * @default false
47 */
48 disabled: {
49 type: Boolean
50 }
51 },
52
53 listeners: {
54 keydown: '_onKeyDown',
55 mousedown: '_onMouseDown'
56 },
57
58 ready: function() {
59 if (this.$.checkboxLabel.textContent == '') {
60 this.$.checkboxLabel.hidden = true;
61 } else {
62 this.setAttribute('aria-label', this.$.checkboxLabel.textContent);
63 }
64 },
65
66 _computeCheckboxClass: function(checked) {
67 if (checked) {
68 return 'checked';
69 }
70 },
71
72 _computeCheckmarkClass: function(checked) {
73 if (!checked) {
74 return 'hidden';
75 }
76 },
77
78 _onKeyDown: function(e) {
79 // Enter key.
80 if (e.keyCode === 13) {
81 this._onMouseDown();
82 e.preventDefault();
83 }
84 },
85
86 _onMouseDown: function() {
87 if (this.disabled) {
88 return;
89 }
90
91 var old = this.checked;
92 this.checked = !this.checked;
93
94 if (this.checked !== old) {
95 this.fire('iron-change');
96 }
97 },
98
99 _checkedChanged: function() {
100 this.setAttribute('aria-checked', this.checked ? 'true' : 'false');
101 this.fire('iron-change');
102 }
103 })
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698